AgentBack: AI-native API/MCP framework for agents

ninemind1 pts0 comments

AgentBack — interfaces agents use, backends agents build

Agent-native, end to end

Interfaces agents use.<br>Backends agents<br>build.

AgentBack gives your REST endpoints, MCP tools, OpenAPI docs, typed<br>clients, and validation one Zod contract — one<br>schema, every boundary. Agents consume that surface with<br>machine-actionable errors, /llms.txt, and MCP tools;<br>and because there's a single source of truth, a coding agent can<br>author the whole surface from it without drift. Built on<br>LoopBack 4's proven dependency-injection core, rebuilt for ESM<br>and Node 22.

Read the docs

ninemindai/agentback

alpha · ESM-only · Node 22.13+ ·<br>TypeScript 6

weather.ts — one contract, two surfaces

const City = z.object({city: z.string().min(1)});<br>const Report = z.object({summary: z.string(), tempC: z.number()});

@api({basePath: '/weather'})<br>class WeatherController {<br>@get('/forecast/{city}', {path: City, response: Report})<br>async forecast(input: {path: z.infertypeof City>}) { /* … */ }

@mcpServer()<br>class WeatherTools {<br>@tool('forecast', {input: City, output: Report})<br>async forecast(input: z.infertypeof City>) { /* … */ }

One artifact, many views

The Zod schema is the contract

Declare a schema once, on the decorator. The framework derives every<br>other representation from it — so a coding agent adds a surface in<br>one edit and nothing drifts.

Runtime validatorrequests & tool calls parsed before your code runs

z.infer typethe handler's input type, enforced at compile time

OpenAPI 3.1.1served at /openapi.json, rendered in Swagger<br>UI

MCP tool schemainput/output contracts on the official MCP SDK

/llms.txtagent-readable surface map from the same route registry

Typed clientno codegen — the client imports the same schemas

Positioning

For APIs that apps and agents consume

Most stacks keep the runtime contract, the service contract, and the<br>agent contract in three hand-synchronized places.

Stack<br>Runtime contract<br>Service contract<br>Agent/tool contract

Express + raw Zod<br>Hand-wired Zod<br>Hand-written OpenAPI<br>Hand-written manifest

tRPC<br>Zod<br>TypeScript-only<br>Custom adapter

NestJS<br>class-validator<br>Swagger decorators<br>Custom adapter

FastAPI<br>Pydantic<br>OpenAPI from same models<br>Custom adapter

AgentBack<br>Zod<br>OpenAPI from same Zod<br>MCP from same Zod

What's in the box

Agent ergonomics, end to end

Proven DI core

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

Dependency injection →

Hybrid surfaces

REST and MCP servers are components over the same container. Run<br>either, or both from one process — controllers and tool classes<br>are just bindings.

Build a hybrid app →

Errors agents can fix

Stable codes, per-field issues, the violated schema, retryability,<br>and remediation hints — the same machine-actionable envelope on<br>REST and MCP.

Read the design note →

Safety primitives

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

Operations agents can't break →

Per-call pricing

@price('$0.001') meters a route or tool; the price<br>gate refuses unpaid calls with an x402/MPP challenge. Stripe<br>metered billing from the same usage log.

Metering & payments →

Typed client, no codegen

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

Contract-first clients →

Tool-surface budgets

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

Tools are not endpoints →

Production rails

Auth (JWT, OAuth 2.1), authorization voters, health probes,<br>Prometheus metrics, OpenTelemetry, rate limiting, validated config<br>— 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<br>context, schemas live once on the decorator, and servers are<br>components.

Concepts

Dependency injection<br>Schema-first decorators<br>Components, servers & lifecycle

Guides

Build a REST API<br>Build an MCP server<br>Build a hybrid app<br>Composition & extensibility<br>Testing<br>Secure MCP over HTTP<br>Deploy to production

Architecture & design

Architecture overview<br>Metering & payments<br>Boundary coherence (design thesis)<br>Database story<br>System boundary map

From the blog

Design notes from the framework boundary

All posts →

June 10, 2026<br>Introducing AgentBack

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

Read post

June 10, 2026<br>Boundary coherence is the product

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

Read post

June 11, 2026<br>Charge agents per call

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

Read post

June 11, 2026<br>Your API's first...

from agents contract tool agentback agent

Related Articles