Proven DI core
A hierarchical Context of Bindings with
@inject, providers, interceptors, extension points,
and tag-based discovery — ported from LoopBack 4.
Agent-native, end to end
AgentBack gives your REST endpoints, MCP tools, OpenAPI docs, typed
clients, and validation one Zod contract — one
schema, every boundary. Agents consume that surface with
machine-actionable errors, /llms.txt, and MCP tools;
and because there's a single source of truth, a coding agent can
author the whole surface from it without drift. Built on
LoopBack 4's proven dependency-injection core, rebuilt for ESM
and Node 22.
alpha · ESM-only · Node 22.13+ · TypeScript 6
const City = z.object({city: z.string().min(1)});
const Report = z.object({summary: z.string(), tempC: z.number()});
@api({basePath: '/weather'})
class WeatherController {
@get('/forecast/{city}', {path: City, response: Report})
async forecast(input: {path: z.infer<typeof City>}) { /* … */ }
}
@mcpServer()
class WeatherTools {
@tool('forecast', {input: City, output: Report})
async forecast(input: z.infer<typeof City>) { /* … */ }
}
One artifact, many views
Declare a schema once, on the decorator. The framework derives every other representation from it — so a coding agent adds a surface in one edit and nothing drifts.
z.infer typethe handler's input type, enforced at compile time
/openapi.json, rendered in Swagger
UI
/llms.txtagent-readable surface map from the same route registry
Positioning
Most stacks keep the runtime contract, the service contract, and the agent contract in three hand-synchronized places.
| Stack | Runtime contract | Service contract | Agent/tool contract |
|---|---|---|---|
| Express + raw Zod | Hand-wired Zod | Hand-written OpenAPI | Hand-written manifest |
| Fastify | JSON Schema / TypeBox | OpenAPI via plugin | Custom adapter |
| Hono | Zod (validator) | OpenAPI via add-on | Custom adapter |
| tRPC | Zod | TypeScript-only | Custom adapter |
| NestJS | class-validator | Swagger decorators | Custom adapter |
| FastAPI | Pydantic | OpenAPI from same models | Custom adapter |
| AgentBack | Zod | OpenAPI from same Zod | MCP from same Zod |
Fastify and Hono are transport runtimes, not competitors. They solve HTTP plumbing; AgentBack solves the layer above — one Zod schema projected to REST, OpenAPI, and MCP through a DI container, riding on a host beneath it. Hono is the closest sibling in spirit (Web-standard core, codegen-free typed client, Zod), and AgentBack is built to stay host-portable so the same projection runs wherever the handler is mounted.
What's in the box
A hierarchical Context of Bindings with
@inject, providers, interceptors, extension points,
and tag-based discovery — ported from LoopBack 4.
REST and MCP servers are components over the same container. Run either, or both from one process — controllers and tool classes are just bindings.
Build a hybrid app →Stable codes, per-field issues, the violated schema, retryability, and remediation hints — the same machine-actionable envelope on REST and MCP.
Read the design note →
confirm: payload-bound confirmation tokens and
idempotency: key replay, declared on the route or
tool that must not run twice.
@price('$0.001') meters a route or tool; the price
gate refuses unpaid calls with an x402/MPP challenge. Stripe
metered billing from the same usage log.
TypeScript consumers import the same schemas and get typed calls plus runtime validation — the client never imports a running server.
Contract-first clients →
Every tool definition costs context-window tokens on every
connection. toolCostReport token-prices the MCP
surface before agents pay for it.
Auth (JWT, OAuth 2.1), authorization voters, health probes, Prometheus metrics, OpenTelemetry, rate limiting, validated config — all as DI components.
Deploy to production →Documentation
Three ideas carry the whole framework: everything is a binding in a context, schemas live once on the decorator, and servers are components.
For coding agents
AgentBack ships an agent skill that teaches Claude Code, Codex, Cursor, and 20+ other agents the conventions that aren't guessable from type signatures — schema-on-decorator, the slot-0 input bundle, the DI container. One Zod schema is the only source of truth, so an agent adds a route, its MCP tool, and its docs in a single edit without drift. The docs are agent-readable too — /llms.txt, /llms-full.txt, and a markdown mirror of every page — so the agent reads the framework the way it reads your API.
# install the AgentBack skill into your agent of choice
npx skills add ninemindai/agentback
# point an agent at the docs corpus
curl -s https://agentback.dev/llms.txt
Built with AgentBack
Not a snippet — a real service. agentback-demo is a
Weather server where one Zod schema set is served over stdio,
authenticated HTTP, and a dev console. It's the shape a coding agent
and the skill produce: one contract fanning out to REST, MCP, a
typed client, and docs, with nothing kept in sync by hand.
One Zod schema set, served three ways — stdio, authenticated HTTP, and a dev console. Backed by the free Open-Meteo API.
AgentError, /llms.txt, tool-cost reportQuick start
AgentBack is in alpha — the end-to-end examples work and the API surface is still moving. Clone the repo and run a working REST, MCP, or hybrid app, each with its explorer UI.
# clone & build (tests and examples run against dist/)
git clone https://github.com/ninemindai/agentback
pnpm install && pnpm build
# REST + Swagger UI + Context Explorer
pnpm -F hello-rest start
# REST + MCP from one process, both UIs
pnpm -F hello-hybrid start