---
title: "MCP server: let your agent query its own traces"
description: "Let your agent query its own sessions, failures, latency and usage over MCP; init registers the server for you."
canonical: https://coding.sh/docs/mcp
human_url: https://coding.sh/docs/mcp
markdown_url: https://coding.sh/docs/mcp.md
agents_url: https://coding.sh/agents.md
llms_url: https://coding.sh/llms.txt
updated: 2026-11-11
---

# MCP server

Let your agent query its own sessions, failures, latency and usage over MCP; init registers the server for you.

`coding.sh mcp` is a local MCP server over stdio. An agent can read the sessions captured on this machine, including its own, and answer "what failed last time?" or "what did this cost?" from real traces. Nothing leaves your machine.

## You don't set it up (built)

The install script runs `coding.sh init`, which adds capture hooks and the MCP server for every agent it finds. It registers the server at user scope with Claude Code, Codex, Cursor, OpenCode and older Gemini CLI installs, backing up each file first.

shell

```
coding.sh init          # hooks + MCP server for every detected agent
coding.sh init --no-mcp # hooks only
coding.sh mcp config    # print the server command for manual setup
```

The entry points at the installed CLI by absolute path, so agents started from a dock or an IDE find it. `coding.sh uninstall` removes it, and restores a config file nobody touched since init byte for byte.

Every call reads fresh data: the server ingests new hook events before it answers. There is no `coding.sh ingest` step.

## Tools

| Tool | What it returns |
| --- | --- |
| `improve` | What goes wrong most in this repo's sessions, ranked, each with the AGENTS.md line that fixes it. |
| `harness_changes` | Each committed AGENTS.md, rule or skill change: flagged sessions before and after, and a verdict. |
| `harness_audit` | Each memory file, AGENTS.md, rule and skill with its load tokens and the sessions that used it, unused first. With check: true, whether uncommitted edits deleted, reworded or relaxed a protected line. |
| `session_current` | The session of the agent calling the tool: its summary and latest timeline. |
| `sessions_list` | Captured sessions, newest first, with turns, tool errors, tokens, cost and flags. Filter with flag or where. |
| `session_get` | One session as a digest: per-turn index and a timeline of prompts, replies, tool calls and model calls. |
| `session_replay` | A session as numbered steps, with the files as of any step, and a step's or a range's diff. With fork, a step's model call sent again with changed files. |
| `search` | Full-text search over prompts, replies and tool input/output across all sessions. Takes where too. |
| `failures` | The raw data behind improve: flagged sessions, frequent tool errors, prompts where the user pushed back. |
| `latency` | Model-call p50/p95 and time to first token, plus the slowest tools and tool calls. |
| `usage` | Tokens and cost by day, agent, model or repo, with the most expensive sessions. Takes where too. |
| `subagents` | The subagents a session spawned, as a tree with durations and errors. |
| `session_tree` | A whole multi-agent run as one tree, with per-node cost, tokens and flags and rolled-up totals. |
| `eval_candidates` | Captured sessions ranked as eval candidates by failure flags, pushback, a guessable verifier and recency. |
| `experiments_list` | Dataset experiments with pass rate and confidence interval. |
| `experiment_compare` | Paired comparison of two experiments: difference, p-value, regressed and improved cases. |
| `exp_session_summary` | The experiment session's timeline: notes, commands and each run with its delta against the previous run. |
| `exp_session_note` | Add a note to the experiment session: a hypothesis before a run, the reading after it. |
| `harness_compare` | Harness A/B results from coding.sh compare: the list, or one report with its gates. |
| `benchmarks` | Benchmarks: the list, one run's leaderboard, or one metric over time. |
| `eval_from_session` | Draft an eval task from a session. |
| `eval_init` | Write an eval suite to evals/<name>/: tasks from failed sessions, a skill's trigger prompts, or cases the agent writes. What the agent writes is marked draft. |
| `score_list` | Typed scores on sessions, events, dataset cases and eval runs, newest first, with filters. |
| `score_add` | Score a session, event, case or run: a number, true or false, or a category. Scoring the same thing again replaces it. |
| `status` | Health of coding.sh: version, available update, recent captures, pending spool, last error. |

Only `eval_from_session`, `eval_init`, `score_add` and `exp_session_note` write. Agents ask you before `eval_from_session` and `eval_init`. Notes have secrets redacted.

## Prompts and resources

| Prompt | In Claude Code | What it does |
| --- | --- | --- |
| `improve` | `/mcp__coding-sh__improve` | Find the top issue and the line that fixes it. |
| `trim` | `/mcp__coding-sh__trim` | Find memory files, skills and instructions sessions never read, then check the edits. |
| `did-it-help` | `/mcp__coding-sh__did-it-help` | Whether a committed change helped, with an optional `commit`. |

See [Improve your agent every week](https://github.com/jackulau/coding.sh/blob/main/docs/guides/improve.md). Resources: `codingsh://latest` and `codingsh://session/<id>`, each a Markdown digest of one session.

## Manual config

For a machine where you'd rather not run `init`, or a project-scoped setup. These use the `coding.sh` binary on `PATH`; `coding.sh mcp config` prints the absolute-path form.

### Claude Code

shell

```
claude mcp add -s user coding-sh -- coding.sh mcp
```

json

```
// ~/.claude.json
{
  "mcpServers": {
    "coding-sh": { "type": "stdio", "command": "coding.sh", "args": ["mcp"], "env": {} }
  }
}
```

### Codex

toml

```
# ~/.codex/config.toml
[mcp_servers.coding-sh]
command = "coding.sh"
args = ["mcp"]
```

### Cursor

json

```
// ~/.cursor/mcp.json
{
  "mcpServers": {
    "coding-sh": { "command": "coding.sh", "args": ["mcp"] }
  }
}
```

### OpenCode

json

```
// ~/.config/opencode/opencode.json
{
  "mcp": {
    "coding-sh": { "type": "local", "command": ["coding.sh", "mcp"], "enabled": true }
  }
}
```

### Gemini CLI (older installs)

json

```
// ~/.gemini/settings.json
{
  "mcpServers": {
    "coding-sh": { "command": "coding.sh", "args": ["mcp"] }
  }
}
```

To set coding.sh up for a user, follow the agent workflow at [/agents.md](https://coding.sh/agents.md).
