anvil mcp to serve your MCP-exposed routes and any standalone tool files in server/tools/ as a Model Context Protocol (MCP) tool server. AI agents, orchestrators, and local clients such as Claude Desktop can then discover and call your tools without any additional glue code.
Anvil supports two transport modes: Streamable HTTP (the default) for networked agents and hosted deployments, and --stdio for local clients that communicate over standard input/output.
Usage
Flags
Directory Anvil scans for route files. Only routes that carry
meta.mcp.expose = true are registered as MCP tools.Directory of standalone tool files to include alongside route-derived tools. If this directory does not exist, it is silently skipped — no error is thrown.
Serve the MCP server over stdio instead of HTTP. Use this mode when connecting a local client such as Claude Desktop directly to the process. In stdio mode, the protocol channel is
stdout; all Anvil diagnostics are written to stderr so they do not corrupt the protocol stream.HTTP port for Streamable HTTP mode. Ignored when
--stdio is set.URL path at which the Streamable HTTP endpoint is mounted. Ignored when
--stdio is set.HTTP mode (default)
Start the MCP server on its default port:http://localhost:3100/mcp.
Custom port and endpoint
stdio mode
Start the MCP server over stdio for use with Claude Desktop or another local client:Exposing a route as an MCP tool
To include a route as an MCP tool, add ameta export to the route file with mcp.expose set to true:
If
server/tools/ does not exist, anvil mcp silently skips it. You do not need to create the directory or pass --tools with a different path unless you have standalone tool files to include.