Skip to content

Commit 6d66f05

Browse files
authored
Merge pull request #10 from holive/holive/improve-mcp
feat: improve MCP server -- roam_ prefix, 13 new tools, structured errors, roam mcp command
2 parents 4358b70 + 63a591d commit 6d66f05

9 files changed

Lines changed: 1089 additions & 176 deletions

File tree

.github/workflows/roam-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ jobs:
4949
- run: pip install -e .
5050
- run: roam index
5151
- run: roam fitness
52-
- run: roam health --json
52+
- run: roam --json health

.github/workflows/roam.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ jobs:
1818
- run: pip install roam-code
1919
- run: roam index
2020
- run: roam fitness
21-
- run: roam pr-risk --json
21+
- run: roam --json pr-risk

CLAUDE.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ roam health
3838
```
3939
src/roam/
4040
cli.py # Click CLI entry point — LazyGroup, _COMMANDS dict, _CATEGORIES
41-
mcp_server.py # FastMCP server (48 tools, 2 resources)
41+
mcp_server.py # FastMCP server (61 tools, 2 resources) + `roam mcp` CLI command
4242
__init__.py # Version string (reads from pyproject.toml via importlib.metadata)
4343
db/
4444
schema.py # SQLite schema (CREATE TABLE statements)
@@ -106,7 +106,7 @@ src/roam/
106106
formatter.py # Token-efficient text formatting, abbrev_kind(), loc(), format_table(), to_json(), json_envelope()
107107
sarif.py # SARIF 2.1.0 output (--sarif flag on health/debt/complexity)
108108
schema_registry.py # JSON envelope schema versioning + validation
109-
tests/ # 70 test files
109+
tests/ # 71 test files
110110
# Core & legacy
111111
test_basic.py, test_comprehensive.py, test_fixes.py, test_performance.py,
112112
test_resolve.py, test_salesforce.py, test_v6_features.py,
@@ -130,7 +130,8 @@ tests/ # 70 test files
130130
test_capsule.py, test_forecast.py, test_path_coverage.py,
131131
test_minimap.py, test_attest.py, test_annotations.py, test_budget.py,
132132
test_pr_diff.py, test_framework_detection.py, test_backend_fixes_round2.py,
133-
test_backend_fixes_round3.py, test_exclude_patterns.py, test_math_tips.py
133+
test_backend_fixes_round3.py, test_exclude_patterns.py, test_math_tips.py,
134+
test_mcp_server.py
134135
```
135136

136137
### Key patterns
@@ -223,7 +224,7 @@ tests/ # 70 test files
223224
- tree-sitter >= 0.23 (AST parsing)
224225
- tree-sitter-language-pack >= 0.6 (165+ grammars)
225226
- networkx >= 3.0 (graph algorithms)
226-
- Optional: fastmcp (MCP server)
227+
- Optional: fastmcp >= 2.0 (MCP server`pip install roam-code[mcp]`)
227228
- Dev: pytest >= 7.0, pytest-xdist >= 3.0, ruff >= 0.4
228229

229230
## Version bumping

README.md

Lines changed: 84 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -722,73 +722,86 @@ Run `roam --help` for all commands. Use `roam --json <cmd>` for structured outpu
722722
Roam includes a [Model Context Protocol](https://modelcontextprotocol.io/) server for direct integration with tools that support MCP.
723723

724724
```bash
725-
pip install fastmcp
726-
fastmcp run roam.mcp_server:mcp
725+
pip install roam-code[mcp]
726+
roam mcp
727727
```
728728

729-
48 read-only tools and 2 resources. All tools query the index -- they never modify your code.
729+
61 tools and 2 resources. All tools are read-only and query the index -- they never modify your code.
730730

731-
**Lite mode:** For smaller models or latency-sensitive setups, set `ROAM_MCP_LITE=1` to expose only 15 core tools:
731+
**Lite mode (default):** By default, 16 core tools are exposed to keep the tool list manageable for agents. Set `ROAM_MCP_LITE=0` to expose all 61 tools:
732732

733733
```bash
734-
ROAM_MCP_LITE=1 fastmcp run roam.mcp_server:mcp
734+
ROAM_MCP_LITE=0 roam mcp
735735
```
736736

737-
Core tools in lite mode: `understand`, `health`, `preflight`, `search_symbol`, `context`, `trace`, `impact`, `file_info`, `pr_risk`, `affected_tests`, `dead_code`, `complexity_report`, `diagnose`, `visualize`, `closure`.
737+
Core tools in lite mode: `roam_understand`, `roam_search_symbol`, `roam_context`, `roam_file_info`, `roam_deps`, `roam_preflight`, `roam_diff`, `roam_pr_risk`, `roam_affected_tests`, `roam_impact`, `roam_uses`, `roam_health`, `roam_dead_code`, `roam_complexity_report`, `roam_diagnose`, `roam_trace`.
738738

739739
<details>
740-
<summary><strong>MCP tool list (all 48)</strong></summary>
740+
<summary><strong>MCP tool list (all 61)</strong></summary>
741741

742742
| Tool | Description |
743743
|------|-------------|
744-
| `understand` | Full codebase briefing |
745-
| `health` | Health score (0-100) + issues |
746-
| `preflight` | Pre-change safety check |
747-
| `search_symbol` | Find symbols by name |
748-
| `context` | Files-to-read for modifying a symbol |
749-
| `trace` | Dependency path between two symbols |
750-
| `impact` | Blast radius of changing a symbol |
751-
| `file_info` | File skeleton with all definitions |
752-
| `pr_risk` | Risk score for pending changes |
753-
| `breaking_changes` | Detect breaking changes between refs |
754-
| `affected_tests` | Find tests affected by a change |
755-
| `dead_code` | List unreferenced exports |
756-
| `complexity_report` | Per-symbol cognitive complexity |
757-
| `repo_map` | Project skeleton with key symbols |
758-
| `tour` | Auto-generated onboarding guide |
759-
| `diagnose` | Root cause analysis for debugging |
760-
| `visualize` | Generate Mermaid or DOT architecture diagrams |
761-
| `algo` | Algorithm anti-pattern detection with language-aware tips |
762-
| `ws_understand` | Unified multi-repo workspace overview |
763-
| `ws_context` | Cross-repo augmented symbol context |
764-
| `pr_diff` | Structural PR diff: metric deltas, edge analysis, symbol changes |
765-
| `budget_check` | Check changes against architectural budgets |
766-
| `effects` | Side-effect classification (DB writes, network, filesystem) |
767-
| `attest` | Proof-carrying PR attestation with all evidence bundled |
768-
| `capsule_export` | Export sanitized structural graph (no code bodies) |
769-
| `path_coverage` | Find critical untested call paths (entry -> sink) |
770-
| `forecast` | Predict when metrics will exceed thresholds |
771-
| `simulate` | Counterfactual architecture simulator |
772-
| `orchestrate` | Multi-agent swarm partitioning |
773-
| `fingerprint` | Topology fingerprint comparison |
774-
| `mutate` | Graph-level code editing (move/rename/extract) |
775-
| `dark_matter` | Hidden co-change coupling detection |
776-
| `closure` | Minimal-change synthesis for rename/delete |
777-
| `adversarial_review` | Adversarial architecture review |
778-
| `generate_plan` | Agent work planner |
779-
| `get_invariants` | Architectural invariant discovery |
780-
| `bisect_blame` | Architectural git bisect |
781-
| `doc_intent` | Doc-to-code linking |
782-
| `cut_analysis` | Minimum graph cut analysis |
783-
| `annotate_symbol` | Attach persistent notes to symbols |
784-
| `get_annotations` | View stored annotations |
785-
| `relate` | Show relationship between two symbols |
786-
| `search_semantic` | Semantic search by meaning |
787-
| `rules_check` | Plugin DSL governance rules |
788-
| `vuln_map` | Vulnerability report ingestion |
789-
| `vuln_reach` | Vulnerability reachability paths |
790-
| `ingest_trace` | Ingest runtime trace data |
791-
| `runtime_hotspots` | Runtime hotspot analysis |
744+
| `roam_understand` | Full codebase briefing |
745+
| `roam_health` | Health score (0-100) + issues |
746+
| `roam_preflight` | Pre-change safety check |
747+
| `roam_search_symbol` | Find symbols by name |
748+
| `roam_context` | Files-to-read for modifying a symbol |
749+
| `roam_trace` | Dependency path between two symbols |
750+
| `roam_impact` | Blast radius of changing a symbol |
751+
| `roam_file_info` | File skeleton with all definitions |
752+
| `roam_pr_risk` | Risk score for pending changes |
753+
| `roam_breaking_changes` | Detect breaking changes between refs |
754+
| `roam_affected_tests` | Find tests affected by a change |
755+
| `roam_dead_code` | List unreferenced exports |
756+
| `roam_complexity_report` | Per-symbol cognitive complexity |
757+
| `roam_repo_map` | Project skeleton with key symbols |
758+
| `roam_tour` | Auto-generated onboarding guide |
759+
| `roam_diagnose` | Root cause analysis for debugging |
760+
| `roam_visualize` | Generate Mermaid or DOT architecture diagrams |
761+
| `roam_algo` | Algorithm anti-pattern detection with language-aware tips |
762+
| `roam_ws_understand` | Unified multi-repo workspace overview |
763+
| `roam_ws_context` | Cross-repo augmented symbol context |
764+
| `roam_pr_diff` | Structural PR diff: metric deltas, edge analysis, symbol changes |
765+
| `roam_budget_check` | Check changes against architectural budgets |
766+
| `roam_effects` | Side-effect classification (DB writes, network, filesystem) |
767+
| `roam_attest` | Proof-carrying PR attestation with all evidence bundled |
768+
| `roam_capsule_export` | Export sanitized structural graph (no code bodies) |
769+
| `roam_path_coverage` | Find critical untested call paths (entry -> sink) |
770+
| `roam_forecast` | Predict when metrics will exceed thresholds |
771+
| `roam_simulate` | Counterfactual architecture simulator |
772+
| `roam_orchestrate` | Multi-agent swarm partitioning |
773+
| `roam_fingerprint` | Topology fingerprint comparison |
774+
| `roam_mutate` | Graph-level code editing (move/rename/extract) |
775+
| `roam_dark_matter` | Hidden co-change coupling detection |
776+
| `roam_closure` | Minimal-change synthesis for rename/delete |
777+
| `roam_adversarial_review` | Adversarial architecture review |
778+
| `roam_generate_plan` | Agent work planner |
779+
| `roam_get_invariants` | Architectural invariant discovery |
780+
| `roam_bisect_blame` | Architectural git bisect |
781+
| `roam_doc_intent` | Doc-to-code linking |
782+
| `roam_cut_analysis` | Minimum graph cut analysis |
783+
| `roam_annotate_symbol` | Attach persistent notes to symbols |
784+
| `roam_get_annotations` | View stored annotations |
785+
| `roam_relate` | Show relationship between two symbols |
786+
| `roam_search_semantic` | Semantic search by meaning |
787+
| `roam_rules_check` | Plugin DSL governance rules |
788+
| `roam_vuln_map` | Vulnerability report ingestion |
789+
| `roam_vuln_reach` | Vulnerability reachability paths |
790+
| `roam_ingest_trace` | Ingest runtime trace data |
791+
| `roam_runtime_hotspots` | Runtime hotspot analysis |
792+
| `roam_diff` | Blast radius of uncommitted/committed changes |
793+
| `roam_symbol` | Symbol definition, callers, callees, metrics |
794+
| `roam_deps` | File-level import/imported-by relationships |
795+
| `roam_uses` | All consumers of a symbol by edge type |
796+
| `roam_weather` | Code hotspots: churn x complexity ranking |
797+
| `roam_debt` | Hotspot-weighted technical debt prioritization |
798+
| `roam_n1` | Detect N+1 I/O patterns in ORM code |
799+
| `roam_auth_gaps` | Find endpoints missing auth |
800+
| `roam_over_fetch` | Detect models serializing too many fields |
801+
| `roam_missing_index` | Find queries on non-indexed columns |
802+
| `roam_orphan_routes` | Detect dead backend routes |
803+
| `roam_migration_safety` | Detect non-idempotent migrations |
804+
| `roam_api_drift` | Backend/frontend model mismatch detection |
792805

793806
**Resources:** `roam://health` (current health score), `roam://summary` (project overview)
794807

@@ -798,17 +811,17 @@ Core tools in lite mode: `understand`, `health`, `preflight`, `search_symbol`, `
798811
<summary><strong>Claude Code</strong></summary>
799812

800813
```bash
801-
claude mcp add roam -- fastmcp run roam.mcp_server:mcp
814+
claude mcp add roam-code -- roam mcp
802815
```
803816

804817
Or add to `.mcp.json` in your project root:
805818

806819
```json
807820
{
808821
"mcpServers": {
809-
"roam": {
810-
"command": "fastmcp",
811-
"args": ["run", "roam.mcp_server:mcp"]
822+
"roam-code": {
823+
"command": "roam",
824+
"args": ["mcp"]
812825
}
813826
}
814827
}
@@ -824,9 +837,9 @@ Add to your `claude_desktop_config.json`:
824837
```json
825838
{
826839
"mcpServers": {
827-
"roam": {
828-
"command": "fastmcp",
829-
"args": ["run", "roam.mcp_server:mcp"],
840+
"roam-code": {
841+
"command": "roam",
842+
"args": ["mcp"],
830843
"cwd": "/path/to/your/project"
831844
}
832845
}
@@ -843,9 +856,9 @@ Add to `.cursor/mcp.json`:
843856
```json
844857
{
845858
"mcpServers": {
846-
"roam": {
847-
"command": "fastmcp",
848-
"args": ["run", "roam.mcp_server:mcp"]
859+
"roam-code": {
860+
"command": "roam",
861+
"args": ["mcp"]
849862
}
850863
}
851864
}
@@ -861,10 +874,10 @@ Add to `.vscode/mcp.json`:
861874
```json
862875
{
863876
"servers": {
864-
"roam": {
877+
"roam-code": {
865878
"type": "stdio",
866-
"command": "fastmcp",
867-
"args": ["run", "roam.mcp_server:mcp"]
879+
"command": "roam",
880+
"args": ["mcp"]
868881
}
869882
}
870883
}
@@ -1167,7 +1180,7 @@ Roam is **not** a replacement for your linter, LSP, or SonarQube. It fills a dif
11671180
| **Aider repo map** | Tree-sitter + PageRank | Context selection for chat. Roam adds git signals, 95 architecture commands, CI gates, multi-agent orchestration |
11681181
| **CodeScene** | Behavioral code analysis | Commercial SaaS ($20-60k/yr). Roam is free, local, uses peer-reviewed algorithms (Mann-Kendall, NPMI, Personalized PageRank) |
11691182
| **SonarQube** | Code quality + security | Heavy server ($15-45k/yr). Roam's cognitive complexity follows SonarSource spec |
1170-
| **Serena MCP** | LSP-based symbol navigation | 6 MCP tools for navigation. Roam has 48 MCP tools covering architecture, governance, simulation, and orchestration |
1183+
| **Serena MCP** | LSP-based symbol navigation | 6 MCP tools for navigation. Roam has 61 MCP tools covering architecture, governance, simulation, and orchestration |
11711184
| **Repomix / code2prompt** | Codebase packing for LLMs | Flat file packing with no graph intelligence. Roam gives structural queries, not raw file dumps |
11721185
| **Augment Code** | Cloud context engine | Cloud-hosted, enterprise-priced. Roam is 100% local, air-gapped, MIT-licensed |
11731186
| **grep / ripgrep** | Text search | No semantic understanding. Can't distinguish definitions from usage |
@@ -1254,7 +1267,7 @@ roam-code/
12541267
├── src/roam/
12551268
│ ├── __init__.py # Version (from pyproject.toml)
12561269
│ ├── cli.py # Click CLI (95 commands, 7 categories)
1257-
│ ├── mcp_server.py # MCP server (48 tools, 2 resources)
1270+
│ ├── mcp_server.py # MCP server (61 tools, 2 resources)
12581271
│ ├── db/
12591272
│ │ ├── connection.py # SQLite (WAL, pragmas, batched IN)
12601273
│ │ ├── schema.py # Tables, indexes, migrations
@@ -1333,7 +1346,7 @@ roam-code/
13331346
| [tree-sitter-language-pack](https://github.com/nicolo-ribaudo/tree-sitter-language-pack) >= 0.6 | 165+ grammars |
13341347
| [networkx](https://networkx.org/) >= 3.0 | Graph algorithms |
13351348

1336-
Optional: [fastmcp](https://github.com/jlowin/fastmcp) (MCP server)
1349+
Optional: [fastmcp](https://github.com/jlowin/fastmcp) >= 2.0 (MCP server — install with `pip install roam-code[mcp]`)
13371350

13381351
## Roadmap
13391352

llms-install.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Installing roam-code
22

33
roam-code provides instant codebase comprehension for AI coding agents.
4-
55 commands, 22 languages, 100% local, zero API keys.
4+
95 commands, 26 languages, 100% local, zero API keys.
55

66
## Quick install
77

88
```bash
99
pip install roam-code
10+
pip install roam-code[mcp] # optional: MCP server support
1011
```
1112

1213
Or with isolated environments:
@@ -71,4 +72,4 @@ Add to your MCP config:
7172
| `roam context <symbol>` | Files and line ranges to read |
7273
| `roam diff` | Blast radius of uncommitted changes |
7374

74-
Run `roam --help` for all 55 commands.
75+
Run `roam --help` for all 95 commands.

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ Issues = "https://github.com/Cranot/roam-code/issues"
4444
roam = "roam.cli:cli"
4545

4646
[project.optional-dependencies]
47+
mcp = [
48+
"fastmcp>=2.0",
49+
]
4750
dev = [
4851
"pytest>=7.0",
4952
"pytest-xdist>=3.0",

src/roam/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,12 @@
109109
"schema": ("roam.commands.cmd_schema", "schema_cmd"),
110110
"search-semantic": ("roam.commands.cmd_search_semantic", "search_semantic"),
111111
"relate": ("roam.commands.cmd_relate", "relate"),
112+
"mcp": ("roam.mcp_server", "mcp_cmd"),
112113
}
113114

114115
# Command categories for organized --help display
115116
_CATEGORIES = {
116-
"Getting Started": ["index", "init", "config", "understand", "tour", "describe", "minimap", "ws", "schema"],
117+
"Getting Started": ["index", "init", "config", "understand", "tour", "describe", "minimap", "ws", "schema", "mcp"],
117118
"Daily Workflow": ["preflight", "pr-risk", "pr-diff", "attest", "adversarial", "diff", "context", "affected-tests", "diagnose", "digest", "annotate", "annotations", "plan"],
118119
"Codebase Health": ["health", "weather", "debt", "complexity", "algo", "n1", "over-fetch", "missing-index", "alerts", "trend", "fitness", "snapshot", "forecast", "bisect", "ingest-trace", "hotspots"],
119120
"Architecture": ["map", "layers", "clusters", "coupling", "dark-matter", "effects", "cut", "simulate", "orchestrate", "entry-points", "patterns", "safe-zones", "visualize", "x-lang", "fingerprint"],

0 commit comments

Comments
 (0)