MCP server that compresses any codebase into LLM-ready semantic context. AST-based compression for TypeScript, JavaScript, PHP, Dart & Python.
Works with Claude Desktop, Cursor, Windsurf, GitHub Copilot, Amazon Q, and any Model Context Protocol compatible client.
When an LLM needs to understand a large codebase, sending raw source files wastes most of the context window on function bodies, boilerplate, and irrelevant files. A 500-line file might contain only 30 lines of structural information (signatures, types, interfaces) that the LLM actually needs.
mcp-code-context extracts only the structural skeleton of your code — function signatures, class declarations, interfaces, type aliases, constants, and docblocks — delivering a compressed map that gives the LLM full architectural awareness at a fraction of the token cost.
| File | Original | Compressed | Reduction |
|---|---|---|---|
| PHP class (426 lines) | 426 | 60 | 85.9% |
| Dart repository (230 lines) | 230 | 30 | 87.0% |
| PHP config (68 lines) | 68 | 15 | 77.9% |
Built to be robust and precise. The extraction engines are tested against real-world, complex codebases (including nested generic types in Dart and complex interfaces in PHP) with a 100% test pass rate (66/66 test assertions passing across all languages).
- 🌳 AST-based compression — Real parsers for TypeScript/JavaScript (ts-morph) and PHP (php-parser). Brace-counting engine for Dart. Regex-based extraction for Python.
- 🔬 Surgical symbol extraction — Extract a single function, class, or method from a file by name. Get only what you need.
- 💥 Impact analysis — Discover all files that depend on a given file before refactoring. Supports ES imports, CommonJS
require(), Python imports, PHPuse/require_once/include, and Dart imports. - 📁 Smart file walking — Respects
.gitignoreand.repomixignorerules. Automatically excludesnode_modules,dist,vendor,.git, etc. - 📄 Multi-format output — XML (optimized for LLM consumption) or Markdown (human-readable).
| Language | Compression Engine | Symbol Extraction | Import Analysis |
|---|---|---|---|
| TypeScript / JavaScript | AST (ts-morph) | ✅ | ✅ |
| PHP | AST (php-parser) | ✅ | ✅ |
| Dart | Brace-counting + regex | ✅ | ✅ |
| Python | Regex-based | ✅ | ✅ |
| Others (JSON, YAML, CSS, etc.) | Passthrough / truncation | — | — |
# Clone the repository
git clone https://github.com/YOUR_USERNAME/mcp-code-context.git
cd mcp-code-context
# Install dependencies
npm install
# Build
npm run buildAdd to your claude_desktop_config.json:
{
"mcpServers": {
"mcp-code-context": {
"command": "node",
"args": ["/absolute/path/to/mcp-code-context/dist/index.js"]
}
}
}Add to your Cursor MCP settings (.cursor/mcp.json):
{
"mcpServers": {
"mcp-code-context": {
"command": "node",
"args": ["/absolute/path/to/mcp-code-context/dist/index.js"]
}
}
}Add to your Windsurf MCP config:
{
"mcpServers": {
"mcp-code-context": {
"command": "node",
"args": ["/absolute/path/to/mcp-code-context/dist/index.js"]
}
}
}Any MCP-compatible client can use this server. The transport is stdio (JSON-RPC over stdin/stdout). Point your client to node dist/index.js.
Generate a compressed architectural overview of an entire repository.
Parameters:
directoryPath(required) — Absolute path to the repository rootformat(optional) —"xml"(default) or"markdown"
Example output (PHP class):
namespace Dt24ApiAuth;
class Dt24_Api_Auth_Admin {
private $plugin_name;
private $version;
const CUSTOM_STATUSES = ['shipped' => '...', 'delivered' => '...'];
public function __construct($plugin_name, $version) { /* ... */ }
public function enqueue_styles() { /* ... */ }
/** @param int $order_id The order ID. */
public function check_the_elapsed_time(int $time_to_check, int $intervalo, string $unidad, ?int $current_time = null) { /* ... */ }
}Read a complete file, or extract only a specific named symbol.
Parameters:
filePath(required) — Absolute path to the source filesymbolName(optional) — Name of a function, class, method, or type to extract
Example: Extract only the fetchSections method from a 230-line Dart file:
// Symbol: fetchSections
// File: home_repository.dart
/// Obtiene las secciones del home
Future<List<Map<String, dynamic>>> fetchSections({
String platform = 'app',
bool useCache = true,
}) async {
final token = await AuthService().getValidToken();
// ... full implementation
}Find all files that import or depend on a given file.
Parameters:
filePath(required) — Absolute path to the file being modifiedrootDir(optional) — Repository root (auto-detected if omitted)
Example output:
# Impact Analysis
## Target
- **File:** `includes/Dt24Config.php`
- **Dependent files:** 1
## Dependent Files
### `dt24-core-plugin.php`
- `use Dt24ApiAuth\Dt24Config`- Start with
get_semantic_repo_mapto understand the project architecture - Use
read_file_surgicalwith a symbol name to drill into specific implementations - Before modifying a file, run
analyze_impactto understand the blast radius
# Build
npm run build
# Run tests
npm run build && node dist/test-dart.js && node dist/test-php.js
# Development (build + start)
npm run dev- Transport: stdio (JSON-RPC over stdin/stdout)
- Runtime: Node.js >= 18
- Protocol: Model Context Protocol
- AST Engines: ts-morph (TypeScript/JS), php-parser (PHP), brace-counting (Dart), regex (Python)
- Ignore Engine:
ignorenpm package (full .gitignore spec support)