A step-by-step guide to extending Salesforce Agentforce agents with external tools using the Model Context Protocol (MCP) hosted on MuleSoft CloudHub. The tutorial covers building a timezone MCP server in MuleSoft using DataWeave 2.0, securing it with OAuth 2.0 via Anypoint Connected Apps, deploying it to CloudHub, registering it in Salesforce's API Catalog, and wiring it into an Agentforce agent via Agent Studio. The MCP approach eliminates custom Apex callouts by using JSON-RPC over HTTP with automatic token management, tool discovery, and error handling handled by the Salesforce platform.

7m read timeFrom developer.salesforce.com
Post cover image
Table of contents
Why MCP matters for developersWhy MuleSoft for hosting MCP serversReady to configure the MCP server on your MuleSoft (Anypoint Platform) instance?Registering the MCP server in SalesforceAgentforce integration: Invoking MCP tools via JSON-RPCConclusionResourcesAbout the authors

Questions this post answers

How do I connect an Agentforce agent to an external MCP server without writing Apex?

Register the MCP server in Salesforce via Setup → API Catalog → MCP Server → Import External MCP Server. Provide the server URL, OAuth 2.0 credentials (client ID and secret from a Connected App), and the identity provider token URL. Salesforce automatically calls initialize, fetches the tool catalog via tools/list, creates GenAiFunction metadata records, and manages token acquisition and refresh — no Apex callouts required. Teams wiring Agentforce to external services track MCP integration patterns on daily.dev.

What MCP protocol methods does a MuleSoft-hosted MCP server need to implement?

A MuleSoft MCP server must implement three core JSON-RPC methods: initialize (protocol handshake, negotiating version 2024-11-05), tools/list (returns the tool catalog Salesforce uses for discovery), and tools/call (executes the named tool with provided arguments and returns results wrapped in MCP content arrays as {"type":"text","text":"…"}). Bearer token validation runs before method routing, returning error code -32000 for unauthorized requests. Developers building MCP-compatible servers find implementation details like these on daily.dev.

What are the minimum prerequisites to register an external MCP server in Salesforce Agentforce?

Registering an external MCP server in Agentforce requires a MuleSoft Anypoint subscription, Agentforce/Einstein enablement, a Connected App configured with the client credentials grant, Agent Studio access, and a deployed CloudHub application. The MCP server must be reachable over HTTPS and implement the initialize and tools/list methods so Salesforce can perform automatic tool discovery during registration. Salesforce architects evaluating Agentforce extensibility options follow the latest requirements on daily.dev.

186 Impressions