Proven DI core
A hierarchical Context
of Binding
s with
@inject
, providers, interceptors, extension points, and tag-based discovery β ported from LoopBack 4.
Dependency injection β 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
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
type/openapi.json
, rendered in Swagger
UI
/llms.txt
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 |
| 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 |
What's in the box
A hierarchical Context
of Binding
s 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.
Stable codes, per-field issues, the violated schema, retryability, and remediation hints β the same machine-actionable envelope on REST and MCP.
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.
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.
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.txt),
[/llms-full.txt](llms-full.txt), and a markdown mirror of
every page β so the agent reads the framework the way it reads your API.
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.