CodeShave
Compresses code into syntax-valid skeletons so AI coding assistants use fewer tokens
CodeShave is an open-source MCP server for developer tools. It runs locally on your machine and is started by your AI client.
- Pricing
- Open source
- Platforms
- CLI, VS Code, macOS
- Runs
- Locally
- Version
- 0.2.2
- Listing updated
Similar MCP servers
Install
You install MCP servers on a computer. Send yourself the link.
Add with the CLI
Run in a terminal
claude mcp add codeshave -- uvx codeshaveAdd --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": {
"codeshave": {
"command": "uvx",
"args": [
"codeshave"
]
}
}
}Add to claude_desktop_config.json
{
"mcpServers": {
"codeshave": {
"command": "uvx",
"args": [
"codeshave"
]
}
}
}Settings → Developer → Edit Config, then quit and reopen Claude Desktop.
Add to ~/.cursor/mcp.json
{
"mcpServers": {
"codeshave": {
"command": "uvx",
"args": [
"codeshave"
]
}
}
}Use .cursor/mcp.json in a project to share it with the project.
Add to ~/.copilot/mcp-config.json
{
"mcpServers": {
"codeshave": {
"type": "stdio",
"command": "uvx",
"args": [
"codeshave"
]
}
}
}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 codeshave -- uvx codeshaveOr add to config.toml
Add to ~/.codex/config.toml
[mcp_servers.codeshave]
command = "uvx"
args = ["codeshave"]Add to your client's MCP settings (most use this shape)
{
"mcpServers": {
"codeshave": {
"command": "uvx",
"args": [
"codeshave"
]
}
}
}Gemini CLI and Antigravity
Gemini CLI
Add to ~/.gemini/settings.json
{ "mcpServers": { "codeshave": { "command": "uvx", "args": [ "codeshave" ] } } }Or run: gemini mcp add -s user codeshave uvx -- codeshave
Antigravity
Add to ~/.gemini/config/mcp_config.json
{ "mcpServers": { "codeshave": { "command": "uvx", "args": [ "codeshave" ] } } }Use .agents/mcp_config.json to add it to one workspace only.
Devin Desktop (formerly Windsurf)
Add to ~/.config/devin/mcp_config.json
{ "mcpServers": { "codeshave": { "command": "uvx", "args": [ "codeshave" ] } } }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": { "codeshave": { "command": "uvx", "args": [ "codeshave" ] } } }Open it from the MCP Servers icon → Configure → Configure MCP Servers.
Zed
Add to Zed settings.json
{ "context_servers": { "codeshave": { "command": "uvx", "args": [ "codeshave" ] } } }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": { "codeshave": { "command": "uvx", "args": [ "codeshave" ] } } }Junie
Add to ~/.junie/mcp/mcp.json
{ "mcpServers": { "codeshave": { "command": "uvx", "args": [ "codeshave" ] } } }Use .junie/mcp/mcp.json to share it with a project.
Kiro
Add to ~/.kiro/settings/mcp.json
{ "mcpServers": { "codeshave": { "command": "uvx", "args": [ "codeshave" ] } } }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 CodeShave
CodeShave shrinks source code before it reaches a language model. It parses files with language-native AST tools and keeps the parts a model needs to understand a codebase, such as types, classes, interfaces, docstrings, decorators and function signatures, while collapsing repetitive function bodies and loops into placeholders. The output stays syntactically valid, so assistants can still read it as real code.
The tool runs as an MCP server over stdio and can also be used from the command line. Commands cover copying a compressed view to the clipboard, packing a directory into a Markdown or XML context bundle, showing a diff of the lines removed, and enforcing a token budget so output fits under a chosen limit. A connect command registers it with several AI clients, and an IDE extension is available for VS Code-based editors.
It suits developers who work with large repositories in tools such as Claude, Cursor, Windsurf or VS Code Copilot and want to keep prompts within context limits. The project is MIT licensed and includes a browser playground for testing compression on your own code.
What it does
- AST-based body pruning
- Replaces function and method bodies with placeholders while leaving the surrounding structure intact.
- Syntax-valid output
- Compressed files remain parseable in the source language, so models receive clean code structure.
- Token budget enforcement
- Automatically prunes files so the packed output fits under a specified token ceiling.
- Multi-language support
- Handles Python, TypeScript and JavaScript, Go, Rust, Java, C and C++, C#, Kotlin and Swift.
- Client auto-connect
- A single command detects installed AI clients and registers the MCP server with them.
- Clipboard and pack commands
- Copies compressed code to the clipboard or writes it to Markdown or XML context files.
Good for
- Giving an AI assistant an overview of a large repository without exceeding its context window
- Reducing prompt token costs when asking models about a codebase
- Packing a project into a single context file for a chat session
- Reviewing which lines a compression pass removed before sharing code
Pricing
Open source
Free and open source under MIT; optional sponsorship links.
CodeShave FAQ
How do I install CodeShave as an MCP server?
Run pip install codeshave followed by codeshave connect --all, or configure the server to run with uvx codeshave mcp.
Which languages are supported?
Python, TypeScript and JavaScript, Go, Rust, Java, C and C++, C#, Kotlin and Swift are supported.
What is the license?
CodeShave is released under the MIT license.
Is CodeShave free?
Yes. CodeShave is open source, so you can use and self-host it for free.
How do I add CodeShave to Claude Code?
Run this command in your terminal: claude mcp add codeshave -- uvx codeshave
What are the best alternatives to CodeShave?
The closest alternatives to CodeShave are Compress-token, Air, Smart Context MCP, Codegraph and Diogenes Context Compression & Code Solvers MCP.
Where this comes from
- Description: written from the project's README and its MCP Registry entry.
- Install steps: from the official MCP Registry entry.