# ctxcap

> ctxcap is a free MCP server for developer tools. Offline linter that trims CLAUDE.md and AGENTS.md files to a token budget. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Free
- **Platforms:** CLI
- **Website:** https://naeha-s.github.io/ctxcap/
- **Repository:** https://github.com/naeha-s/ctxcap
- **MCP Registry name:** io.github.Naeha-S/ctxcap
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools), [AI models and LLM tooling](https://ai-powered.com/categories/ai-and-llm)
- **Listing updated:** 2026-11-23

## About

Agent instruction files grow every sprint and are pasted into every request. ctxcap measures them, then gives the agent a ranked plan to get back under a budget instead of letting it rewrite files from memory, which the README says tends to drop the "Never" rules. It scans CLAUDE.md, AGENTS.md, copilot instructions, prompts and Cursor rules by default, and runs with no config, API key, network or telemetry.

The loop is plan, apply, verify. A plan lists spans by start and end line with safety flags and a preserve list; applying splices atomically; verification catches drift and violations, and plans expire after 24 hours. A stale pass finds paths, commands, globs and @references that no longer resolve and can emit SARIF or a deletion diff. A committed baseline lets a CI step report growth per pull request or fail on a budget.

Through the stdio MCP server an agent can check itself. The repository includes a measured case study that took a multi-file run from 1,504 tokens to 259 at a 400-token budget, with the preserved rule intact.

## Features

- **Token measurement:** Counts tokens in agent context files, grouped by always, startup, conditional and manual load classes.
- **Ranked trim plan:** Produces line-range edits with safety flags and spans that must be preserved.
- **Atomic apply and verify:** Splices a saved plan in one step and verifies it afterwards.
- **Stale reference pass:** Finds dead paths, commands, globs and @path references and reports reclaimable tokens.
- **CI gating:** Compares against a committed baseline and can fail on increase, budget or stale findings, with SARIF output.
- **Local only:** Needs Node 20 or later and sends nothing over the network.

## Good for

- Keep CLAUDE.md under a token budget over time
- Fail a pull request when prompt files grow
- Remove references to files that no longer exist
- Let an agent condense rules without losing the must-keep sections

## Install

### Claude Code: Add with the CLI (Terminal)

```sh
claude mcp add ctxcap -- npx -y ctxcap-mcp
```

Add --scope user to use it in every project, or --scope project to share it in .mcp.json.

### Claude Code: Or share it with your project (.mcp.json)

```json
{
  "mcpServers": {
    "ctxcap": {
      "command": "npx",
      "args": [
        "-y",
        "ctxcap-mcp"
      ]
    }
  }
}
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "ctxcap": {
      "command": "npx",
      "args": [
        "-y",
        "ctxcap-mcp"
      ]
    }
  }
}
```

Settings → Developer → Edit Config, then quit and reopen Claude Desktop.

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "ctxcap": {
      "command": "npx",
      "args": [
        "-y",
        "ctxcap-mcp"
      ]
    }
  }
}
```

Use .cursor/mcp.json in a project to share it with the project.

### VS Code (~/.copilot/mcp-config.json)

```json
{
  "mcpServers": {
    "ctxcap": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "ctxcap-mcp"
      ]
    }
  }
}
```

Or put the same entry in .mcp.json at your workspace root to share it.

### Codex: Add with the CLI (Terminal)

```sh
codex mcp add ctxcap -- npx -y ctxcap-mcp
```

### Codex: Or add to config.toml (~/.codex/config.toml)

```toml
[mcp_servers.ctxcap]
command = "npx"
args = ["-y", "ctxcap-mcp"]
```

### Gemini CLI and Antigravity: Gemini CLI (~/.gemini/settings.json)

```json
{
  "mcpServers": {
    "ctxcap": {
      "command": "npx",
      "args": [
        "-y",
        "ctxcap-mcp"
      ]
    }
  }
}
```

Or run: gemini mcp add -s user ctxcap npx -- -y ctxcap-mcp

### Gemini CLI and Antigravity: Antigravity (~/.gemini/config/mcp_config.json)

```json
{
  "mcpServers": {
    "ctxcap": {
      "command": "npx",
      "args": [
        "-y",
        "ctxcap-mcp"
      ]
    }
  }
}
```

Use .agents/mcp_config.json to add it to one workspace only.

### Devin Desktop (~/.config/devin/mcp_config.json)

```json
{
  "mcpServers": {
    "ctxcap": {
      "command": "npx",
      "args": [
        "-y",
        "ctxcap-mcp"
      ]
    }
  }
}
```

On Windows the file is %APPDATA%\\devin\\mcp_config.json. Use .devin/mcp_config.json to share it with a project.

### Cline (cline_mcp_settings.json)

```json
{
  "mcpServers": {
    "ctxcap": {
      "command": "npx",
      "args": [
        "-y",
        "ctxcap-mcp"
      ]
    }
  }
}
```

Open it from the MCP Servers icon → Configure → Configure MCP Servers.

### Zed (Zed settings.json)

```json
{
  "context_servers": {
    "ctxcap": {
      "command": "npx",
      "args": [
        "-y",
        "ctxcap-mcp"
      ]
    }
  }
}
```

Open it with zed: open settings file. Merge context_servers into the settings you already have.

### JetBrains AI Assistant and Junie: AI Assistant (Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add)

```json
{
  "mcpServers": {
    "ctxcap": {
      "command": "npx",
      "args": [
        "-y",
        "ctxcap-mcp"
      ]
    }
  }
}
```

### JetBrains AI Assistant and Junie: Junie (~/.junie/mcp/mcp.json)

```json
{
  "mcpServers": {
    "ctxcap": {
      "command": "npx",
      "args": [
        "-y",
        "ctxcap-mcp"
      ]
    }
  }
}
```

Use .junie/mcp/mcp.json to share it with a project.

### Kiro (~/.kiro/settings/mcp.json)

```json
{
  "mcpServers": {
    "ctxcap": {
      "command": "npx",
      "args": [
        "-y",
        "ctxcap-mcp"
      ]
    }
  }
}
```

Use .kiro/settings/mcp.json to add it to one workspace only.

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "ctxcap": {
      "command": "npx",
      "args": [
        "-y",
        "ctxcap-mcp"
      ]
    }
  }
}
```

## FAQ

### Does ctxcap need an API key or network access?

No. The README says there is no config, key, network or telemetry.

### Can ctxcap damage my files?

Apply splices atomically by line range and spans marked preserve are never cut; it advises running on a clean tree and reviewing with git diff. There is deliberately no stale apply mode.

### How do I try ctxcap?

Run npx ctxcap --json in a repository, or npx ctxcap --plan --budget 40000 for a plan.

### How is ctxcap different from tokenlint?

The README says tokenlint nudges per turn in the editor, while ctxcap gates the repository with baselines, plans and CI checks.

### Is ctxcap free?

Yes. ctxcap is free to use.

### How do I add ctxcap to Claude Code?

Run this command in your terminal: claude mcp add ctxcap -- npx -y ctxcap-mcp

### What are the best alternatives to ctxcap?

The closest alternatives to ctxcap are REA, Context7, Chrome DevTools MCP, Codebase Memory and GitHub.

## Where this comes from

- Description: written from the project's README and the project's website.
- Install steps: from the official MCP Registry entry.

## Alternatives

- [REA](https://ai-powered.com/mcp/rea): REA is an open-source MCP server for developer tools.
- [Context7](https://ai-powered.com/mcp/context7): Context7 is a freemium MCP server for developer tools.
- [Chrome DevTools MCP](https://ai-powered.com/mcp/chrome-devtools-mcp-2): Chrome DevTools MCP is an open-source MCP server for browser automation.
- [Codebase Memory](https://ai-powered.com/mcp/codebase-memory): Codebase Memory is an open-source MCP server for knowledge and memory.
- [GitHub](https://ai-powered.com/mcp/github): GitHub is an open-source MCP server for developer tools.
- [Serena MCP: the IDE for your agent](https://ai-powered.com/mcp/serena-mcp-the-ide-for-your-agent): Serena MCP: the IDE for your agent is an open-source MCP server for developer tools.
- [XERJ](https://ai-powered.com/mcp/xerj): XERJ is an open-source MCP server for knowledge and memory.
- [awesome-mcp-servers](https://ai-powered.com/mcp/awesome-mcp-servers-2): awesome-mcp-servers is an open-source MCP server for developer tools.

---
Source: https://ai-powered.com/mcp/ctxcap
