MCP bridge (bidirectional)
Consume any MCP server as AgentsKit tools, or expose your AgentsKit tools to MCP hosts — over stdio or any transport.
Model Context Protocol (MCP) is the emerging open standard for
connecting LLM hosts (Claude Desktop, Cursor, Codex, OpenClaw, Zed, IDEs)
to external tool servers. @agentskit/tools/mcp ships a minimal bidirectional
bridge — consume MCP servers as AgentsKit tools, and expose your
AgentsKit tools to any MCP host.
This is a protocol subset: initialize + tools/list + tools/call
over JSON-RPC 2.0. Full MCP (resources, prompts, sampling) is a
follow-up.
#Install
npm install @agentskit/toolsTransports are framework-agnostic — bring your own stdio, WebSocket, or SSE + POST. An in-memory transport pair ships for tests.
#Consume an MCP server
import { spawn } from 'node:child_process'
import {
createMcpClient,
createStdioTransport,
toolsFromMcpClient,
} from '@agentskit/tools/mcp'
import { createRuntime } from '@agentskit/runtime'
const child = spawn('my-mcp-server', ['--flag'], { stdio: ['pipe', 'pipe', 'inherit'] })
const transport = createStdioTransport(child)
const client = createMcpClient({ transport })
await client.initialize()
const tools = await toolsFromMcpClient(client)
const runtime = createRuntime({ adapter, tools })
// Later:
await client.close()toolsFromMcpClient advertises every MCP tool as a native
ToolDefinition — schemas pass through, errors propagate, results
are flattened from the MCP content[] array into a single string.
#Run the published AgentsKit MCP server
For a ready-made stdio server, install @agentskit/mcp instead of writing a
transport wrapper:
npx -y @agentskit/mcp@0.3.9 --tools fetch,searchUse the smallest tool set that fits the task. filesystem, sqlite, and
especially shell are opt-in capabilities and should not be enabled by a
copy-paste recipe without a scoped root or explicit permission.
#Claude Desktop and Cursor
Use this JSON in Claude Desktop or .cursor/mcp.json in a project:
{
"mcpServers": {
"agentskit": {
"command": "npx",
"args": ["-y", "@agentskit/mcp@0.3.9", "--tools", "fetch,search"]
}
}
}#Codex
Codex uses TOML configuration, not the JSON wrapper above:
[mcp_servers.agentskit]
command = "npx"
args = ["-y", "@agentskit/mcp@0.3.9", "--tools", "fetch,search"]#OpenClaw
OpenClaw can save and probe the stdio server directly:
openclaw mcp add agentskit \
--command npx \
--arg -y \
--arg @agentskit/mcp@0.3.9 \
--arg --tools \
--arg fetch,search
openclaw mcp doctor agentskit --probeThese recipes prove host configuration, not marketplace inclusion or product adoption. Pi is intentionally not listed as a native MCP host here; its integration path requires a separate extension or package.
#Publish AgentsKit tools as an MCP server
import { createMcpServer, createStdioTransport } from '@agentskit/tools/mcp'
import { webSearch, fetchUrl } from '@agentskit/tools'
const transport = createStdioTransport(process as unknown as {
stdin: typeof process.stdin
stdout: typeof process.stdout
on?: typeof process.on
})
createMcpServer({
transport,
tools: [webSearch(), fetchUrl()],
serverInfo: { name: 'my-agentskit-mcp', version: '1.0.0' },
onEvent: e => console.error('[mcp]', e),
})Your process now speaks MCP on stdin/stdout. Point Claude Desktop, Cursor, Codex, OpenClaw, or any MCP host at the binary and your AgentsKit tools show up as first-class.
#Transports
| Transport | Provider |
|---|---|
createStdioTransport(child) | newline-delimited JSON over stdin/stdout |
createInMemoryTransportPair() | paired in-process transports — tests, in-process bridges |
| Your own | implement the McpTransport contract (send + onMessage + optional onClose + close) — WebSocket, SSE + POST, etc. |
#See also
- Tool composer — chain N tools into one macro tool
- Mandatory sandbox — enforce policy on imported MCP tools
- More providers
Explore nearby
- PeerRecipes
Copy-paste solutions grouped by theme. Every recipe end-to-end, runs as written.
- PeerCustom adapter
Wrap any LLM API as an AgentsKit adapter. Plug-and-play with the rest of the kit in 30 lines.
- PeerAdapter contract tests
Verify any adapter against the ADR 0001 invariants A1–A10 with the shared test harness.
Scraping, voice, maps, browser agent
Firecrawl + Jina Reader, OpenAI Images + ElevenLabs + Whisper + Deepgram, Nominatim + OpenWeatherMap + CoinGecko, and a BYO-Playwright browser agent.
Connect AgentsKit to your coding agent
Fix MCP setup across Codex, Claude, Cursor, Cline, and Continue with pinned configurations and an executable server proof.