AgentBack: AI-native API/MCP framework for agents AgentBack, an AI-native API and MCP framework for building agent services, has been released as an alpha, ESM-only package requiring Node 22.13+ and TypeScript 6. Built on LoopBack 4's dependency-injection core, it allows developers to define a single Zod schema that automatically generates REST endpoints, MCP tools, OpenAPI docs, typed clients, and validation, eliminating contract drift. The framework includes machine-actionable errors, agent-readable documentation, and built-in support for auth, metering, and observability. 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 → docs/concepts/dependency-injection.html 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 skills/agentback/SKILL.md 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.