Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

3.4 KB
Raw Blame

title: "CAMEL Agent as an MCP Server" icon: server description: "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."

doc_code_map: - "services/agent_mcp/agent_mcp_server.py" - "camel/agents/mcp_agent.py"

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.

Quick Start

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: ```json mcp_servers_config.json Example highlight={5} { "camel-chat-agent": { "command": "/path/to/python", "args": [ "/path/to/camel/services/agent_mcp/agent_mcp_server.py" ], "env": { "OPENAI_API_KEY": "...", "OPENROUTER_API_KEY": "...", "BRAVE_API_KEY": "..." } } } ``` Tip: Just point your MCP client at this config, and it will auto-discover and call your agent! Turn any ChatAgent into an MCP server instantly with to_mcp(): ```python agent_mcp_server.py lines icon="python" from camel.agents import ChatAgent

Create a chat agent with your model

agent = ChatAgent(model="gpt-4o-mini")

Convert to an MCP server

mcp_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")

<Info>
<b>Supported transports:</b> <code>stdio</code>, <code>sse</code>, <code>streamable-http</code>
</Info>
</Card>

</Card>


<Card title="What does this unlock?" icon="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.
</Card>

## Real-world Example

<Card title="Claude calling a CAMEL MCP server" icon="comments">
You can use Claude, Cursor, or any other app to call your custom agent!
Just connect to your <b>CAMEL MCP server</b>
<img src="/images/claude_example1.png" alt="Claude MCP Screenshot" />
<img src="/images/claude_example2.png" alt="Claude MCP Screenshot" />
<Info>
You can expose any number of custom tools, multi-agent workflows, or domain knowledge, right from your own laptop or server!
</Info>
</Card>

---

## Why make your ChatAgent an MCP server?

<Card title="Benefits" icon="star">
- **Universal Access:** Any client, any platform, anytime.
- **Multi-Agent Workflows:** Power agent societies by letting agents call each other.
- **Local Control:** Expose only the tools and data you want, with full security.
- **No Glue Code:** MCP handles discovery and invocation, no custom REST or RPC needed.
</Card>

---

<Info>
Want to create your own tools and toolkits?
See <a href="/key_modules/tools">Toolkits Reference</a> for everything you can expose to the MCP ecosystem!
</Info>