# Why Charter

The API runtime built for Model Context Protocol (MCP). Operators shape the API, and end-user agents call the resources you define.

## The problem

Most API tools make you write the same thing several times. A new resource means a database model, validation, a route for each operation, a response shape, and permission rules, usually copied from the last resource and edited by hand. When a field changes, every copy has to change with it.

Agents now call APIs too. An agent can use the API when the API lists its resources, fields, and permissions.

## MCP to build, MCP to serve

Charter exposes two Model Context Protocol (MCP) servers.

Admin MCP (`charter mcp` and `/mcp`) is for operators. You may create resources, fields, permissions, and webhooks with it, and list users.

Resource MCP (`charter mcp api` and `/v1/mcp`) is the automatic server for those resources. An end-user agent reads and writes records as that user, under the same roles as the Representational State Transfer (REST) API.

## Apply a config file

You may describe resources, fields, validation, and permissions in one `charter.toml`. Put that file in version control if you want, or skip the file and change the API from the CLI or MCP. `charter export` writes the live definition. `charter import config` reads it, and an import without `--apply` lists what would change. When you have a file, apply it to the runtime, and the API updates.

## Stop hand-writing your API.

Agents spend fewer tokens and get the same endpoints every time.

The same definition fills in the reference docs and an OpenAPI spec. The human reference is `/docs`. The spec is one OpenAPI 3.1 document at `/openapi.json` and `/openapi.yaml`. `/llms.txt` and `/llms-full.txt` are that same reference for agents. They update when resources or fields change.

```cards
JSON:API|Every resource returns records, relationships, and errors in the same shape.
Docs and OpenAPI|Reference docs at /docs, one OpenAPI 3.1 document at /openapi.json and /openapi.yaml, and /llms.txt for agents.
```

## Roles and permissions

A permission gives one role one action on one resource. It lists the fields that role may read or write, and it can limit rows to the caller. REST and MCP both check that permission on every request.

## The same records

MCP, REST, and the command-line interface (CLI) act on the same resources. A record an agent creates over Resource MCP shows up in the next API response and in the CLI.

A config file is optional. When you use one, applying it is how you change the API.

The same `charter` binary runs local development and production. Deploy that runtime, then apply the config. Production runs `charter serve`. The schema is not baked into the image.
