Why Anvil’s approach is different
Most frameworks require you to maintain two parallel surfaces — an HTTP API and a separate tool definition — each with its own schema and validation logic. Anvil eliminates that split. When you mark a route withmeta.mcp.expose, Anvil reads its paramsSchema (a Zod object you already defined for HTTP validation), converts it to JSON Schema automatically, and advertises the tool to MCP clients. The same handler function runs in both contexts.
server/tools/ and are served by the same command.
How it works
Annotate a route (or add a standalone tool)
Add
meta.mcp.expose = true and a paramsSchema to any route file, or drop a new file in server/tools/ with a default function and an inputSchema.Run anvil mcp
Start the MCP server with
anvil mcp. By default it listens on :3100/mcp over Streamable HTTP. Pass --stdio for local clients like Claude Desktop.Transport modes
| Mode | Command | Endpoint | Best for |
|---|---|---|---|
| Streamable HTTP | anvil mcp | http://localhost:3100/mcp | Remote agents, AI frameworks, CI |
| stdio | anvil mcp --stdio | stdin/stdout | Claude Desktop, local CLI tools |
--port / --endpoint flags) can be changed at the command line. See the CLI reference for all flags.
What gets served
anvil mcp collects tools from two places and merges them into a single MCP server:
- Route-derived tools — every route file that exports
meta.mcp.expose = true - Standalone tools — every file in
server/tools/that default-exports a function
anvil lint validates MCP-exposed routes at build time: it checks that paramsSchema keys match the folder params in the path and that the schema converts losslessly to JSON Schema. Run anvil lint --strict to treat schema-conversion warnings as errors.Learn more
Exposing Routes
Mark a route with
meta.mcp.expose and let Anvil generate the tool definition from your existing Zod schema.Standalone Tools
Define tools that aren’t tied to an HTTP route in
server/tools/ and serve them from the same anvil mcp command.Claude Desktop
Connect your Anvil MCP server to Claude Desktop in minutes using stdio mode and a one-line config snippet.