ctxcap
Offline linter that trims CLAUDE.md and AGENTS.md files to a token budget
ctxcap is a free MCP server for developer tools. It runs locally on your machine and is started by your AI client.
- Pricing
- Free
- Platforms
- CLI
- Runs
- Locally
- Version
- 0.1.10
- Listing updated
Similar MCP servers
Install
Add with the CLI
Run in a terminal
claude mcp add ctxcap -- npx -y ctxcap-mcpAdd --scope user to use it in every project, or --scope project to share it in .mcp.json.
Or share it with your project
Add to .mcp.json
{
"mcpServers": {
"ctxcap": {
"command": "npx",
"args": [
"-y",
"ctxcap-mcp"
]
}
}
}Add to claude_desktop_config.json
{
"mcpServers": {
"ctxcap": {
"command": "npx",
"args": [
"-y",
"ctxcap-mcp"
]
}
}
}Settings → Developer → Edit Config, then quit and reopen Claude Desktop.
Add to ~/.cursor/mcp.json
{
"mcpServers": {
"ctxcap": {
"command": "npx",
"args": [
"-y",
"ctxcap-mcp"
]
}
}
}Use .cursor/mcp.json in a project to share it with the project.
Add to ~/.copilot/mcp-config.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.
Add with the CLI
Run in a terminal
codex mcp add ctxcap -- npx -y ctxcap-mcpOr add to config.toml
Add to ~/.codex/config.toml
[mcp_servers.ctxcap]
command = "npx"
args = ["-y", "ctxcap-mcp"]Add to your client's MCP settings (most use this shape)
{
"mcpServers": {
"ctxcap": {
"command": "npx",
"args": [
"-y",
"ctxcap-mcp"
]
}
}
}Gemini CLI and Antigravity
Gemini CLI
Add to ~/.gemini/settings.json
{ "mcpServers": { "ctxcap": { "command": "npx", "args": [ "-y", "ctxcap-mcp" ] } } }Or run: gemini mcp add -s user ctxcap npx -- -y ctxcap-mcp
Antigravity
Add to ~/.gemini/config/mcp_config.json
{ "mcpServers": { "ctxcap": { "command": "npx", "args": [ "-y", "ctxcap-mcp" ] } } }Use .agents/mcp_config.json to add it to one workspace only.
Devin Desktop (formerly Windsurf)
Add to ~/.config/devin/mcp_config.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
Add to cline_mcp_settings.json
{ "mcpServers": { "ctxcap": { "command": "npx", "args": [ "-y", "ctxcap-mcp" ] } } }Open it from the MCP Servers icon → Configure → Configure MCP Servers.
Zed
Add to Zed settings.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
Add to Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add
{ "mcpServers": { "ctxcap": { "command": "npx", "args": [ "-y", "ctxcap-mcp" ] } } }Junie
Add to ~/.junie/mcp/mcp.json
{ "mcpServers": { "ctxcap": { "command": "npx", "args": [ "-y", "ctxcap-mcp" ] } } }Use .junie/mcp/mcp.json to share it with a project.
Kiro
Add to ~/.kiro/settings/mcp.json
{ "mcpServers": { "ctxcap": { "command": "npx", "args": [ "-y", "ctxcap-mcp" ] } } }Use .kiro/settings/mcp.json to add it to one workspace only.
Using several servers? Build one config file with the MCP config generator.
About ctxcap
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.
What it does
- 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
Pricing
Free
Free; license not published
Prices change. Check naeha-s.github.io before you buy.
ctxcap 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.


