By Integration Lead1 min read
MCP Server Connector for External DB
Connecting Agentforce topics to an external Postgres database using Model Context Protocol (MCP) server endpoints and secure stdio/HTTP transport.
In this advanced tutorial, we configure an external Postgres database connection for Salesforce Agentforce using the open standard Model Context Protocol (MCP).
Architecture Overview
flowchart LR
Agent[Agentforce Agent] --> Atlas[Atlas Reasoning Engine]
Atlas --> MCPBridge[MCP Client Bridge]
MCPBridge --> MCPServer[MCP Server: Node/Python]
MCPServer --> DB[(PostgreSQL DB)]
Step 1: Deploying the MCP Server
Create a lightweight Node.js or Python service that exposes tools to the Agentforce runtime:
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import pg from "pg";
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });
const server = new Server({ name: "agentforce-db", version: "1.0.0" }, { capabilities: { tools: {} } });
server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: [
{
name: "query_order_status",
description: "Lookup real-time order status and fulfillment tracking",
inputSchema: {
type: "object",
properties: { order_id: { type: "string" } },
required: ["order_id"]
}
}
]
}));
Step 2: Register Tool in Agent Builder
- Navigate to Agentforce Builder in your Salesforce Org.
- Under Actions, select Add MCP Endpoint.
- Point to your authenticated endpoint and map parameters to Topic inputs.
- Verify using the interactive Agent Simulator.
Frequently Asked Questions
Why use Model Context Protocol with Agentforce?
Model Context Protocol (MCP) allows Agentforce agents to query private databases and external APIs without hardcoding custom integrations or storing credentials inside the LLM prompt.
Does MCP replace Salesforce Data Cloud?
No. MCP complements Data Cloud by providing low-latency, transactional tool execution directly into operational database clusters.