mcp recipe
Wrap an MCP server as Agentmatic tools
Connect to any MCP (Model Context Protocol) server and expose its tools to your agent. Three lines for stdio servers, four for SSE.
3 min read · Published May 4, 2026 · Languages: python, typescript
The pattern
MCP is becoming the open standard for AI tools. Any MCP server (filesystem, git, browser, Postgres, GitHub) is one client connection away from being callable by your agent.
MCP in one line: An MCP server is a process that exposes tools over JSON-RPC; an MCP client (your agent) discovers and calls them.
Stdio transport
from agentmatic.tools.mcp import MCPClient
fs = MCPClient.stdio([
"npx", "-y", "@modelcontextprotocol/server-filesystem", "/Users/me/projects"
])
tools = await fs.list_tools_as_agentmatic()
agent = create_react_agent(llm=OpenAI(), tools=tools)
SSE / HTTP transport
mcp = await MCPClient.sse("https://my-mcp.example.com/mcp")
tools = await mcp.list_tools_as_agentmatic()
TypeScript
import { MCPClient, createReactAgent, OpenAI } from '@agentmatic/core';
const fs = await MCPClient.stdio([
'npx', '-y', '@modelcontextprotocol/server-filesystem', '/Users/me/projects'
]);
const tools = await fs.listToolsAsAgentmatic();
const agent = createReactAgent({ llm: new OpenAI(), tools });
Discover servers from mcp.json
If you already have an mcp.json for Claude Desktop / Cursor:
from agentmatic.tools.mcp import discover_from_config
clients = await discover_from_config() # reads ~/.mcp/mcp.json + project-local
tools = await asyncio.gather(*[c.list_tools_as_agentmatic() for c in clients.values()])