feat(mcp): index_repo tool (T4 #652)#678
Draft
DvirDukhan wants to merge 1 commit into
Draft
Conversation
First real MCP tool. Wraps the existing Project / SourceAnalyzer
pipeline so AI agents can call `index_repo(path_or_url, branch)` over
stdio to populate code-graph for a repo.
- `api/mcp/tools/structural.py` (NEW) — registers `index_repo` on
the shared FastMCP app. Accepts local paths or git URLs;
auto-detects branch from local git checkouts via T17's
`detect_branch`; honors `ALLOWED_ANALYSIS_DIR` for sandboxing.
Non-git folders are handled by driving SourceAnalyzer directly
(Project requires a git repo).
- `api/mcp/tools/__init__.py` (NEW) — package marker; importing it
registers every tool module's `@app.tool()` decorators.
- `api/mcp/server.py` — imports tools at module load so both direct
`from api.mcp.server import app` and `cgraph-mcp` stdio entry
point see the same tool list.
- `tests/mcp/test_index_repo.py` (NEW) — 5 tests: local-path happy
path, missing-path error, ALLOWED_ANALYSIS_DIR sandboxing,
in-process app registration, JSON serialisability.
- `tests/mcp/test_scaffold.py` — replaced the "zero tools"
assertion with a presence check for `index_repo` so it stays
stable as T5-T8 / T11 add more tools.
Return shape:
{project_name, branch, graph_name, num_nodes, num_edges,
languages_detected, mode}
`incremental` parameter is accepted now and forwarded once T18
lands; the current full-reindex path ignores it and always returns
`mode="full"`.
All 8 tests pass against FalkorDB on 6390.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #652.
Stacked on #677 (T3). First real MCP tool — agents can call
index_repo(path_or_url, branch)over stdio.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com