Agent CLI and MCP Integration
coco exposes its Git-aware AI generation as a versioned, structured interface for coding agents, IDEs, automation, and Model Context Protocol clients. The integration's generation operations:
| Operation | Agent CLI value | MCP tool | Result |
|---|---|---|---|
| Commit draft | commit-draft | coco_commit_draft | Title, body, formatted message, and safe built-in Conventional Commits validation when requested |
| Code review | review | coco_review | Structured findings sorted by severity |
| Changelog | changelog | coco_changelog | Changelog title and content |
| Work recap | recap | coco_recap | Recap title and summary |
| Pull request draft | pr-draft | coco_split_plan | Plan how to split the staged changes into focused commits, as coco commit --split would. Planning only: never stages or commits. |
coco_batch | Run several of commit-draft, review, changelog and recap over one resolution of source, returning one envelope per operation with a shared meta.digest. | ||
coco_pr_draft | Base, head, title, body, and draft flag for the current branch |
Both transports call the same typed operation layer and return the same protocol-v1 success or failure envelopes. They generate drafts and analysis only. They do not create commits, write repository files, post comments, or mutate a forge.
When to use each transport
Use the agent CLI when the caller can run a one-shot process, needs a stable JSON/stdin contract, or does not support MCP. Use the local stdio MCP server when the client supports tool discovery, JSON Schema, cancellation, and filesystem roots.
Do not wrap the interactive coco commands and scrape their terminal output. The agent interfaces are designed for machine callers and keep stdout protocol-safe.
Requirements and installation
- Node.js
22.22.2or newer in a supported release line - Git
- A configured
cocoAI provider and credentials - An MCP-capable client only when using the MCP transport
Install globally:
npm install -g git-coco@latest
coco initOr run the one-shot agent CLI without a global install:
npx git-coco@latest agent schema --task reviewVerify the installed commands:
coco agent --help
coco mcp --help
coco agent schema --task commit-draftThe normal provider configuration applies. See Config Overview, Using Ollama, and Dynamic Model Routing.
Agent CLI
The command shape is:
coco agent <commit-draft|review|changelog|recap> --input <file|-> [--repo <dir>]--input <file>reads one JSON request from a file.--input -reads one JSON request from stdin.- When stdin is a TTY and
--inputis omitted, the request defaults to{}. --reposelects the repository from the command line and takes precedence overrepoin the request.- stdout contains only the JSON result. Diagnostics do not get mixed into the response.
- A failed operation emits a versioned failure envelope and exits non-zero.
SIGINTcancels repository and model work, emits aCANCELLEDfailure, and exits with status 130.
File request
1{
2 "version": 1,
3 "repo": "/absolute/path/to/repository",
4 "source": {
5 "kind": "repository",
6 "scope": { "type": "staged" }
7 },
8 "options": {
9 "conventional": true,
10 "includeBranchName": true,
11 "previousCommitCount": 3
12 }
13}coco agent commit-draft --input request.jsonstdin request
1printf '%s\n' '{
2 "version": 1,
3 "source": {
4 "kind": "summary",
5 "summary": "Added root-constrained MCP tools and structured agent responses.",
6 "files": [
7 { "path": "src/mcp/server.ts", "status": "added" },
8 { "path": "src/operations/agent/schemas.ts", "status": "added" }
9 ],
10 "provenance": { "generatedBy": "calling-agent" }
11 }
12}' | coco agent changelog --input - --repo /absolute/path/to/repositoryPublish the schemas
Each operation has a strict input schema and an operation-specific output schema:
1coco agent schema --task commit-draft
2coco agent schema --task review
3coco agent schema --task changelog
4coco agent schema --task recapThe schema command does not call a model or require repository changes. It prints:
1{
2 "version": 1,
3 "operation": "review",
4 "input": { "type": "object" },
5 "output": { "oneOf": [] }
6}The abbreviated objects above represent full JSON Schemas in real output.
MCP server
Start the local stdio server:
coco mcpThe server writes MCP messages to stdout and startup information to stderr. It has two binding modes:
| Mode | Start with | Repository |
|---|---|---|
| Unbound (recommended for editors) | coco mcp | Resolved on each tool call, in this order: the repo field of the tool input, then the first Git repository found among the roots the MCP client declares. If neither yields one, the call fails with INVALID_REPOSITORY. |
| Bound | coco mcp --repo /absolute/path | The normalized Git top-level directory of that path, for the lifetime of the process. A request that names a different repository fails with REPOSITORY_MISMATCH. |
One unbound entry works in every workspace, so the client configuration needs no path. Editors start MCP servers with their working directory at the filesystem root (/), so a bound server started with --repo . resolves to /, which is not a repository, and exits with INVALID_REPOSITORY before it answers initialize. Use unbound mode, or an absolute path.
Generic MCP client configuration
Add a local stdio server entry to your client's MCP configuration. This is the recommended setup:
1{
2 "mcpServers": {
3 "coco": {
4 "command": "coco",
5 "args": ["mcp"]
6 }
7 }
8}Each tool call then works against the workspace the client has open, provided the client declares workspace roots (most editors do). Without declared roots, pass repo in the tool input.
If coco is not on the MCP client's PATH, use the absolute path to the binary. Find it with:
command -v cocoTo pin the server to one repository on purpose, for scripted or CI use or to rule out any other repository, pass --repo:
1{
2 "mcpServers": {
3 "coco-api": {
4 "command": "/absolute/path/to/coco",
5 "args": ["mcp", "--repo", "/work/api"]
6 },
7 "coco-web": {
8 "command": "/absolute/path/to/coco",
9 "args": ["mcp", "--repo", "/work/web"]
10 }
11 }
12}A bound process serves one repository, so configure one entry per repository. --repo is not needed for ordinary editor use.
Restart or reconnect the server from the MCP client after changing its configuration.
Where each client keeps its MCP configuration
| Client | File |
|---|---|
| Kiro | ~/.kiro/settings/mcp.json (all workspaces) or .kiro/settings/mcp.json (one workspace) |
| VS Code | .vscode/mcp.json in the workspace. It names the top-level key servers rather than mcpServers, and each entry takes "type": "stdio" |
| Cursor | .cursor/mcp.json in the project, or ~/.cursor/mcp.json for all projects |
| Claude Desktop | ~/Library/Application Support/Claude/claude_desktop_config.json on macOS, %APPDATA%\Claude\claude_desktop_config.json on Windows |
Paths and key names are the clients' own and can change between their releases; check the client's MCP documentation if a file is not picked up.
Available tools
| Tool | Description |
|---|---|
coco_commit_draft | Generate a commit-message draft. With conventional: true, validate it against coco's built-in Conventional Commits rules without loading repository configuration. Never creates a commit. |
coco_review | Return structured code-review findings. Never posts comments. |
coco_changelog | Generate changelog content. Never writes CHANGELOG.md. |
coco_recap | Summarize the supplied or repository-derived changes. |
coco_pr_draft | Draft a pull/merge request title and body for the current branch against its base, as coco pr create --json would. Never opens a request or calls a forge. |
coco_condense_diff | Reduce a diff to a semantically condensed representation within a token budget. Uses tree-sitter/regex structural extractors in structural mode (the default), requiring no LLM call and no API key. Per-file metrics report which strategy was applied. Files omitted to meet the budget are reported in metrics.filesOmitted. |
coco_commit_validate | Check a commit message you wrote against coco's built-in Conventional Commits rules. Returns valid, and errors/warnings that each name the commitlint rule (for example header-max-length). No model call, no API key, no network. |
coco_commitlint_rules | List the rules coco_commit_validate checks, one readable line each, so a message can conform on the first attempt. No model call, no API key, no network. |
All tools publish strict input and output schemas. The output schema exposes explicit success and failure alternatives. Successful calls return both MCP text content and structuredContent; failed calls set isError and return the same structured failure envelope used by the agent CLI.
The tools advertise readOnlyHint: true and destructiveHint: false. Generation is intentionally not marked idempotent because model output can vary between calls. coco_condense_diff is additionally marked idempotentHint: true because structural mode is deterministic.
MCP resources
The server exposes four read-only repository resources that editors can browse without spending a tool call:
| Resource URI | Description |
|---|---|
coco://repo/status | Working tree status (git status --porcelain=v1 -b) |
coco://repo/diff/staged | Diff of currently staged changes (git diff --cached) |
coco://repo/branch-context | Current branch name, upstream, ahead/behind counts |
coco://repo/log/recent | Recent commit history (git log --oneline, bounded to 20 entries) |
Each resource response includes a _meta.digest field (SHA-256) for cache invalidation.
MCP prompt templates
Five built-in prompt templates are published so any MCP client can inspect or reuse coco's generation prompts:
| Prompt | Description |
|---|---|
coco_commit_prompt | Standard commit-message generation template |
coco_conventional_commit_prompt | Conventional Commits generation template |
coco_review_prompt | Code review template |
coco_changelog_prompt | Changelog generation template |
coco_recap_prompt | Recap generation template |
Each accepts optional string arguments matching the template's input variables (defaults to empty when omitted).
Progress notifications
Long-running tool calls emit notifications/progress messages so editors can display a spinner or progress indicator. The progress token is passed by the client via _meta.progressToken in the tool-call request. Progress messages include a counter and an optional message field describing the current stage.
Convention-file injection (trustRepositoryConfig)
When trustRepositoryConfig is enabled on the agent CLI (not available via MCP tools, which always reject it), coco reads AGENTS.md, CLAUDE.md, CONTRIBUTING.md, and all .kiro/steering/*.md files from the repository root. These are injected as trusted system-prompt context into generation calls, bounded to a fixed byte budget with SHA-256 provenance tracking. This lets project-level conventions flow into generated commit messages, reviews, and changelogs without duplicating them in every request.
MCP tools always reject trustRepositoryConfig: true with an UNSAFE_OPTION error. Only the one-shot coco agent CLI supports it, for repositories the caller has explicitly vetted.
MCP roots
If a client advertises the MCP roots capability, the repository a call resolves to must be inside one of the file roots returned by that client, in both modes. Otherwise the tool returns REPOSITORY_OUTSIDE_ROOT. The roots are fetched once per tool call and never reused across calls, so a client that changes its roots is honored on the next call.
A request may omit repo, which is recommended for MCP.
- Bound server: a
repothat is given must normalize to the bound repository. A tool call cannot switch a bound server to another repository. - Unbound server:
reposelects the repository for that call. Without it, the first Git repository among the client's roots is used.
An unbound server whose client does not advertise roots has nothing to confine repo to, so it will read any Git repository on the machine that the process can access. Use a bound server (--repo) when the client does not declare roots and you want a fixed boundary.
Protocol-v1 request
Every operation accepts the same top-level request:
1{
2 version?: 1
3 repo?: string
4 source?: ChangeSource
5 options?: AgentOptions
6}Unknown fields are rejected at every level. Defaults are applied when fields are omitted:
1{
2 "version": 1,
3 "source": {
4 "kind": "repository",
5 "scope": { "type": "staged" }
6 },
7 "options": {
8 "conventional": false,
9 "includeBranchName": false,
10 "previousCommitCount": 0,
11 "author": false,
12 "trustRepositoryConfig": false
13 }
14}Even supplied patch/summary calls run in a Git repository because the repository provides the coco configuration and model context. Supplied sources do not inspect repository changes, and they do not read HEAD unless the request includes a head revision for provenance verification.
Change sources
Shorthand strings
The generation operations accept a string in place of a source object for the common repository sources:
source | Expands to |
|---|---|
"staged" | { "kind": "repository", "scope": { "type": "staged" } } |
"worktree" | { "kind": "repository", "scope": { "type": "worktree" } } |
"since-last-tag" | range from the most recent tag reachable from HEAD (git describe --tags --abbrev=0) to HEAD. Fails with INVALID_REVISION when there is no tag. |
"branch" | branch against the default branch: origin/HEAD's target, else main. |
"branch:<ref>" | branch against <ref>. |
"HEAD~N" | branch against HEAD~N. |
The expansion happens after the repository is resolved, so root confinement applies as usual. Any other string fails with INVALID_INPUT, and the error lists the valid shorthands. The object forms below remain available for everything else.
Staged repository changes
This is the default and safest repository-derived source:
1{
2 "source": {
3 "kind": "repository",
4 "scope": { "type": "staged" }
5 }
6}It reads git diff --cached with external diff drivers and text conversion disabled.
Worktree changes
1{
2 "source": {
3 "kind": "repository",
4 "scope": { "type": "worktree" }
5 },
6 "options": {
7 "trustRepositoryConfig": true
8 }
9}Worktree inspection can invoke repository-defined clean filters. It is therefore rejected by default with UNSAFE_SOURCE.
- The one-shot agent CLI can opt in with
trustRepositoryConfig: truefor a repository the caller explicitly trusts. - MCP always rejects
trustRepositoryConfigwithUNSAFE_OPTION. Supply a patch, file summaries, or a consolidated summary instead.
A trusted worktree source combines staged, unstaged, and untracked-file information.
Branch comparison
1{
2 "source": {
3 "kind": "repository",
4 "scope": {
5 "type": "branch",
6 "base": "origin/main",
7 "head": "HEAD"
8 }
9 }
10}head defaults to HEAD. Both references must resolve to commits.
A branch scope covers what head adds since it forked from base (git diff base...head, from their merge base), so commits that landed on base after the fork are not counted as branch changes. Use a range scope for a straight two-point diff.
Explicit range
1{
2 "source": {
3 "kind": "repository",
4 "scope": {
5 "type": "range",
6 "from": "v0.82.0",
7 "to": "HEAD"
8 }
9 }
10}Revisions cannot begin with - or contain NUL bytes. coco verifies them with an end-of-options boundary before using them in a diff.
Supplied patch
Use this when the calling agent already has the exact patch:
1{
2 "source": {
3 "kind": "patch",
4 "patch": "diff --git a/src/a.ts b/src/a.ts\n...",
5 "baseRevision": "origin/main",
6 "headRevision": "0123456789abcdef"
7 }
8}baseRevision and headRevision are provenance fields. When headRevision exactly matches the repository's current HEAD, the response metadata reports head-matched; otherwise supplied data remains provided-unverified.
Supplied files
1{
2 "source": {
3 "kind": "files",
4 "files": [
5 {
6 "path": "src/new.ts",
7 "status": "added",
8 "summary": "Adds a typed agent operation dispatcher."
9 },
10 {
11 "path": "src/old.ts",
12 "oldPath": "src/legacy.ts",
13 "status": "renamed",
14 "patch": "diff --git ..."
15 }
16 ],
17 "provenance": {
18 "headRevision": "0123456789abcdef",
19 "generatedBy": "calling-agent"
20 }
21 }
22}Each file requires path, status, and either patch or summary.
Allowed status values are:
modifiedrenamedaddeddeleteduntrackedunknown
A request can include at most 500 file entries.
Supplied summary
This is the most token-efficient choice when the caller has already inspected the change:
1{
2 "source": {
3 "kind": "summary",
4 "summary": "Adds four read-only generation tools over a shared typed operation layer.",
5 "files": [
6 { "path": "src/mcp/server.ts", "status": "added" }
7 ],
8 "provenance": {
9 "generatedBy": "calling-agent"
10 }
11 }
12}A summary can list up to 500 affected paths. Those file entries do not contain patch content.
Context limits and digest
Supplied patch/summary fields are limited to 2 MiB, and the fully formatted aggregate context is checked again against the same 2 MiB limit. If the aggregate is too large, consolidate it before calling coco.
Every successful response includes a SHA-256 digest of the exact resolved change context:
1{
2 "meta": {
3 "kind": "summary",
4 "digest": "sha256:...",
5 "verification": "provided-unverified"
6 }
7}Options
| Option | Type/default | Used by | Behavior |
|---|---|---|---|
language | string, optional | all operations | Writes the generated result in the requested language. |
additionalContext | string, max 32 KiB | commit draft, changelog | Adds caller-provided guidance to the generation prompt. |
conventional | boolean, false | commit draft | Requests Conventional Commits formatting and validates the result against coco's built-in rules without loading repository config. |
includeBranchName | boolean, false | commit draft | Includes the current branch name in generation context. |
previousCommitCount | integer 0-20, 0 | commit draft | Includes this many previous commits for style/context. |
author | boolean, false | changelog | Includes author attribution only when present in supplied context. |
timeframe | string, optional | recap | Labels the period represented by the supplied changes. |
severity | integer 1-10, optional | review | Returns only findings with severity at or above the threshold, the same scale as coco review --severity. A filter, not a gate: the call still succeeds and a warning says how many findings were left out. Filtering happens after generation, so it does not reduce token cost. |
base | revision, optional | pr draft | Base branch the request would target. Defaults to origin/HEAD's branch, else the configured defaultBranch, else main. |
draft | boolean, optional | pr draft | Echoed back as draft for the caller's later use. coco never opens the request. |
trustRepositoryConfig | boolean, false | agent CLI only | Enables repository-defined prompt/commitlint config and permits worktree inspection. MCP always rejects it. |
Repository-defined custom prompts and executable commitlint configuration are disabled unless the one-shot agent CLI explicitly opts into trustRepositoryConfig.
Responses
Success envelope
1{
2 "version": 1,
3 "ok": true,
4 "operation": "commit-draft",
5 "status": "completed",
6 "data": {
7 "title": "feat(agent): expose structured generation tools",
8 "body": "Add JSON and MCP transports over a shared typed operation layer.",
9 "formatted": "feat(agent): expose structured generation tools\n\nAdd JSON and MCP transports over a shared typed operation layer.",
10 "validationErrors": []
11 },
12 "warnings": [],
13 "meta": {
14 "kind": "repository",
15 "digest": "sha256:...",
16 "repositoryHead": "0123456789abcdef",
17 "verification": "repository-derived"
18 }
19}Operation data shapes:
commit-draft:title,body,formatted,validationErrors[]review:findings[], where each item hastitle,summary,severity(1-10),category, andfilePathchangelog:title,contentrecap:title,summarypr-draft:base,head,title,body,draft. Generated through the same changelog chain ascoco pr create, over the branch against its base. A detached HEAD fails withINVALID_REVISION, and being on the base branch fails withINVALID_INPUT. A supplied patch, files, or summary source is used as given, with base and head still read from the repository.
Failure envelope
1{
2 "version": 1,
3 "ok": false,
4 "operation": "review",
5 "error": {
6 "code": "NO_CHANGES",
7 "category": "repository",
8 "message": "No changes were found for the requested source.",
9 "retryable": false
10 }
11}Callers should branch on ok, error.code, error.category and error.retryable, not parse human-readable messages.
categorygroups codes so a client can handle a class it does not recognize in detail.retryableis true only when sending the same request again later may succeed: a rate limit or a transient provider or network failure.retryAfterMs(optional) is how long the provider asked to wait, from itsRetry-Afterorretry-after-msheader. Values over one day are capped at one day.details(optional) carries structured detail, such as the validation issues forINVALID_INPUT.
Unknown codes. coco may add error codes within protocol version 1. Treat a code you do not recognize as OPERATION_FAILED, and use category and retryable to decide what to do. The full list is published in the failure schema (coco agent schema and MCP tools/list).
Versioning. Within version 1, coco may add optional fields to requests and outputs and new enum values such as error codes. Changes that would break an existing client bump the version. If you validate responses strictly against a downloaded schema, regenerate it with coco agent schema when you upgrade coco.
Error codes
| Code | Category | Retryable | Meaning |
|---|---|---|---|
INVALID_INPUT | input | no | The request does not match the schema. details lists the validation issues. |
INVALID_JSON | input | no | The agent CLI could not parse the request as JSON. |
INVALID_OPERATION | input | no | The operation was sent to the wrong entry point. |
INVALID_REVISION | input | no | A ref or revision in the source could not be resolved. |
UNSUPPORTED_OPERATION | input | no | The option or operation combination is not supported (for example dryRun on commit-draft). |
UNSUPPORTED_SOURCE | input | no | The source kind is not accepted by this operation. |
UNSUPPORTED_MODE | input | no | The requested mode is not supported by this operation. |
CONTEXT_TOO_LARGE | input | no | The resolved context exceeds the size limit. |
EXPLAIN_RANGE_TOO_LARGE | input | no | A blame explain range covers too many lines or commits. |
INVALID_REPOSITORY | repository | no | No usable git repository at the requested path. |
REPOSITORY_MISMATCH | repository | no | A bound MCP server was asked about a different repository. |
NO_CHANGES | repository | no | The source has no changes, or supplied context is blank. |
EMPTY_INDEX | repository | no | Commit apply found nothing staged. |
BLAME_FAILED | repository | no | git blame failed for the requested file or range. |
HOOK_FAILED | repository | no | A git hook rejected the commit. |
REPOSITORY_OUTSIDE_ROOT | safety | no | The repository is outside the roots the MCP client exposed. |
UNSAFE_SOURCE | safety | no | The source was refused by a safety rule. |
AUTHENTICATION_REQUIRED | authentication | no | No provider credentials, or the provider rejected them. |
GENERATION_FAILED | generation | sometimes | The model's output was unusable. retryable is true when commit-message validation failed, since a new generation may pass. |
RATE_LIMITED | provider | yes | The provider rate-limited the call. Wait retryAfterMs when present. |
PROVIDER_UNAVAILABLE | provider | yes | A network failure (such as a timeout or dropped connection) or a 408, 500, 502, 503 or 504 from the provider. |
QUOTA_EXCEEDED | provider | no | Quota or billing exhaustion. Waiting does not help; add credits or raise the cap. |
CANCELLED | cancelled | no | The client cancelled the request. |
OPERATION_FAILED | internal | no | Anything not classified more precisely. |
Planning a commit split
split-plan (coco_split_plan) returns the decomposition coco commit --split would apply, without staging or committing anything:
1{
2 "data": {
3 "groups": [
4 { "title": "feat(agent): add batch", "body": "", "files": ["src/batch.ts"], "hunks": [], "unclaimed": false },
5 { "title": "test(agent): cover batch", "body": "", "files": [], "hunks": ["src/x.test.ts::hunk-2"], "unclaimed": false }
6 ]
7 }
8}- Only the staged source is accepted, since the plan is validated against the real index state.
dryRunis not supported. filesare committed whole;hunks(<path>::hunk-<n>) split a file across groups. A group withunclaimed: trueholds changes the planner could not place, whichcoco commit --splitleaves uncommitted.- Group titles are validated against coco's built-in Conventional Commits rules when
conventional: true. Unlikecoco commit --split, repository commitlint config and custom prompts are never loaded, and the staged state is read through the hardened agent git runner. fallbackis set (and a warning added) when the planner gave up and returned one combined group.
Batching operations on one diff
batch (coco_batch) runs several generation operations over a single resolution of the source, so the diff is read, digested and budgeted once:
printf '{"source":"staged","operations":["review","commit-draft"],"options":{"conventional":true}}' | coco agent batch --input -operations: 1 to 4 ofcommit-draft,review,changelog,recap, each at most once. They run in that order.data.resultsholds one envelope per operation, all carrying the samemeta.digest. The batch envelope carries it too.- If one operation fails, its failure envelope takes its place in
resultsand the others still run. Cancellation stops the whole batch. optionsapply to every operation, as they would to each call on its own.
Commit message validation
commit-validate (coco_commit_validate) and commitlint-rules (coco_commitlint_rules) need no model, API key, or network, so an agent can call them on every commit: draft a message, validate it, repair it, then commit.
printf '{"message":"feat(agent): add thing"}' | coco agent commit-validate --input -1{
2 "data": {
3 "valid": true,
4 "errors": [],
5 "warnings": [],
6 "rulesSource": "built-in-conventional",
7 "repositoryConfig": "absent"
8 }
9}rulesSourceis alwaysbuilt-in-conventional. Repository commitlint configuration (commitlint.config.jsand friends) is executable, so these tools never load it.repositoryConfigisdetectedwhen the repository defines its own config (checked by file presence only, never executed),absentwhen it does not, andunknownwhen no repository was resolved. Withdetected, a pass is advisory: the repository's own rules may be stricter, and the response carries a warning saying so.- A repository is optional. When one is given it is still confined to the MCP client's roots.
Safety model
The machine interfaces use stricter defaults than an interactive developer session:
- The MCP server is local stdio, not a remote network service.
- A bound MCP process (
--repo) serves one real, normalized Git repository root and rejects any other. An unbound process resolves a repository per tool call from the request or the client's roots. - Client filesystem roots are enforced, in both modes, when the client advertises them. An unbound server without declared roots can read any repository its process can access; pin one with
--repoif that matters. - A bound server rejects repository switching per tool call.
- Git commands disable optional locks and filesystem monitors.
- Diff collection disables external diff drivers and text conversion.
- Revisions are validated and passed after an end-of-options boundary.
- Worktree reads are rejected unless the one-shot agent CLI explicitly trusts repository configuration.
- MCP never enables repository-defined prompts or executable commitlint configuration.
- Supplied patches, summaries, and file data are framed as untrusted data in model prompts. Instructions inside repository content must not alter the operation or output format.
- Model cancellation propagates through MCP request signals and through
SIGINTin the agent CLI. - The four operations generate data only. They do not create commits, write files, post review comments, open pull requests, or call forge mutation APIs.
One opt-in exception: starting the server with coco mcp --allow-write also registers coco_commit_apply, which creates a Git commit from whatever is currently staged. It never runs git add, never pushes, and refuses with EMPTY_INDEX when nothing is staged. Without the flag the tool is not registered at all.
readOnlyHint refers to repository and forge behavior. If local usage analytics are enabled, coco can append a metadata-only record to its user cache as described below.
Local usage analytics and privacy
Agent and MCP calls participate in the same local usage ledger as normal coco commands when usage recording is already enabled.
Machine transports never show a consent prompt and never write a configuration preference. They only honor:
COCO_USAGE_LOG, when set; otherwise- the existing
telemetry.usagepreference.
The environment variable wins in both directions:
1# Force local recording on at the default user-cache path
2COCO_USAGE_LOG=1 coco mcp --repo /work/api
3
4# Force it off
5COCO_USAGE_LOG=0 coco agent review --input request.json
6
7# Use an explicit local ledger path
8COCO_USAGE_LOG=/tmp/coco-usage.jsonl coco agent recap --input request.jsonEach JSONL row contains metadata only:
- timestamp
- command/task label
- surface:
cli,agent-cli, ormcp - provider and model identifiers
- estimated prompt tokens and provider-reported completion tokens, when available
- elapsed milliseconds
- a readable repository tag, when available
The ledger does not store prompts, patches, diffs, source code, generated responses, filenames, request options, or API keys. It is bounded, remains on the local machine, and is never written into the repository.
Review it with:
coco doctor --cost
coco doctor --cost --jsonThe report aggregates by task, model, surface, and repository. Delete it with:
coco doctor --clearSee Config Overview: local usage stats for the general preference behavior.
Troubleshooting
INVALID_JSON
The agent CLI could not parse the input file or stdin. Validate it before calling coco:
jq . request.jsonINVALID_INPUT
The request does not match protocol version 1. Common causes are unknown fields, an unsupported operation option, an invalid status value, or a context field over its limit.
Print the current schema and validate against it:
coco agent schema --task review > review-schema.jsonThe server connects, then nothing happens
An MCP server that seems to connect and then never answers has usually died before the handshake, and the client shows no error. Two causes cover most cases.
Node is too old. The MCP SDK uses modern syntax, so on Node older than 22 the process exits with SyntaxError: Unexpected token '??=' before any MCP message. coco requires ^22.22.2 || ^24.15.0 || >=26.0.0. Check the Node that will run coco:
node --versionThe editor sees a different Node, or no coco, than your terminal. nvm changes PATH only in interactive shells, through your shell profile. Editors and other GUI applications do not read that profile, so one that launches coco may find an older Node (for example /usr/local/bin/node) or not find coco at all, even though both work in your terminal. This affects every nvm user on macOS and is not specific to coco. Two fixes:
- Use an absolute
command, and point it at acocowhose Node is current (command -v cocoin a terminal that has the right Node active). - Or set
PATHin the entry'senvso it starts with the directory of the Node you want:
1{
2 "mcpServers": {
3 "coco": {
4 "command": "coco",
5 "args": ["mcp"],
6 "env": { "PATH": "/Users/you/.nvm/versions/node/v24.15.0/bin:/usr/local/bin:/usr/bin:/bin" }
7 }
8 }
9}Run the same command by hand with the same environment to see the real error on stderr: coco mcp should sit waiting for input without printing a stack trace.
INVALID_REPOSITORY
No Git repository could be resolved. On an unbound server (coco mcp) that means the tool input had no repo and none of the client's declared roots contains a Git repository: pass repo, open a workspace that is a repository, or start the server with --repo <path>. On a bound server it means --repo is not a Git repository. Use an existing directory and an absolute path for MCP configuration.
git -C /absolute/path/to/repository rev-parse --show-toplevelREPOSITORY_OUTSIDE_ROOT
The requested repository is outside the MCP client's advertised filesystem roots. Add the repository to the client's workspace/root configuration, reconnect the server, or start a server for an allowed repository.
REPOSITORY_MISMATCH
A bound server (coco mcp --repo ...) was asked for a different repository from the one it is bound to. Omit repo from the tool input, start a second server process for that repository, or run an unbound server (coco mcp), which resolves a repository per call.
INVALID_REVISION
A branch/range reference is unsafe or does not resolve to a commit. Verify it without treating it as an option:
git rev-parse --verify --end-of-options 'origin/main^{commit}'UNSAFE_SOURCE
An untrusted call requested worktree inspection. Prefer staged changes or supply a patch/summary. For a repository you explicitly trust, only the one-shot agent CLI can set:
{
"options": { "trustRepositoryConfig": true }
}trustRepositoryConfig over MCP
An MCP call that sets trustRepositoryConfig fails with INVALID_INPUT: the option is not part of the MCP input schema. Remove it and use a staged, branch, range, patch, files, or summary source. (Older releases documented an UNSAFE_OPTION code for this; it is no longer emitted.)
NO_CHANGES
The selected Git source has no changes, or supplied context is blank. Verify the staged diff:
git diff --cached --CONTEXT_TOO_LARGE
The resolved context exceeds 2 MiB. Have the calling agent consolidate the change into a summary and affected-file list, then send a summary source.
AUTHENTICATION_REQUIRED
The selected provider requires credentials. Run coco init, set the provider-specific environment variable, and verify with coco doctor.
RATE_LIMITED
The provider rate-limited the call. It is retryable: wait retryAfterMs when the envelope includes it, otherwise back off. If it keeps happening, lower service.maxConcurrent.
PROVIDER_UNAVAILABLE
The provider could not be reached, timed out, dropped the connection, or returned 408, 500, 502, 503 or 504. It is retryable with backoff. For Ollama, check that the daemon is running (coco doctor).
QUOTA_EXCEEDED
The provider reports quota or billing exhaustion (often sent as a 429). It is not retryable: add credits or raise the spending cap.
CANCELLED
The MCP client cancelled the request or the agent CLI received SIGINT. This is not retryable automatically; retry only when the user or calling agent intends to restart the operation.
GENERATION_FAILED or OPERATION_FAILED
The model call, parser, or commit-message validation failed. Check provider connectivity and configuration:
coco doctor
coco doctor --costIf the client shows no tools, run the server command directly and inspect stderr, verify the absolute coco path, then reconnect the MCP client:
/absolute/path/to/coco mcp --repo /absolute/path/to/repositoryFor more general provider, installation, and Git issues, see Troubleshooting.