SA

Salesforce MCP Server: Data and Metadata Access

Access Salesforce data and metadata with the MCP server to query, sync, and manage records securely and efficiently.

Quick Install
npx -y @smn2gnt/MCP-Salesforce

Overview

The MCP (Model Context Protocol) Salesforce server provides a lightweight API layer to access Salesforce data and metadata in a consistent, programmatic way. It abstracts authentication and pagination, surfaces object and field definitions, and exposes record-level operations so developers can query, sync, and manage Salesforce records from other services or applications.

This server is useful when you need a stable, developer-friendly interface to Salesforce for integrations, analytics pipelines, or AI agents that require structured data and schema information. It centralizes common patterns—auth, query translation, metadata fetching—so clients don’t need to embed Salesforce-specific logic.

Features

  • Unified REST endpoints for data and metadata access
  • Support for Salesforce authentication (OAuth/JWT or username/password patterns)
  • Querying with pagination and basic filtering
  • SObject and field metadata retrieval (schema discovery)
  • Record read/write/delete operations
  • Data synchronization primitives for exporting or mirroring records
  • Simple JSON responses suitable for downstream tools and LLMs
  • Configurable via environment variables or .env files
  • Lightweight, easy to run locally or in containers

Installation / Configuration

Clone the repository, install dependencies, and configure environment variables. The following are typical steps for a Node.js-based server.

  1. Clone and install
git clone https://github.com/smn2gnt/MCP-Salesforce.git
cd MCP-Salesforce
npm install
  1. Create a .env file (example)
# OAuth / instance settings
SF_CLIENT_ID=your_salesforce_client_id
SF_CLIENT_SECRET=your_salesforce_client_secret
SF_INSTANCE_URL=https://login.salesforce.com
SF_LOGIN_URL=https://login.salesforce.com

# Alternative: username + password
SF_USERNAME=your_sf_username
SF_PASSWORD=your_sf_password
SF_SECURITY_TOKEN=your_security_token

# Optional JWT (if supported)
SF_JWT_KEY_PATH=/path/to/private.key
SF_JWT_SUBJECT=connected_app_subject

# Server settings
PORT=3000
LOG_LEVEL=info
  1. Start the server
npm run start
# or for development:
npm run dev
  1. Docker (optional)

If a Dockerfile is provided, build and run:

docker build -t mcp-salesforce .
docker run -e SF_CLIENT_ID=... -e SF_CLIENT_SECRET=... -p 3000:3000 mcp-salesforce

Adjust environment variables to match your Salesforce org and auth method. The server will log successful authentication and available endpoints on startup.

Available Resources

The MCP server exposes a small set of REST endpoints designed for common developer workflows. Example endpoints:

MethodPathDescription
GET/healthServer health check
POST/authExchange credentials / trigger auth (if implemented)
GET/metadata/sobjectsList available sObjects and basic schema
GET/metadata/sobjects/:nameDetailed metadata for an sObject (fields, types, relations)
POST/queryRun a SOQL-like query (body: { query: “SELECT … FROM …” })
GET/records/:sobject/:idFetch a single record by id
POST/records/:sobjectCreate or update records (bulk rules may apply)
DELETE/records/:sobject/:idDelete a record
POST/sync/:sobjectTrigger a synchronization/export job for an sObject

Example: simple query via curl

curl -X POST http://localhost:3000/query \
  -H "Content-Type: application/json" \
  -d '{"query": "SELECT Id, Name FROM Account WHERE CreatedDate = LAST_MONTH"}'

Responses are JSON and include paging cursors or metadata when applicable.

Additional resources you may find in the project:

  • Source code and issue tracker: https://github.com/smn2gnt/MCP-Salesforce
  • Local API docs (often hosted at /docs or described in repository README)
  • Example configuration templates and sample queries in the repo

Use Cases

  • Integrations: Use the MCP server as an intermediary API for services that need Salesforce data without embedding Salesforce clients. This reduces duplicated auth logic across services.

    • Example: A middleware that fetches Account metadata and returns a normalized schema to frontend apps.
  • Data synchronization and ETL: Trigger export or sync jobs for specific sObjects, then consume the exported data in a warehouse or analytics system.

    • Example: Run /sync/Contact nightly and stream the results to a BI pipeline.
  • Application development: Query records and schema during runtime to build dynamic forms or admin UIs that adapt to org customizations.

    • Example: Retrieve /metadata/sobjects/Case to render a form with the correct fields and picklist options.
  • AI and automation: Provide LLMs and agents with both data and schema context so generated actions (queries, updates) are grounded and validated.

    • Example: An automations service queries /metadata and /query endpoints to validate field names before constructing record updates.
  • Testing and tooling: Use the server to mock or wrap Salesforce behavior during development and CI, isolating auth and network complexity.

Notes and Best Practices

  • Protect environment secrets (client secret, private keys) using secure secrets management in production.
  • Prefer OAuth or JWT flows over username/password for long-term maintainability and security.
  • Use pagination and rate-limit handling in clients to avoid hitting Salesforce API limits.
  • Review and restrict API surface via network controls and authentication to limit exposure.

For code samples, configuration templates, and the latest API paths, refer to the project’s GitHub repository: https://github.com/smn2gnt/MCP-Salesforce.

Common Issues & Solutions

You received a GitHub issue notifying you that your project is listed on Spark and inviting you to claim it. You're unsure how to claim the listing or verify the listing's authenticity before granting access.

✓ Solution

I ran into this too! I followed the claim link, signed in with GitHub, and approved only the minimal OAuth scopes; Spark then checked my repo push access automatically and allowed me to claim the listing. After claiming I edited the title/description, added the 'Listed on Spark' badge to README, and reviewed the analytics. To be safe I verified the listing URL matches the repo and emailed [email protected] to confirm provenance before granting access. If you're nervous about permissions you can create a machine user or limit OAuth token scopes, then revoke access once the badge is added.

The MCP server is listed on Glama but other users can't use it because the listing has no Dockerfile. Glama needs a Dockerfile in the admin page so it can build and run the server for public use.

✓ Solution

I ran into this too! I claimed the listing first, then added a minimal Dockerfile through the Glama admin Dockerfile page that installs runtime deps, copies the app, sets WORKDIR, exposes the correct port and provides an explicit CMD. I also added a simple HEALTHCHECK so the platform's checks could validate the container. I built the image locally to verify it started, fixed a couple of missing dependencies, saved the Dockerfile in the admin, and re-ran the score checks until they all passed. After that the server became available to everyone.