Turn your CAMEL ChatAgent into an MCP server—let any client (Claude, Cursor, custom apps) connect and use your agent as a universal AI backend.
Why export a ChatAgent as an MCP server?
Publishing your ChatAgent as an MCP server turns your agent into a universal AI backend.
Any MCP-compatible client (Claude, Cursor, editors, or your own app) can connect, chat, and run tools through your agent as if it were a native API—no custom integration required.
Scripted Server:
Launch your agent as an MCP server with the ready-made scripts in services/.
Configure your MCP client (Claude, Cursor, etc.) to connect:
Tip: Just point your MCP client at this config, and it will auto-discover and call your agent!
Method 2: Use `to_mcp()`
Turn any ChatAgent into an MCP server instantly with to_mcp():
agent_mcp_server.py
Copy
from camel.agents import ChatAgent# Create a chat agent with your modelagent = ChatAgent(model="gpt-4o-mini")# Convert to an MCP servermcp_server = agent.to_mcp( name="demo", description="A demonstration of ChatAgent to MCP conversion")if __name__ == "__main__": print("Starting MCP server on http://localhost:8000") mcp_server.run(transport="streamable-http")
Supported transports:stdio, sse, streamable-http
What does this unlock?
Plug-and-play with any MCP client: Claude, Cursor, editors, automations—just connect and go.
Universal API: Your agent becomes an “AI API” for any tool that speaks MCP.
Security & Flexibility: Keep control over keys, environments, and agent configs.