Codectx

v1.0.0Developer Toolsstable

Codebase context compiler for AI agents. Graph-ranked, token-budgeted, tier-compressed output. Smarter than the existing ones.

aiai-agentsclicli-toolcontext
Share:
29
Stars
0
Downloads
0
Weekly
0/5

What is Codectx?

Codectx is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to codebase context compiler for ai agents. graph-ranked, token-budgeted, tier-compressed output. smarter than the existing ones.

Codebase context compiler for AI agents. Graph-ranked, token-budgeted, tier-compressed output. Smarter than the existing ones.

This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • Codebase context compiler for AI agents. Graph-ranked, token

Use Cases

Extract codebase context
Token-optimized output
AI-ready code summaries
hey-granth

Maintainer

LicenseMIT
Languagepython
Versionv1.0.0
UpdatedMay 10, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx codectx

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use Codectx

Codectx is a Python CLI tool and MCP server that compiles a codebase into a single, token-budgeted context document for AI agents. It uses tree-sitter to parse source files across nine languages, graph-ranks them by relevance to a query or task profile, and applies tier compression to fit within a configurable token budget — producing far more useful context than naive directory concatenation. Developers feed its output to AI coding assistants when they need the agent to understand a large repository without blowing the context window.

Prerequisites

  • Python 3.10 or higher
  • pip, uv, or pipx for installation
  • An MCP-compatible client such as Claude Desktop or Cursor
  • Optional: OpenAI or compatible API key for the --llm AI-summary feature
1

Install codectx

Install codectx from PyPI using your preferred Python package manager. Use the [llm] extra if you want AI-powered summaries.

pip install codectx
# or with LLM summary support
pip install codectx[llm]
# or with uv
uv add codectx
2

Create an optional project configuration file

Add a .codectx.toml to your project root to set default token budget, output filename, and patterns to ignore. All keys are optional.

[codectx]
token_budget = 120000
output_file = "CONTEXT.md"
extra_ignore = ["**/generated/**", "*.draft.py"]
3

Run a basic codebase analysis

Run codectx analyze from your project root. It will parse all supported source files, rank them, and write a token-budgeted CONTEXT.md.

codectx analyze .
# Limit to 60k tokens
codectx analyze . --tokens 60000
# Output as machine-readable JSON
codectx analyze . --format json --output context.json
4

Use task profiles for better ranking

Specify a --task profile to bias the graph-ranking toward files relevant to a specific kind of work: architecture, refactor, debug, or feature.

codectx analyze . --task debug
codectx analyze . --task feature --query "authentication flow"
5

Enable watch mode for live updates

Watch mode regenerates the context file automatically when source files change, keeping AI agents up to date during active development.

codectx watch . --debounce 1.5
6

Configure as an MCP server in Claude Desktop

Register codectx as an MCP server so Claude can call it as a tool to analyse any repository path on demand.

{
  "mcpServers": {
    "codectx": {
      "command": "python",
      "args": ["-m", "codectx", "serve"]
    }
  }
}

Codectx Examples

Client configuration

Claude Desktop configuration to run codectx as a Python-based MCP server.

{
  "mcpServers": {
    "codectx": {
      "command": "python",
      "args": ["-m", "codectx", "serve"]
    }
  }
}

Prompts to try

Prompts that use codectx to give Claude deep codebase awareness.

- "Use codectx to analyse this repo and then explain the overall architecture."
- "Compile the authentication-related files into context and identify security gaps."
- "Run codectx with the debug task profile and find the most likely source of the payment processing bug."
- "Generate a 60k-token context of the API layer and write API documentation for each endpoint."

Troubleshooting Codectx

tree-sitter fails to parse certain files or raises ImportError

Ensure Python 3.10+ is in use (python --version). Some tree-sitter language wheels require a Rust toolchain to compile on first install; run pip install codectx --no-binary codectx if wheels are unavailable for your platform.

Output context file exceeds the expected token budget

The --tokens flag overrides the config file value. Pass --tokens with an explicit number and add high-noise directories (node_modules, .git, build) to extra_ignore in .codectx.toml.

Watch mode misses file changes in Docker or WSL environments

File-system events may not propagate across bind mounts. Increase the --debounce value to 3 or 5 seconds, or use polling mode if your platform supports it via the underlying watchdog library.

Frequently Asked Questions about Codectx

What is Codectx?

Codectx is a Model Context Protocol (MCP) server that codebase context compiler for ai agents. graph-ranked, token-budgeted, tier-compressed output. smarter than the existing ones. It connects AI assistants to external tools and data sources through a standardized interface.

How do I install Codectx?

Follow the installation instructions on the Codectx GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with Codectx?

Codectx works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is Codectx free to use?

Yes, Codectx is open source and available under the MIT license. You can use it freely in both personal and commercial projects.

Browse More Developer Tools MCP Servers

Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "codectx": { "command": "npx", "args": ["-y", "codectx"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use Codectx?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides