Agent-native, end to end

Interfaces agents use.
Backends agents build.

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

weather.ts — one contract, two surfaces
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

The Zod schema is the contract

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.

Positioning

For APIs that apps and agents consume

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

Agent ergonomics, end to end

Proven DI core

A hierarchical Context of Bindings with @inject, providers, interceptors, extension points, and tag-based discovery — ported from LoopBack 4.

Dependency injection →

Hybrid surfaces

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 →

Errors agents can fix

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 →

Safety primitives

confirm: payload-bound confirmation tokens and idempotency: key replay, declared on the route or tool that must not run twice.

Operations agents can't break →

Per-call pricing

@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.

Metering & payments →

Typed client, no codegen

TypeScript consumers import the same schemas and get typed calls plus runtime validation — the client never imports a running server.

Contract-first clients →

Tool-surface budgets

Every tool definition costs context-window tokens on every connection. toolCostReport token-prices the MCP surface before agents pay for it.

Tools are not endpoints →

Production rails

Auth (JWT, OAuth 2.1), authorization voters, health probes, Prometheus metrics, OpenTelemetry, rate limiting, validated config — all as DI components.

Deploy to production →

Documentation

A guided path, ideas first

Three ideas carry the whole framework: everything is a binding in a context, schemas live once on the decorator, and servers are components.

From the blog

Design notes from the framework boundary

All posts →

Introducing AgentBack

A TypeScript framework for agent-facing services: one Zod contract across REST, MCP, docs, typed clients, policy, and usage rails.

Read post

Boundary coherence is the product

Why AgentBack treats a Zod schema as the same artifact across runtime validation, TypeScript, OpenAPI, MCP, and docs.

Read post

Charge agents per call

One @price decorator meters a route or MCP tool and gates it behind a payment rail — x402 today, Stripe from the same usage log.

Read post

Your API's first reader is an agent

/llms.txt and /llms-full.txt served from the same registry as /openapi.json — derived contracts can't drift.

Read post

For coding agents

Hand the build to a coding agent

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.

terminal
# 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

A worked example, end to end

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.

ninemindai/agentback-demo Weather MCP server

One Zod schema set, served three ways — stdio, authenticated HTTP, and a dev console. Backed by the free Open-Meteo API.

  • one schema → REST + MCP + typed client + docs
  • AgentError, /llms.txt, tool-cost report
  • the canonical agent-plus-skill build
github.com/ninemindai/agentback-demo →

Quick start

Run the examples in two minutes

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.

terminal
# 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