Skip to content

MCP server for static code analysis. Returns structured data instead of raw files to reduce context window usage by 10x. Supports JS/TS/Python/Rust.

Notifications You must be signed in to change notification settings

dimaland1/codeast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodeAst

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).

Why CodeAst?

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

Installation

macOS / Linux:

claude mcp add codeast npx codeast

Windows:

npm install -g codeast
claude mcp add codeast codeast

The analyzer binary is downloaded automatically on first run.

Tools

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

Supported Languages

  • JavaScript / TypeScript / JSX / TSX
  • Python
  • Rust
  • Astro

Contributing

Contributions are welcome! Here's how to get started:

1. Fork & Clone

# Fork the repo on GitHub, then clone your fork
git clone https://github.com/YOUR_USERNAME/codeast.git
cd codeast

2. Setup Dev Environment

# 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

3. Make Changes

# 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"

4. Open a Pull Request

# Push to your fork
git push origin feature/my-feature

# Then open a PR on GitHub: https://github.com/dimaland1/codeast/pulls

Areas for Contribution

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

New Language Support

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

License

MIT


Found a bug? Have an idea? Open an issue or submit a PR!

About

MCP server for static code analysis. Returns structured data instead of raw files to reduce context window usage by 10x. Supports JS/TS/Python/Rust.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages