MCP 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:
claude mcp add codeast npx codeastWindows:
npm install -g codeast
claude mcp add codeast codeastThe 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
Contributions are welcome! Here's how to get started:
# Fork the repo on GitHub, then clone your fork
git clone https://github.com/YOUR_USERNAME/codeast.git
cd codeast# Build the Rust analyzer
cd analyzer && cargo build --release
# Build and run MCP server (auto-detects local binary)
cd ../mcp && npm install && npm run build
node dist/mcp/server.js# Create a branch for your feature/fix
git checkout -b feature/my-feature
# Make your changes, then commit
git add .
git commit -m "feat: Add my feature"# Push to your fork
git push origin feature/my-feature
# Then open a PR on GitHub: https://github.com/dimaland1/codeast/pulls| # | 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 |
| # | 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 |
| # | 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 |
| 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 |
Want to add support for a new language? Here's what you need:
- Add tree-sitter grammar to
analyzer/Cargo.toml - Create extraction functions in
analyzer/src/symbols.rs - Add import parsing in
analyzer/src/parser.rs - Add tests in
analyzer/tests/
Languages we'd love to support:
- Go
- Java
- C/C++
- Ruby
- PHP
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!