MCP server for structural code analysis and editing
Project description
rw-ast-tools
Structural code analysis and editing MCP server — 57 tools for Python, TypeScript, JavaScript, Rust, Go, Java, C, C++, and more.
rw-ast-tools gives LLMs the ability to search, read, edit, and analyze code structurally, not as text. Built on tree-sitter parsing for accuracy across 20+ languages, with a hybrid semantic + keyword search engine powered by sqlite-vec.
Features
- 57 MCP tools across 13 categories — structural search, semantic analysis, code editing, dependency analysis, class hierarchy, blast radius, knowledge graphs, co-change analysis, and more
- Three server modes —
timeout(stdio + idle TTL, default),daemon(systemd + file watcher),remote(Streamable HTTP + auth) - Agent-agnostic integration —
ast_tools.agent_integrationpackage has zero Hermes dependency. Use with FORGE, Claude Code, Cursor, or any MCP client - Hybrid search: True 6-factor RRF fusion — FTS5 keyword + vector semantic + recency + usage frequency + symbol kind + callgraph centrality
- Multi-language: 20+ languages via tree-sitter with full structural awareness
- Incremental indexing: SHA256 content-hash based, symbol-level diff — reindex in milliseconds
- Watchdog auto-indexer: Inotify-based file watcher for live codebase updates
- Metrics store: Time-series SQLite for codebase growth tracking
- CLI: 11 commands for terminal-first workflows
- Schema v5: symbols, embeddings, edges, dependency metrics, KNN graph, audit log
Quick Start
git clone https://github.com/stephanos8926-lgtm/ast-tools.git
cd ast-tools
uv sync --all-extras
MCP Server Configuration
Any MCP client (Hermes, FORGE, Claude Code):
{
"mcpServers": {
"rw-ast-tools": {
"command": "ast-tools-server",
"args": ["--mode", "timeout"]
}
}
}
Server Modes
| Mode | Flag | Transport | Lifecycle | Use Case |
|---|---|---|---|---|
timeout (default) |
--mode timeout |
stdio | Per-connection, idle TTL | Desktop CLI agents |
daemon |
--mode daemon |
stdio + systemd | Persistent, auto-restart | Multi-agent workstations |
remote |
--mode remote |
HTTP | Persistent, auth | Server deployment |
Override via env var: AST_TOOLS_MODE=daemon ast-tools-server
Tool Categories
| Category | Count | Tools |
|---|---|---|
| Core AST | 8 | Structural search (ast_grep), read (ast_read), edit (ast_edit), query (ast_query), capsule (ast_capsule), stub gen (ast_generate_stub), interface extraction (ast_refactor_extract_interface), TS editing (ts_edit) |
| Project Intelligence | 3 | Codebase summary, project info, impact analysis |
| Symbol Search | 5 | FTS5, semantic hybrid (6-factor RRF), find-by-name, list symbols, index status |
| Structural Analysis | 5 | Call graphs, type hierarchies, references, module imports, dependency chains |
| Dependency Analysis | 6 | Fan-in/out (module_imports), circular deps, external deps, dead code (basic + enhanced), API surface diff |
| Index Management | 4 | Refresh, reindex path, watch add, watch status |
| LSP Integration | 8 | Go-to-def, references, hover, symbols, call hierarchy (in/out), available languages, server check |
| Agent Integration | 4 | Context inject, context status, token status, validate usage |
| Code Validation | 1 | Multi-language syntax validation |
| Knowledge Graph | 3 | KG query, shortest path, neighborhood |
| Co-Change Analysis | 4 | Predict, hotspots, history, diff |
| Phase 10 | 7 | Transitive deps, class hierarchy (MRO), blast radius v2, repo skeleton, file related, code validate |
| CLI | 11 | Commands (ast search, ast blast-radius, ast find-dead, ast callers, ast deps, etc.) |
CLI
ast search "authentication handler" # Semantic search
ast blast-radius src/auth.py:42 # Impact analysis
ast find-dead --format json # Dead code detection
ast callers process_payment # Call graph
ast deps src/api/handlers.py # Import analysis
See docs/CLI_REFERENCE.md for the complete CLI reference.
Architecture
rw-ast-tools/
├── src/
│ └── ast_tools/
│ ├── agent_integration/ # Standalone modules (zero Hermes dep)
│ ├── tools/ # All 57 tool implementations
│ ├── watchdog/ # File watcher + metrics store
│ ├── kg/ # Knowledge graph engine
│ ├── cochange/ # Co-change analysis
│ ├── database/ # Schema v5
│ ├── embeddings/ # 384-dim vector embeddings
│ ├── indexer/ # Symbol extraction, diff engine
│ ├── context/ # Context injection (6-factor RRF)
│ ├── watcher/ # File watcher daemon
│ ├── curator/ # Automated index curation
│ ├── utils/ # Security, file ops
│ ├── _server.py # 3-mode MCP server
│ ├── server_config.py # Config (CLI/env/file)
│ └── cli.py # CLI commands
├── tests/ # 770 tests passing
├── docs/ # Full documentation
├── hermes-plugins/rw-ast-tools/ # Unified Hermes plugin
├── deploy/ # systemd service files
└── CHANGELOG.md # Release changelog
Documentation
| Document | Purpose |
|---|---|
docs/AST_TOOLS_QUICKSTART.md |
User guide & workflows |
docs/CLI_REFERENCE.md |
Complete CLI reference |
docs/TROUBLESHOOTING.md |
Common issues & fixes |
docs/DOCUMENTATION_INDEX.md |
Full documentation index |
docs/reports/server-architecture-completion.md |
3-mode server architecture report |
docs/specs/server-architecture-redesign-v1.md |
Architecture specification |
docs/adrs/0012-server-architecture-multi-mode.md |
Architecture decision record |
SETUP_INSTRUCTIONS.md |
Installation guide |
License
MIT — RapidWebs Enterprise, LLC
Contact
Steven Page — steven@rapidwebs.io
Part of the RapidWebs Enterprise ecosystem.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rw_ast_tools-0.2.0.tar.gz.
File metadata
- Download URL: rw_ast_tools-0.2.0.tar.gz
- Upload date:
- Size: 870.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b553bb1ad51cf5c27870669d473b15f783c9a524cd2c9847493cf664a490453
|
|
| MD5 |
378c1d7375cfcabe4e7ead76c88bd76c
|
|
| BLAKE2b-256 |
0d1a08253bffb19ab73c83dbfdc17349fc97fc4d4bc5344ca53de99d0822f703
|
File details
Details for the file rw_ast_tools-0.2.0-py3-none-any.whl.
File metadata
- Download URL: rw_ast_tools-0.2.0-py3-none-any.whl
- Upload date:
- Size: 248.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76224a80901452a171768e659ed73aebe95b68b85e7bfcebd7fb53dfab85b330
|
|
| MD5 |
7bd0d07c4339de2eb9b17e33072efe4c
|
|
| BLAKE2b-256 |
c491136e6a9296886a582cb5542dec84546a904e934aab49cda9b6e7946bcacc
|