
Anvil SDK
The Next.js of AI backends
Anvil is a Node.js backend framework built for AI and GenAI developers. It gives you Express-level flexibility and Next.js-style file-based routing, with a native agentic layer baked directly into the framework core.
Most teams building an AI product on Node end up stitching together Express for HTTP, a hand-rolled MCP server, scattered OpenAI/Anthropic SDK calls, and zero standard way to trace what a multi-step agent actually did. Anvil solves all of that at the framework level, so you're not duct-taping five tools together just to ship an agent endpoint.
Any Anvil route can speak REST, MCP, and A2A at the same time, off the same handler, no duplicated schemas. Add a meta block and a paramsSchema to a route, and it's instantly an MCP tool, no separate server required.
Installation
anvil init scaffolds your starter route, tsconfig, and package scripts. It'll ask what you're building, a basic API, an MCP server, or an agent route, or you can skip straight to a template with --template <name>.
Features
- File-based routing, Next.js style, mapped straight to HTTP routes with dynamic params, catch-alls, and scoped middleware
- One route, three protocols: REST, MCP, and A2A from a single handler
- Compile-time validation via
anvil lint, params, schemas, and MCP serializability checked before you ship - Built-in auth and security: bearer/API key auth, cookie sessions, rate limiting, body limits
- Agent-native primitives:
defineAgent,LlmClient(Anthropic, OpenAI, Gemini with fallback chains), guardrails, durable checkpointing, human-in-the-loop - Built-in observability with a local tracing dashboard at
/_anvilplus OTel export and cost tracking - Memory and RAG support: chunking, embeddings, vector store, and a semantic cache out of the box
- Full CLI:
dev,build,start,mcp,lint,eval,replay

