context-trim
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@context-trimanalyze which files are eating the most tokens in this repo"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
context-trim βοΈ
Cut codebase token bloat by 70%+ when packing context for LLMs.
Ultra-fast CLI and zero-dependency MCP server for Claude Code, Cursor, Codex, ChatGPT, and Antigravity.
β‘ The Problem
When you prompt an AI coding assistant (Claude Code, ChatGPT, Cursor) with your repository:
Massive lockfiles (
package-lock.json,poetry.lock,yarn.lock) consume 50,000+ unnecessary tokens.Build output folders (
dist,.next,build,__pycache__) flood context windows.Minified files, maps, images, and binary artifacts waste money, trigger rate limits, and degrade model reasoning.
context-trim automatically strips out all bloat, estimates token consumption, and outputs a clean, structured context pack ready for any LLM.
Related MCP server: Ambiance MCP Server
π Quick Start
No installation needed. Run directly with npx:
# Scan current repository and save a clean ai-context.md
npx context-trim
# Check token waste and see what's eating your context window
npx context-trim --stats
# Preview the clean file tree that LLMs will receive
npx context-trim --tree
# Save to a custom output file with a strict token budget
npx context-trim -o prompt.md --budget 40000π Use as an MCP Server (Claude Desktop & Claude Code)
context-trim comes with native Model Context Protocol (MCP) support built-in without installing external dependencies.
Add it to your Claude Desktop configuration (claude_desktop_config.json):
{
"mcpServers": {
"context-trim": {
"command": "npx",
"args": ["-y", "context-trim", "--mcp"]
}
}
}Exposed MCP Tools:
get_clean_codebase_context: Feeds Claude a lean, optimized codebase representation without lockfile bloat.analyze_token_waste: Identifies the heaviest files eating tokens in your workspace.
βοΈ CLI Options
Flag | Description |
| Custom path to save the generated markdown pack (default: |
| Show token count, skipped files, and size breakdown without writing a file. |
| Print the filtered file tree with token estimates per file. |
| Cap context at a specific token ceiling (e.g. |
| Start as an MCP server over stdio for Claude / Cursor / Antigravity. |
| Output version number. |
| Display command-line help. |
π‘οΈ Default Smart Filters
context-trim ignores by default:
Directories:
node_modules,.git,.next,.nuxt,dist,build,out,coverage,.venv,__pycache__,.turbo,.cache,.idea,.vscode.Lockfiles:
package-lock.json,yarn.lock,pnpm-lock.yaml,poetry.lock,Cargo.lock,bun.lockb.Media & Binaries: Images, videos, fonts, zips, PDFs, compiled binaries (
.so,.dll,.exe).Minified & Maps:
*.min.js,*.min.css,*.map.Local
.gitignorerules: Respected automatically.
π¦ Zero Dependencies
Written in native Node.js ESM. It requires no external npm dependencies, starts in under 2ms, and runs anywhere Node 18+ is available.
π License
MIT Β© Kaan Efe Demir
This server cannot be deployed
Maintenance
Related MCP Connectors
Codebase intelligence for AI agents β dead code, blast radius, ownership.
Deterministic context layer for your codebase: change impact, blast radius, answers with receipts.
AI-powered codebase analysis β call graphs, security, dead code, complexity. 150+ tools.
Provide your AI coding tools with token-efficient access to up-to-date technical documentation forβ¦
Related MCP Servers
- AlicenseBqualityDmaintenanceExtracts minimal, relevant code context from multiple programming languages while analyzing diffs and optimizing imports to reduce token usage for AI assistants. Supports TypeScript/JavaScript, Python, Go, and Rust with token-aware caching.76 npm1MIT
- AlicenseAqualityDmaintenanceProvides intelligent code context and analysis through semantic compression, AST parsing, and multi-language support. Offers 60-80% token reduction while enabling AI assistants to understand codebases through local analysis, OpenAI-enhanced insights, and GitHub repository integration.63 npm3MIT
- AlicenseAqualityDmaintenanceAnalyzes codebases from local directories, GitHub, and Azure DevOps, providing intelligent context to AI coding assistants through repository structure, critical files, and semantic maps.144MIT

Code Scalpelofficial
AlicenseNot gradedqualityCmaintenanceEnables AI assistants to surgically extract and analyze code, reducing token usage and costs by up to 200x compared to reading entire files.18MIT