MCP server for code analysis - reduces context window usage by returning structured data
npm install codeastMCP server for static code analysis — Returns structured data instead of raw files to reduce context window usage by 10x.
Built with Rust (analyzer) + TypeScript (MCP wrapper).
When LLMs analyze code, they typically read entire files. CodeAst extracts only what matters:
| Without CodeAst | With CodeAst |
|-----------------|--------------|
| Read 500 lines to find functions | Get structured list of symbols |
| Grep entire codebase for callers | Get precise caller locations |
| Manual dependency tracing | Automatic cycle detection |
macOS / Linux:
``bash`
claude mcp add codeast npx codeast
Windows:
`bash`
npm install -g codeast
claude mcp add codeast codeast
The analyzer binary is downloaded automatically on first run.
| Tool | Description |
|------|-------------|
| get_symbols | List functions, classes, types in a file |get_callers
| | Find all functions that call a function |get_calls
| | Get all functions called by a function |get_imports
| | Get imports (internal vs external) |get_imported_by
| | Find files that import a file |get_complexity
| | Get cyclomatic/cognitive complexity metrics |get_cycles
| | Detect circular dependencies |get_duplicates
| | Find duplicated code blocks |get_file_info
| | Quick file overview |search_files
| | Search files by glob pattern |run_tests
| | Run tests (auto-detects npm/cargo/pytest) |status
| | Check if analyzer is running |
- JavaScript / TypeScript / JSX / TSX
- Python
- Rust
- Astro
---
This project is open source and welcomes contributions! Whether you're fixing bugs, adding features, or improving documentation, your help is appreciated.
`bashClone the repo
git clone https://github.com/YOUR_USERNAME/codeast.git
cd codeast
The MCP auto-detects the local binary in dev mode.
$3
#### Bugs to Fix
| # | Bug | Impact |
|---|-----|--------|
| 1 |
get_callers doesn't find without module prefix (fn vs module::fn) | Usability |
| 2 | JS grammar doesn't detect exports (only TS works) | .js files |#### Missing Features
| # | Feature | Description |
|---|---------|-------------|
| 1 | Function parameters | Extract params (name, type) from functions |
| 2 | Return types | Extract return type from functions |
| 3 | Class methods |
get_symbols doesn't return methods |
| 4 | Export default | export default function not detected |
| 5 | Re-exports | export { foo } from './bar' not traced |
| 6 | Decorators | @Controller, @Injectable (NestJS, Angular) |
| 7 | JSDoc/TSDoc | Extract documentation comments |
| 8 | Async detection | Mark if a function is async |#### MCP Improvements
| # | Tool | Improvement |
|---|------|-------------|
| 1 |
get_callers | Fuzzy match (without module prefix) |
| 2 | get_callers | Add recursive: true param for call chain |
| 3 | get_symbols | Add methods for classes |
| 4 | get_complexity | Add maintainability index |
| 5 | search_code | New tool for grep with context |
| 6 | get_dependencies | Visualize dependency tree of a file |#### Refactoring
| File | Complexity | Action |
|------|------------|--------|
|
symbols.rs | 382 | Split into modules (js.rs, rust.rs, python.rs, astro.rs) |
| analyzer.rs | 73 | Extract process_import logic |
| handlers.ts | - | Factor out error handling |$3
Want to add support for a new language? Here's what you need:
1. Add tree-sitter grammar to
analyzer/Cargo.toml
2. Create extraction functions in analyzer/src/symbols.rs
3. Add import parsing in analyzer/src/parser.rs
4. Add tests in analyzer/tests/Languages we'd love to support:
- Go
- Java
- C/C++
- Ruby
- PHP
---
Project Structure
`
codeast/
├── analyzer/ # Rust - Core analysis engine
│ ├── src/
│ │ ├── main.rs # CLI entry point
│ │ ├── analyzer.rs # Orchestration
│ │ ├── symbols.rs # AST symbol extraction
│ │ ├── parser.rs # Import extraction
│ │ ├── complexity.rs # Metrics calculation
│ │ ├── duplicates.rs # Duplicate detection
│ │ └── graph.rs # Dependency graph
│ └── Cargo.toml
│
├── mcp/ # TypeScript - MCP server wrapper
│ ├── src/
│ │ ├── mcp/
│ │ │ ├── server.ts # MCP entry point
│ │ │ ├── tools.ts # Tool definitions
│ │ │ └── handlers.ts # Tool implementations
│ │ └── services/
│ │ ├── analyzer.ts # Process management
│ │ └── queries.ts # Query API
│ └── package.json
│
└── docs/ # Landing page
``MIT
---
Found a bug? Have an idea? Open an issue or submit a PR!