Skip to main content
Glama
fagun04

Salesforce MCP Server

by fagun04
README.md
# Salesforce MCP Server

An [MCP](https://modelcontextprotocol.io) server that exposes Salesforce
operations as tools over stdio, so any MCP client can query and modify
Salesforce data.

## Tools

| Tool                | Purpose                                              |
| ------------------- | ---------------------------------------------------- |
| `getAccount`        | Retrieve an Account by id                            |
| `searchContacts`    | Search Contacts by name / email / account            |
| `listOpportunities` | List Opportunities, filter by account and/or stage   |
| `createLead`        | Create a new Lead                                    |
| `updateCase`        | Update fields on an existing Case                    |

## Setup

1. Install and build:

   ```bash
   npm install
   npm run build
   ```

2. Create a Salesforce **Connected App** and enable the OAuth 2.0
   **Client Credentials** flow (see `.env.example` for the exact steps).

3. Copy `.env.example` to `.env` and fill in your credentials.

4. Run:

   ```bash
   npm start          # runs dist/index.js
   # or during development:
   npm run dev
   ```

## Using with an MCP client (e.g. Claude Desktop)

Add to your client's MCP config:

```json
{
  "mcpServers": {
    "salesforce": {
      "command": "node",
      "args": ["/absolute/path/to/salesforce-mcp/dist/index.js"],
      "env": {
        "SF_LOGIN_URL": "https://login.salesforce.com",
        "SF_CLIENT_ID": "your_consumer_key",
        "SF_CLIENT_SECRET": "your_consumer_secret"
      }
    }
  }
}
```

## Notes

- The client caches the OAuth token and auto-refreshes on 401.
- SOQL string inputs are escaped, but treat this as a starting point — add
  field-level and object-level permission checks appropriate to your org.
- To target a sandbox, set `SF_LOGIN_URL=https://test.salesforce.com`.