How to Connect AI Agents to Salesforce via MCP Server
Exposing Salesforce CRM data to AI agents requires bridging proprietary endpoints with agentic tool calls. Building a Salesforce MCP server exposes accounts, contacts, and opportunities as standardized tools. Using TypeScript and OAuth authentication, developers can establish secure, direct access channels for agents while coordinating work in persistent Fast.io workspaces.
Why AI Agents Need a Salesforce MCP Server
AI agents attempting to query customer relationship data are often blocked by proprietary CRM endpoints that require custom, brittle wrappers for every integration. Implementing a Salesforce MCP server replaces these one-off custom codebases with a standardized Model Context Protocol interface, exposing accounts, contacts, and opportunities directly to LLMs as reusable tools. Rather than writing unique request-response logic for each distinct agent, developers configure a single server that acts as a universal bridge.
This approach solves the integration bottleneck by shifting the interface definition from the vendor to a standardized protocol. A Salesforce MCP server translates Salesforce CRM endpoints into standardized Model Context Protocol tools for AI agents to query customer accounts. Agents can query, update, and search CRM records natively, discovering available actions dynamically without manual schema maintenance on the client application.
Agents that pull records from Salesforce usually need somewhere durable to put what they produce. Connecting a workspace for that is covered in the Fastio MCP integration guide.
Related guides
- How to Implement Collaborative MCP Server Management for DevOps TeamsCollaborative MCP management brings DevOps principles to AI agent infrastructure. As teams move from local scripts to...
- How to Use an MCP Server for Figma Design-to-Code WorkflowsAn MCP server for Figma gives AI coding agents direct access to design files, component metadata, and layout context....
- Top MCP Workspaces for AgentsMCP workspaces enable agents to access shared tools and files via the Model Context Protocol. This guide reviews the...
- How to Integrate Fastio MCP With MetaGPTIntegrating Fastio MCP with MetaGPT gives your multi-agent teams persistent, shared file workspaces. They can store and...
- Fastio MCP Server Docker Compose Setup GuideUsing Docker Compose to set up a local Fastio MCP server provides a stable environment for testing agents and managing...
- How to Connect AI Agents to Google Analytics with MCPThe Google Analytics MCP server connects AI agents to GA4 properties through the Model Context Protocol, giving them...
More on this subject: MCP and Model Context Protocol (195 guides)
Salesforce API Request Limits and Architecture
When designing an integration that connects LLMs to Salesforce, understanding the underlying API request limits is a primary design constraint. In traditional integrations, a single backend service manages credentials and schedules jobs to run in batches. With agentic workflows, however, LLMs frequently make iterative tool calls in loops, which can rapidly exhaust daily API quotas if not properly budgeted.
Salesforce API request limits scale with user licenses, meaning the total capacity of your Salesforce organization depends on the number and types of user licenses purchased. According to Salesforce documentation, an Enterprise Edition organization has a base allocation of 100,000 requests per rolling 24-hour period, with additional requests added per license type, such as 1,000 requests per standard Salesforce license. These limits are pooled organization-wide, meaning that a runaway agent loop can deplete the API quota for the entire company.
To mitigate this risk, the MCP server acts as an intermediary. While developers can use alternatives like direct REST API requests or custom proxy endpoints, these models require writing custom throttling logic. An MCP server provides a standardized point to implement request pooling, query caching, and call rate limiting. By translating abstract agent requests into queries, the server protects the pooled daily allocation from unexpected depletion.
Step-by-Step Connected App Setup in the Console
Bootstrapping a Salesforce MCP server requires establishing a secure, authenticated channel to the Salesforce API. This is accomplished by creating a Connected App in the Salesforce console, which exposes the OAuth 2.0 endpoints required for the server to perform the token exchange. Headless agent integrations should use either the OAuth 2.0 Web Server Flow for initial authorization or the OAuth 2.0 JWT Bearer Flow for automated authentication.
To configure the connection, log in to your Salesforce Developer or Production org and go to Setup. Use the App Manager to create a New Connected App, supplying a name and contact email. Under the API section, check the box to Enable OAuth Settings and specify a callback URL. You must select the OAuth scopes for your implementation, specifically the API access scope and the offline access scope, the latter of which is required to obtain a refresh token.
Once the Connected App is saved, copy the Consumer Key and Consumer Secret. For automated agent environments, the server uses these credentials to initiate the token exchange. In the Web Server Flow, the developer performs a one-time authentication to consent to the app, generating an authorization code. The MCP server then sends a POST request containing this code, the client credentials, and the redirect URI to the token exchange endpoint, receiving an access token and a refresh token. The server stores the refresh token securely, allowing it to request new access tokens programmatically as they expire without manual human intervention.
Connect your AI agents to Salesforce securely
Bridge Salesforce and your agent workflows using persistent shared workspaces and a consolidated MCP toolset. Get started with a 14-day free trial.
Implementing a Salesforce MCP Server in TypeScript
With the OAuth credentials secured, the next step is building the actual server. This server uses the official Node.js Model Context Protocol SDK alongside a Salesforce client library, such as JSforce, to interact with the CRM. The server implements standard JSON-RPC communication, allowing it to run locally over a standard input-output transport or remotely using a transport like Server-Sent Events (SSE).
First, set up a Node.js project directory and install the necessary dependencies, including the Model Context Protocol SDK and JSforce, using your package manager. Configure the project to compile TypeScript. The main entry point initializes the Salesforce connection, registers the available tools, and defines the query handlers.
The following TypeScript code demonstrates how to set up the server, authenticate with a refresh token, register a query tool, and run the server over a standard stdio transport:
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
import jsforce from "jsforce";
const conn = new jsforce.Connection({
oauth2: {
clientId: process.env.SF_CLIENT_ID,
clientSecret: process.env.SF_CLIENT_SECRET,
redirectUri: "http://localhost:3000/oauth/callback"
},
instanceUrl: process.env.SF_INSTANCE_URL,
accessToken: process.env.SF_ACCESS_TOKEN,
refreshToken: process.env.SF_REFRESH_TOKEN
});
conn.on("refresh", (accessToken, res) => {
console.error("Salesforce access token refreshed");
});
const server = new Server(
{
name: "salesforce-mcp-server",
version: "1.0.0"
},
{
capabilities: {
tools: {}
}
}
);
server.setRequestHandler(ListToolsRequestSchema, async () => {
return {
tools: [
{
name: "query_salesforce_accounts",
description: "Execute a SOQL query to retrieve account records from Salesforce",
inputSchema: {
type: "object",
properties: {
soqlQuery: {
type: "string",
description: "The SOQL query string, for example: SELECT Id, Name, Industry, AnnualRevenue FROM Account LIMIT 10"
}
},
required: ["soqlQuery"]
}
}
]
};
});
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args } = request.params;
if (name === "query_salesforce_accounts") {
try {
const queryStr = args?.soqlQuery as string;
const result = await conn.query(queryStr);
return {
content: [
{
type: "text",
text: JSON.stringify(result.records, null, 2)
}
]
};
} catch (error) {
const err = error as Error;
return {
content: [
{
type: "text",
text: `Salesforce API error: ${err.message}`
}
],
isError: true
};
}
}
throw new Error(`Tool not found: ${name}`);
});
async function startServer() {
const transport = new StdioServerTransport();
await server.connect(transport);
console.error("Salesforce MCP Server started over stdio transport");
}
startServer().catch((error) => {
console.error("Fatal error starting Salesforce MCP server:", error);
process.exit(1);
});
This implementation registers the server and exposes a query tool that takes a SOQL query string as input. When the AI agent invokes the tool, the server executes the query on Salesforce using the authenticated connection and returns the serialized JSON payload.
Coordinating Multi-Agent Operations in Shared Workspaces
In complex enterprise settings, a single AI agent is rarely enough. Organizations often deploy specialized agents side by side, such as a research agent that queries Salesforce, a data processing agent that organizes the information, and a writer agent that draft reports. For these agents to work together and hand off deliverables to humans, they require a shared, persistent workspace.
While developers sometimes rely on local directories or standard cloud drives like Google Drive for file handoffs, these solutions lack the dedicated context and coordination interfaces required by agentic teams. Fast.io solves this problem by providing persistent, shared workspaces that act as the neutral ground where agents and humans collaborate. In these workspaces, agents read and write files directly, while humans track activity and review outputs.
In a typical workflow, a research agent queries the Salesforce MCP server for recent customer updates and exports the results as a CSV file to a Fast.io workspace. Once the file is saved, the agent can trigger a Fast.io Metadata View, which automatically parses the CSV file to extract structured fields like account owner, deal value, and close date into a queryable spreadsheet database. A writer agent, notified via the workspace activity feed or a webhook, accesses this extracted metadata, drafting a summary report inside a Collaborative Note.
Every organization starts with a 14-day free trial, which requires a credit card. Plans include Starter at 29 USD per month, Business at 99 USD per month, and Growth at 299 USD per month. Once the workspaces are established and the agents have populated the records, ownership of the organization can be transferred from the agent's account to a human administrator. For further workspace setup, refer to the pricing options and the storage for agents documentation.
Implementing Security and Query Tuning
Exposing CRM data to AI agents introduces security and operational risks that must be managed. Security is a primary concern when dealing with customer records, meaning that access must be configured using the principle of least privilege. The Salesforce user profile associated with your Connected App should be restricted to only the specific objects and fields required for the agent to complete its assigned tasks.
For data protection, Fastio runs on cloud infrastructure partners, including Google Cloud Platform and Cloudflare, that are certified to industry-leading security standards. In addition to transport and rest encryption, you can secure files and workspace access using granular permissions, per-file version history, and an append-only audit log. This ensures that any change made by an agent remains traceable and auditable.
Operationally, query tuning is required to prevent agents from depleting rolling API request limits. Developers should configure the MCP server to cache responses for static metadata and common queries. Furthermore, query queries must use strict filters and SOQL limit clauses to prevent returning bloated datasets. By pairing local caching on the MCP server with secure, persistent workspaces, developers can improve workflow throughput while keeping daily usage within thresholds. For data structuring guidelines, developers can consult our Metadata Views reference.
Frequently Asked Questions
Can you use MCP with Salesforce?
Yes, you can use the Model Context Protocol (MCP) to connect AI agents directly to Salesforce. By building or deploying a Salesforce MCP server, you can translate standard Salesforce REST API endpoints into reusable tools. This allows LLM agents to execute SOQL queries, retrieve records, and update entries using a unified JSON-RPC protocol rather than writing custom API connectors.
How does an AI agent query Salesforce data?
An AI agent queries Salesforce data by invoking tools exposed by a Salesforce MCP server. When the agent receives a request that requires customer data, it calls the query tool, passing a SOQL query string or record identifier. The MCP server executes the request against the Salesforce API using stored OAuth credentials and returns the serialized records to the agent's context.
What is the best way to expose CRM data to an LLM agent?
The best way to expose CRM data to an LLM agent is through a standardized Model Context Protocol server. MCP provides a universal, protocol-level interface that decouples the LLM from the underlying Salesforce API structure. This standard reduces custom integration code, provides a centralized point to enforce security permissions, and simplifies authorization through OAuth Connected Apps.
Related Resources
Connect your AI agents to Salesforce securely
Bridge Salesforce and your agent workflows using persistent shared workspaces and a consolidated MCP toolset. Get started with a 14-day free trial.