Skip to main content
Anvil JS 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 — MCP auto-exposure, a tool registry, agent orchestration, observability, and durability — built directly into the framework core. No second MCP codebase. No hand-wired tool schemas. No separate tracing infra.

Quickstart

Build your first Anvil app with file-based routes and an agent endpoint in under 5 minutes.

File-Based Routing

Learn how Anvil maps your folder structure to HTTP routes — dynamic params, catch-alls, and middleware scoping.

MCP & Tools

Expose any route as an MCP tool with a single annotation — no separate MCP server required.

Agent Routes

Define streaming agent endpoints with built-in LLM clients, tool calling, and abort propagation.

Observability

Trace every agent run, track token usage and cost, and replay past runs without live model calls.

CLI Reference

Reference for all Anvil CLI commands: dev, build, start, mcp, lint, eval, and replay.

Why Anvil?

Today, building an AI product on Node requires stitching together Express for HTTP, a hand-written MCP server, OpenAI/Anthropic SDK calls scattered across routes, and no standard way to trace a multi-step agent run. Anvil solves this once at the framework layer:
  • One route, three protocols. Any Anvil route automatically speaks REST, MCP, and A2A — same handler, no duplicated schemas.
  • Compile-time safety. The anvil build step validates param names, schema compatibility, and MCP serializability before you ship.
  • Agent-native primitives. defineAgent, LlmClient, guardrails, durable checkpointing, and human-in-the-loop are framework features, not application code you write per project.
  • Built-in observability. Every agent run is traced to a local SQLite store and viewable at /_anvil. OTel export ships out of the box.
1

Install Anvil

Add the anvil package to your Node.js project (requires Node ≥ 20).
npm install anvil
2

Create your first route

Add server/routes/get.ts — the file name and location define the HTTP method and path.
server/routes/get.ts
import type { Context } from 'anvil';

export default async function handler(ctx: Context) {
  return { message: 'Hello from Anvil!' };
}
3

Start the dev server

Run anvil dev to start a live-reload server. TypeScript routes load on the fly.
anvil dev
# [anvil] dev server listening on http://localhost:3000
4

Expose a route as an MCP tool

Add meta and a paramsSchema to turn any route into an MCP tool with anvil mcp.
server/routes/users/[id]/get.ts
import { z } from 'zod';
import type { Context } from 'anvil';

export const meta = { mcp: { expose: true, description: 'Fetch a user by ID' } };
export const paramsSchema = z.object({ id: z.string() });

export default async function handler(ctx: Context) {
  return findUser(ctx.params.id);
}
Anvil is currently pre-alpha. The core framework (routing, MCP, agents, observability, durability, RAG, A2A) is fully implemented. The public release (docs, examples, marketing) is the final milestone.