How to integrate Salesforce MCP with Autogen

Trusted by
AWS
Glean
Zoom
Airtable

30 min · no commitment · see it on your stack

Salesforce logo
AutoGen logo
divider

Introduction

This guide walks you through connecting Salesforce to AutoGen using the Composio tool router. By the end, you'll have a working Salesforce agent that can add new contact to spring campaign, clone opportunity with all associated products, complete follow-up task for lead smith through natural language commands.

This guide will help you understand how to give your AutoGen agent real control over a Salesforce account through Composio's Salesforce MCP server.

Before we dive in, let's take a quick look at the key ideas and tools involved.

Also integrate Salesforce with

TL;DR

Here's what you'll learn:
  • Get and set up your OpenAI and Composio API keys
  • Install the required dependencies for Autogen and Composio
  • Initialize Composio and create a Tool Router session for Salesforce
  • Wire that MCP URL into Autogen using McpWorkbench and StreamableHttpServerParams
  • Configure an Autogen AssistantAgent that can call Salesforce tools
  • Run a live chat loop where you ask the agent to perform Salesforce operations

What is AutoGen?

Autogen is a framework for building multi-agent conversational AI systems from Microsoft. It enables you to create agents that can collaborate, use tools, and maintain complex workflows.

Key features include:

  • Multi-Agent Systems: Build collaborative agent workflows
  • MCP Workbench: Native support for Model Context Protocol tools
  • Streaming HTTP: Connect to external services through streamable HTTP
  • AssistantAgent: Pre-built agent class for tool-using assistants

What is the Salesforce MCP server, and what's possible with it?

The Salesforce MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Salesforce account. It provides structured and secure access to your CRM data, so your agent can perform actions like managing contacts, handling opportunities, automating campaigns, and tracking tasks on your behalf.

  • Automated contact and lead management: Effortlessly create new accounts, add contacts or leads to campaigns, and associate contacts with accounts to keep your CRM data up-to-date.
  • Streamlined opportunity management: Let your agent clone opportunities, add products to deals, and manage the full sales cycle for your pipeline.
  • Intelligent campaign automation: Enable your agent to create campaigns, enroll contacts or leads, and track campaign engagement for more effective marketing.
  • Task completion and workflow efficiency: Have your agent mark Salesforce tasks as completed and update records, keeping your team on track without manual intervention.
  • Flexible record operations: Allow the agent to clone existing records or apply lead assignment rules, ensuring data consistency and smart routing across your Salesforce environment.

Supported Tools & Triggers

Tools
Triggers
Add contact to campaignAdds a contact to a campaign by creating a CampaignMember record to track campaign engagement.
Add lead to campaignAdds a lead to a campaign by creating a CampaignMember record, allowing you to track campaign engagement.
Add product to opportunityAdds a product (line item) to an opportunity.
Apply lead assignment rulesApplies configured lead assignment rules to a specific lead, automatically routing it to the appropriate owner based on your organization's rules.
Associate contact to accountAssociates a contact with an account by updating the contact's AccountId field.
Clone opportunity with productsClones an opportunity and optionally its products (line items).
Clone recordCreates a copy of an existing Salesforce record by reading its data, removing system fields, and creating a new record.
Close or abort a jobTool to close or abort a Salesforce Bulk API v2 ingest job.
Complete taskMarks a task as completed with optional completion notes.
Create accountCreates a new account in Salesforce with the specified information.
Create a recordTool to create a Salesforce record using the UI API.
Create campaignCreates a new campaign in Salesforce.
Create contactCreates a new contact in Salesforce with the specified information.
Create custom fieldTool to create a custom field on a Salesforce object using the Tooling API.
Create custom objectTool to create a custom object in Salesforce using the Metadata API.
Create leadCreates a new lead in Salesforce.
Create noteCreates a new note attached to a Salesforce record with the specified title and content.
Create opportunityCreates a new opportunity in Salesforce with the specified information.
Create SObject recordTool to create a new Salesforce SObject record.
Create sObject treeTool to create one or more sObject trees with root records of the specified type.
Create taskCreates a new task in Salesforce to track activities, to-dos, and follow-ups related to contacts, leads, or other records.
Delete accountPermanently deletes an account from Salesforce.
Delete campaignPermanently deletes a campaign from Salesforce.
Delete contactPermanently deletes a contact from Salesforce.
Delete fileTool to permanently delete a file from Salesforce.
Delete job queryTool to delete a Salesforce Bulk API v2 query job.
Delete leadPermanently deletes a lead from Salesforce.
Delete notePermanently deletes a note from Salesforce.
Delete opportunityPermanently deletes an opportunity from Salesforce.
Delete sObject recordTool to delete a single Salesforce record by its ID.
Delete multiple records (SObject Collections)Tool to delete up to 200 records in one request with optional rollback.
Execute sObject Quick ActionTool to execute a specific quick action on an sObject to create records with pre-configured defaults.
Execute SOSL searchExecute a SOSL search to search across multiple Salesforce objects.
Get batch of UI API recordsTool to retrieve multiple Salesforce records in a single request with customizable field selection.
Get accountRetrieves a specific account by ID from Salesforce, returning all available fields.
Get all objectsRetrieves all Salesforce objects (standard and custom) with detailed metadata.
Get all fields for an objectRetrieves all fields (standard and custom) for a Salesforce object with complete metadata including field types, constraints, picklist values, and relationships.
Get all navigation itemsGets all navigation items (tabs) that the user has access to.
Get API resources by versionTool to discover available REST API resources for a specified Salesforce API version.
Get an appTool to get metadata about a specific Salesforce app by ID.
Get appsTool to get metadata for all apps a user has access to.
Get campaignRetrieves a specific campaign by ID from Salesforce, returning all available fields.
Get Chatter resourcesTool to access Chatter resources directory.
Get child recordsTool to get child records for a specified parent record and child relationship name.
Get Compact LayoutsTool to retrieve compact layout information for multiple Salesforce objects.
Get composite resourcesTool to retrieve a list of available composite resources in Salesforce.
Get multiple records by IDsRetrieves multiple records of the same object type by IDs with a request body.
Get consent preferencesTool to retrieve aggregated consent preferences across multiple records for a specific action.
Get contactRetrieves a specific contact by ID from Salesforce, returning all available fields.
Retrieve specific contact by idRetrieves a Salesforce Contact by its unique ID; the ID must correspond to an existing Contact record in Salesforce.
Get dashboardGets detailed metadata for a specific dashboard including its components, layout, and filters.
Get file contentReturns the binary content of a Salesforce file, including references to external files.
Get file informationTool to retrieve comprehensive metadata and information about a specified file in Salesforce.
Get file sharesReturns information about the objects with which the specified file has been shared.
Get global actionsTool to retrieve actions displayed in the Salesforce Global Actions menu with metadata.
Get job failed record resultsTool to retrieve failed records from a Salesforce Bulk API 2.
Get job successful record resultsTool to retrieve successfully processed records from a Salesforce Bulk API 2.
Get job unprocessed record resultsTool to retrieve unprocessed records from a Salesforce Bulk API 2.
Get last selected appRetrieves the app the current user last selected or the app the user sees by default.
Get leadRetrieves a specific lead by ID from Salesforce, returning all available fields.
Get List View Header ActionsTool to retrieve header actions on list views.
Get batch of list view metadataTool to retrieve metadata for multiple list views in a single batch request.
Get list view metadataReturns list view metadata by object and list view API name.
Get list view records by IDReturns record data for a list view by its ID.
Get list view records by API nameRetrieves paginated record data for a specified list view using the object and list view API names.
Get list view resultsRetrieves the results of a list view for a specified sObject.
Get lookup field suggestionsTool to retrieve lookup field suggestions for editing lookup fields with search filtering.
Get lookup field suggestions with POSTTool to get lookup field suggestions with POST request.
Get MRU list view metadataTool to retrieve MRU list view metadata for a Salesforce object.
Get most recently used list view recordsTool to retrieve record data for an object's most recently used (MRU) list view.
Get noteRetrieves a specific note by ID from Salesforce, returning all available fields.
Get list views for an objectReturns a collection of list views associated with a Salesforce object.
Get opportunityRetrieves a specific opportunity by ID from Salesforce, returning all available fields.
Get organization limitsTool to retrieve organization limits with max and remaining allocations.
Get photo actionsTool to retrieve available photo actions for Salesforce pages.
Get Values for All Picklist FieldsTool to get values for all picklist fields of a record type, including dependent picklists.
Get job info queryTool to retrieve information about a Salesforce Bulk API v2 query job.
Get job query resultRetrieves results for a completed Bulk API v2 query job in CSV format.
Get quick actionsTool to retrieve global and object-specific quick actions from Salesforce.
Get record count for objectsTool to retrieve total record counts for specified Salesforce objects.
Get record edit page actionsTool to get available actions on record edit pages.
Get related list actionsTool to get actions on related lists for record detail pages.
Get batch of related list user preferencesTool to get a batch of related list user preferences from Salesforce.
Get related list records with request bodyTool to retrieve related list records with request body parameters for filtering and pagination.
Get search result layoutsRetrieves search result layout information for specified sObjects.
Search suggested queriesReturns a list of suggested searches based on the user's query string.
Get sObject by external IDTool to retrieve a Salesforce record by matching an external ID field value.
Get multiple sObject recordsTool to retrieve multiple records of the same sObject type in a single API call.
Get sObject list view informationTool to retrieve basic information about a specific list view for an sObject.
Get list views for sObjectTool to retrieve list views for a specified sObject.
Get PlatformAction SObject metadataRetrieves metadata description of PlatformAction SObject.
Get sObject Quick Action Default Values by IDRetrieves default field values for a quick action in a specific record context.
Get sObject Quick Action Default ValuesRetrieves default field values for a specific quick action on an sObject.
Get sObject record by IDTool to retrieve a single Salesforce record by ID from any sObject type.
Get records using sObject relationshipsRetrieves records by traversing sObject relationships using friendly URLs.
Get layouts for object with record typeTool to retrieve layout metadata for a specific record type on an object.
Get approval layouts for objectRetrieves approval layouts for a specified Salesforce object.
Get updated sObject recordsTool to retrieve a list of sObject records that have been updated within a given timeframe.
Get support knowledgeRetrieves the root of the Support Knowledge REST API.
Get directory of supported objectsTool to get a Salesforce org's active theme and directory of supported objects.
Get support knowledge articlesRetrieves user's visible knowledge articles and data categories from Salesforce Knowledge.
Get themeTool to get icons and colors for Salesforce UI themes.
Get lookup field actionsTool to get lookup field actions for a Salesforce object.
Get MRU List View ActionsTool to retrieve header actions available on the MRU (Most Recently Used) list view for a specified Salesforce object.
Get related list actionsTool to get available actions on related lists for a record detail page.
Get Personalized Navigation ItemsTool to get personalized navigation items for a specific Salesforce app.
Get Account AllAccounts list view metadataRetrieves list view metadata for the Account AllAccounts view using Salesforce UI API.
Get List View MetadataTool to get list view metadata from Salesforce UI API.
Get Account SearchResult list view metadataRetrieves list view metadata for the Account __SearchResult view using Salesforce UI API.
Get List Views for ObjectTool to get list views for a Salesforce object.
Get record UI data and metadataTool to retrieve layout, field metadata, and record data in a single response.
Get related list user preferencesTool to retrieve user preferences for a specific related list on an object.
Get user infoRetrieves information about the current user or a specific user in Salesforce.
Get custom actions headersTool to return HTTP headers for custom invocable actions without response body.
Get standard actions headersTool to return HTTP headers for standard invocable actions metadata without response body.
Get AppMenu Salesforce1 headersTool to return HTTP headers for AppMenu Salesforce1 mobile navigation items without response body.
Get process rules headersTool to return HTTP headers for process rules of an sObject without retrieving the response body.
Get Quick Actions headersTool to return HTTP headers for Quick Actions resource without response body.
Get quick action default values headers by IDTool to return HTTP headers for sObject quick action default values by context ID without response body.
Get global publisher layouts headersTool to return HTTP headers for all global publisher layouts without response body.
Get sObject quick action headersTool to return HTTP headers for a specific sObject quick action without response body.
Get User password headersTool to return HTTP headers for User password resource without response body.
List accountsLists accounts from Salesforce using SOQL query, allowing flexible filtering, sorting, and field selection.
List Analytics templatesTool to list CRM Analytics templates available in the org.
List campaignsLists campaigns from Salesforce using SOQL query, allowing flexible filtering, sorting, and field selection.
List contactsLists contacts from Salesforce using SOQL query, allowing flexible filtering, sorting, and field selection.
Get custom invocable actionsRetrieves the list of custom actions including Flow actions, Apex actions, and invocable processes.
List dashboardsLists all dashboards available in Salesforce with basic metadata including name, ID, and URLs.
List email templatesLists available email templates in Salesforce with filtering and search capabilities.
List leadsLists leads from Salesforce using SOQL query, allowing flexible filtering, sorting, and field selection.
List notesLists notes from Salesforce using SOQL query, allowing flexible filtering, sorting, and field selection.
List opportunitiesLists opportunities from Salesforce using SOQL query, allowing flexible filtering, sorting, and field selection.
List pricebook entriesLists pricebook entries from Salesforce using SOQL query, allowing flexible filtering, sorting, and field selection.
List pricebooksLists pricebooks from Salesforce using SOQL query, allowing flexible filtering, sorting, and field selection.
List reportsLists all reports available in Salesforce with basic metadata including name, ID, and URLs.
Get standard invocable actionsRetrieves the list of standard actions that can be statically invoked.
Log callLogs a completed phone call as a task in Salesforce with call-specific details like duration, type, and disposition.
Log email activityCreates an EmailMessage record to log email activity in Salesforce, associating it with related records.
Mass transfer ownershipTransfers ownership of multiple records to a new owner in a single operation using Salesforce's composite API for better performance.
Parameterized SearchTool to execute RESTful search using parameters instead of SOSL clause.
Upsert records using external IDTool to upsert up to 200 records using external ID field matching.
Execute Composite GraphTool to execute multiple related REST API requests in a single transactional call with up to 500 subrequests per graph.
Create records using sObject CollectionsTool to create up to 200 records in one request using sObject Collections.
Parameterized SearchTool to execute parameterized search across Salesforce objects with advanced filtering.
Query All (including deleted)Tool to execute SOQL queries including soft-deleted and archived records.
Remove from campaignRemoves a lead or contact from a campaign by deleting the CampaignMember record.
Retrieve lead by idRetrieves details for a Salesforce Lead by its ID; the specified Lead ID must exist in Salesforce.
Retrieve opportunities dataRetrieves all available Opportunity records, representing potential revenue-generating deals, from Salesforce.
Run reportRuns a report and returns the results.
Run SOQL queryExecutes a SOQL query against Salesforce data.
Search accountsSearch for Salesforce accounts using criteria like name, industry, type, location, or contact information.
Search campaignsSearch for Salesforce campaigns using multiple criteria like name, type, status, date range, or active status.
Search contactsSearch Salesforce Contact records (not Leads — use SALESFORCE_SEARCH_LEADS for those) using name, email, phone, account, or title.
Search suggested article title matchesSearch for Salesforce Knowledge articles with titles matching the search query.
Search leadsSearch for Salesforce leads using criteria like name, email, phone, company, title, status, or lead source.
Search notesSearch for Salesforce notes using multiple criteria like title, body content, parent record, owner, or creation date.
Search opportunitiesSearch for Salesforce opportunities using multiple criteria like name, account, stage, amount, close date, or status.
Search tasksSearch for Salesforce tasks using multiple criteria like subject, status, priority, assigned user, related records, or dates.
Send emailSends an email through Salesforce with options for recipients, attachments, and activity logging.
Send email from templateSends an email using a predefined Salesforce email template with merge field support.
Send mass emailSends bulk emails to multiple recipients immediately and irreversibly using a template or custom content.
Set user passwordTool to set or reset a user's password in Salesforce.
Update sObject recordTool to update specific fields in an existing Salesforce sObject record.
Get user password expiration statusTool to check whether a Salesforce user's password has expired.
Execute Tooling API queryTool to execute SOQL queries against Salesforce Tooling API metadata objects.
Update accountUpdates an existing account in Salesforce with the specified changes.
Update campaignUpdates an existing campaign in Salesforce with the specified changes.
Update contactUpdates an existing contact in Salesforce with the specified changes.
Update a favoriteTool to update a favorite's properties in Salesforce UI API.
Update leadUpdates an existing lead in Salesforce with the specified changes.
Update list view preferencesTool to update user preferences for a Salesforce list view including column widths, text wrapping, and display order.
Update noteUpdates an existing note in Salesforce with the specified changes.
Update opportunityUpdates an existing opportunity in Salesforce with the specified changes.
Update a recordTool to update a record's data in Salesforce via UI API.
Update Related List PreferencesTool to update user preferences for a specific related list on an object in Salesforce.
Update taskUpdates an existing task in Salesforce with new information.
Upload file to Salesforce FilesUpload a file to Salesforce Files home via the Connect REST API.
Upload job dataTool to upload CSV data to a Salesforce Bulk API v2 ingest job.
Upsert sObject by External IDTool to upsert records using sObject Rows by External ID.

What is the Composio tool router, and how does it fit here?

What is Composio SDK?

Composio's Composio SDK helps agents find the right tools for a task at runtime. You can plug in multiple toolkits (like Gmail, HubSpot, and GitHub), and the agent will identify the relevant app and action to complete multi-step workflows. This can reduce token usage and improve the reliability of tool calls. Read more here: Getting started with Composio SDK

The tool router generates a secure MCP URL that your agents can access to perform actions.

How the Composio SDK works

The Composio SDK follows a three-phase workflow:

  1. Discovery: Searches for tools matching your task and returns relevant toolkits with their details.
  2. Authentication: Checks for active connections. If missing, creates an auth config and returns a connection URL via Auth Link.
  3. Execution: Executes the action using the authenticated connection.

Step-by-step Guide

Prerequisites

You will need:

  • A Composio API key
  • An OpenAI API key (used by Autogen's OpenAIChatCompletionClient)
  • A Salesforce account you can connect to Composio
  • Some basic familiarity with Autogen and Python async

Getting API Keys for OpenAI and Composio

OpenAI API Key
  • Go to the OpenAI dashboard and create an API key. You'll need credits to use the models, or you can connect to another model provider.
  • Keep the API key safe.
Composio API Key
  • Log in to the Composio dashboard.
  • Navigate to your API settings and generate a new API key.
  • Store this key securely as you'll need it for authentication.

Install dependencies

bash
pip install composio python-dotenv
pip install autogen-agentchat autogen-ext-openai autogen-ext-tools

Install Composio, Autogen extensions, and dotenv.

What's happening:

  • composio connects your agent to Salesforce via MCP
  • autogen-agentchat provides the AssistantAgent class
  • autogen-ext-openai provides the OpenAI model client
  • autogen-ext-tools provides MCP workbench support

Set up environment variables

bash
COMPOSIO_API_KEY=your-composio-api-key
OPENAI_API_KEY=your-openai-api-key
USER_ID=your-user-identifier@example.com

Create a .env file in your project folder.

What's happening:

  • COMPOSIO_API_KEY is required to talk to Composio
  • OPENAI_API_KEY is used by Autogen's OpenAI client
  • USER_ID is how Composio identifies which user's Salesforce connections to use

Import dependencies and create Tool Router session

python
import asyncio
import os
from dotenv import load_dotenv
from composio import Composio

from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.tools.mcp import McpWorkbench, StreamableHttpServerParams

load_dotenv()

async def main():
    # Initialize Composio and create a Salesforce session
    composio = Composio(api_key=os.getenv("COMPOSIO_API_KEY"))
    session = composio.create(
        user_id=os.getenv("USER_ID"),
        toolkits=["salesforce"]
    )
    url = session.mcp.url
What's happening:
  • load_dotenv() reads your .env file
  • Composio(api_key=...) initializes the SDK
  • create(...) creates a Tool Router session that exposes Salesforce tools
  • session.mcp.url is the MCP endpoint that Autogen will connect to

Configure MCP parameters for Autogen

python
# Configure MCP server parameters for Streamable HTTP
server_params = StreamableHttpServerParams(
    url=url,
    timeout=30.0,
    sse_read_timeout=300.0,
    terminate_on_close=True,
    headers={"x-api-key": os.getenv("COMPOSIO_API_KEY")}
)

Autogen expects parameters describing how to talk to the MCP server. That is what StreamableHttpServerParams is for.

What's happening:

  • url points to the Tool Router MCP endpoint from Composio
  • timeout is the HTTP timeout for requests
  • sse_read_timeout controls how long to wait when streaming responses
  • terminate_on_close=True cleans up the MCP server process when the workbench is closed

Create the model client and agent

python
# Create model client
model_client = OpenAIChatCompletionClient(
    model="gpt-5",
    api_key=os.getenv("OPENAI_API_KEY")
)

# Use McpWorkbench as context manager
async with McpWorkbench(server_params) as workbench:
    # Create Salesforce assistant agent with MCP tools
    agent = AssistantAgent(
        name="salesforce_assistant",
        description="An AI assistant that helps with Salesforce operations.",
        model_client=model_client,
        workbench=workbench,
        model_client_stream=True,
        max_tool_iterations=10
    )

What's happening:

  • OpenAIChatCompletionClient wraps the OpenAI model for Autogen
  • McpWorkbench connects the agent to the MCP tools
  • AssistantAgent is configured with the Salesforce tools from the workbench

Run the interactive chat loop

python
print("Chat started! Type 'exit' or 'quit' to end the conversation.\n")
print("Ask any Salesforce related question or task to the agent.\n")

# Conversation loop
while True:
    user_input = input("You: ").strip()

    if user_input.lower() in ["exit", "quit", "bye"]:
        print("\nGoodbye!")
        break

    if not user_input:
        continue

    print("\nAgent is thinking...\n")

    # Run the agent with streaming
    try:
        response_text = ""
        async for message in agent.run_stream(task=user_input):
            if hasattr(message, "content") and message.content:
                response_text = message.content

        # Print the final response
        if response_text:
            print(f"Agent: {response_text}\n")
        else:
            print("Agent: I encountered an issue processing your request.\n")

    except Exception as e:
        print(f"Agent: Sorry, I encountered an error: {str(e)}\n")
What's happening:
  • The script prompts you in a loop with You:
  • Autogen passes your input to the model, which decides which Salesforce tools to call via MCP
  • agent.run_stream(...) yields streaming messages as the agent thinks and calls tools
  • Typing exit, quit, or bye ends the loop

Complete Code

Here's the complete code to get you started with Salesforce and AutoGen:

python
import asyncio
import os
from dotenv import load_dotenv
from composio import Composio

from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.tools.mcp import McpWorkbench, StreamableHttpServerParams

load_dotenv()

async def main():
    # Initialize Composio and create a Salesforce session
    composio = Composio(api_key=os.getenv("COMPOSIO_API_KEY"))
    session = composio.create(
        user_id=os.getenv("USER_ID"),
        toolkits=["salesforce"]
    )
    url = session.mcp.url

    # Configure MCP server parameters for Streamable HTTP
    server_params = StreamableHttpServerParams(
        url=url,
        timeout=30.0,
        sse_read_timeout=300.0,
        terminate_on_close=True,
        headers={"x-api-key": os.getenv("COMPOSIO_API_KEY")}
    )

    # Create model client
    model_client = OpenAIChatCompletionClient(
        model="gpt-5",
        api_key=os.getenv("OPENAI_API_KEY")
    )

    # Use McpWorkbench as context manager
    async with McpWorkbench(server_params) as workbench:
        # Create Salesforce assistant agent with MCP tools
        agent = AssistantAgent(
            name="salesforce_assistant",
            description="An AI assistant that helps with Salesforce operations.",
            model_client=model_client,
            workbench=workbench,
            model_client_stream=True,
            max_tool_iterations=10
        )

        print("Chat started! Type 'exit' or 'quit' to end the conversation.\n")
        print("Ask any Salesforce related question or task to the agent.\n")

        # Conversation loop
        while True:
            user_input = input("You: ").strip()

            if user_input.lower() in ['exit', 'quit', 'bye']:
                print("\nGoodbye!")
                break

            if not user_input:
                continue

            print("\nAgent is thinking...\n")

            # Run the agent with streaming
            try:
                response_text = ""
                async for message in agent.run_stream(task=user_input):
                    if hasattr(message, 'content') and message.content:
                        response_text = message.content

                # Print the final response
                if response_text:
                    print(f"Agent: {response_text}\n")
                else:
                    print("Agent: I encountered an issue processing your request.\n")

            except Exception as e:
                print(f"Agent: Sorry, I encountered an error: {str(e)}\n")

if __name__ == "__main__":
    asyncio.run(main())

Conclusion

You now have an Autogen assistant wired into Salesforce through Composio's Tool Router and MCP. From here you can:
  • Add more toolkits to the toolkits list, for example notion or hubspot
  • Refine the agent description to point it at specific workflows
  • Wrap this script behind a UI, Slack bot, or internal tool
Once the pattern is clear for Salesforce, you can reuse the same structure for other MCP-enabled apps with minimal code changes.

How to build Salesforce MCP Agent with another framework

FAQ

What are the differences in Tool Router MCP and Salesforce MCP?

With a standalone Salesforce MCP server, the agents and LLMs can only access a fixed set of Salesforce tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Salesforce and many other apps based on the task at hand, all through a single MCP endpoint.

Can I use Tool Router MCP with Autogen?

Yes, you can. Autogen fully supports MCP integration. You get structured tool calling, message history handling, and model orchestration while Tool Router takes care of discovering and serving the right Salesforce tools.

Can I manage the permissions and scopes for Salesforce while using Tool Router?

Yes, absolutely. You can configure which Salesforce scopes and actions are allowed when connecting your account to Composio. You can also bring your own OAuth credentials or API configuration so you keep full control over what the agent can do.

How safe is my data with Composio Tool Router?

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Salesforce data and credentials are handled as safely as possible.

Used by agents from

Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai

Never worry about agent reliability

We handle tool reliability, observability, and security so you never have to second-guess an agent action.