MCP Server
Expose your agent's tools as a Model Context Protocol (MCP) endpoint — connect from Claude Desktop, Cursor, or any MCP-compatible client.
How it works
Honi agents automatically expose a /mcp route when tools are defined. The endpoint speaks JSON-RPC 2.0 and implements the MCP 2024-11-05 protocol spec. No extra config needed — tools you define with tool() are automatically available over MCP.
Endpoints
| Endpoint | Method | Description |
|---|---|---|
/mcp | POST | JSON-RPC 2.0 MCP endpoint (initialize, tools/list, tools/call) |
/mcp/tools | GET | Convenience endpoint — lists available tools as JSON |
Connect from Claude Desktop
Add your deployed agent to Claude Desktop's MCP config:
Connect from Cursor
In Cursor settings → MCP, add a new server with the /mcp URL of your deployed worker.
Authentication
The /mcp endpoint is unauthenticated by default — fine for local Claude Desktop (stdio transport). For remote connections, lock it down with a Bearer token.
Set mcp.secretEnvVar in your agent config:
Set the secret via Wrangler:
Clients send Authorization: Bearer <secret> on every request. For Claude Desktop with a remote agent:
Standalone MCP Server
You can also use createMcpServer directly without createAgent — useful for exposing a set of tools without a chat interface:
API Reference
createMcpServer(tools)
Creates an MCP server from an array of tool definitions. Returns an object with:
| Property | Type | Description |
|---|---|---|
handleHttp | (req: Request) => Promise<Response> | HTTP handler — wire directly to your Worker's fetch |
handleRequest | (req: McpRequest) => Promise<McpResponse> | Low-level JSON-RPC handler |
tools | McpToolInfo[] | Tool definitions in MCP format |
toolsToMcp(tools)
Converts an array of Honi ToolDefinition objects to MCP tool format (with JSON Schema). Useful if you need the tool list for other purposes.
Supported MCP Methods
| Method | Description |
|---|---|
initialize | Handshake — returns protocol version and capabilities |
tools/list | Returns all tools with their JSON Schema definitions |
tools/call | Executes a tool by name with validated arguments |
ping | Health check |