> ## Documentation Index
> Fetch the complete documentation index at: https://shunya.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AI-agent integration

> Connect Charter to coding agents through its per-session MCP server.

Charter exposes a small Model Context Protocol (MCP) server over standard input and output. It is intentionally per-session: the agent client starts `charter mcp`, uses it for that session, and owns its lifecycle. Charter does not run a daemon or listen on a network port.

## Install a first-class integration

```sh theme={null}
charter install claude
charter install codex
```

### Claude Code

`charter install claude` adds a `charter` server to the repository `.mcp.json` and inserts a managed Charter instruction block into `CLAUDE.md`.

### Codex

`charter install codex` runs `codex mcp add charter -- charter mcp --principal codex` when the Codex CLI is available, then inserts the managed block into `AGENTS.md`. If `codex` is not on `PATH`, Charter still updates `AGENTS.md` and prints the configuration to add manually.

### Preview instead of writing

```sh theme={null}
charter install claude --print
charter install codex --print
```

For another agent client, `charter install <tool-name>` prints a generic MCP registration and the instruction block rather than modifying a tool-specific config file.

## Agent operating procedure

Give agents this sequence for non-trivial changes:

1. Call `decision_check` with the paths it intends to change, and include a unified diff when available.
2. Read and follow each returned accepted Decision; cite the IDs in its work summary.
3. Use `decision_search` when unsure whether the team already made a relevant choice.
4. Use `decision_propose` to draft a new Decision when the work requires a new architectural choice.
5. Leave acceptance, rejection, and supersession to the human review workflow.

```mermaid theme={null}
sequenceDiagram
    participant Agent as Coding agent
    participant MCP as Charter MCP
    participant Store as Decision files
    participant Human as Human reviewer

    Agent->>MCP: decision_check(paths, diff)
    MCP->>Store: Read accepted Decisions
    Store-->>MCP: Matching constraints
    MCP-->>Agent: Decision IDs and summaries
    alt Existing Decision applies
        Agent->>Agent: Follow and cite it
    else New architectural choice
        Agent->>MCP: decision_search(query)
        Agent->>MCP: decision_propose(...)
        MCP->>Store: Write proposed Decision
        Human->>Store: Review and accept/reject via CLI
    end
```

The installed managed block states this policy and points agents at `.charter/DECISIONS.md` for an immediately readable index.

## Run the server manually

```sh theme={null}
charter mcp --principal "my-agent"
```

The server writes JSON-RPC responses to stdout. Do not write banners, logs, or other text to stdout when embedding it; its diagnostic log is on stderr. `--principal` becomes `proposed_by` for Decisions created through `decision_propose`; without it, the principal is `agent`.

## What agents can and cannot do through MCP

| Tool | Purpose |
| - | - |
| `decision_check` | Return accepted Decisions that match paths and/or a unified diff. |
| `decision_search` | Rank non-rejected Decisions by title and body relevance. |
| `decision_propose` | Write a new `proposed` Decision and regenerate the index. |
| `decision_list` | List Decisions, optionally by status. |

The MCP server intentionally does not expose accept, reject, supersede, affirm, or audit-log tools. See the exact request contracts in the [MCP reference](https://shunya.mintlify.site/docs/reference/mcp.md).

## A note on trust

MCP tool exposure is a workflow boundary, not operating-system authorization. Use normal repository permissions, protected branches, and human pull-request review to control who can merge accepted Decisions.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.