MCP-T13 + T14: cgraph init-agent + Docker dual-mode#683
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR introduces MCP (Model Context Protocol) agent guidance by bundling structured templates, a bootstrapping CLI command ( ChangesMCP Agent Guidance Bundle
🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
5e376e6 to
ead5047
Compare
a18854b to
113ba5c
Compare
ead5047 to
de11c6a
Compare
113ba5c to
e2c504e
Compare
de11c6a to
fec4bac
Compare
e2c504e to
e22b735
Compare
fec4bac to
e14f7f9
Compare
e22b735 to
5da78b5
Compare
There was a problem hiding this comment.
Pull request overview
Adds end-user/agent onboarding for the MCP server and enables running the same Docker image in either web or MCP-stdio mode, improving agent usability and deployment ergonomics.
Changes:
- Introduces
cgraph init-agentto write bundled agent guidance templates (CLAUDE.md,.cursorrules) into the current directory. - Adds Docker “dual-mode” startup via
CGRAPH_MODE=web|mcpwith a composecode-graph-mcpprofile/service for MCP stdio. - Updates docs and adds tests + a smoke script for MCP setup/verification.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
api/cli.py |
Adds init-agent CLI command to copy bundled guidance templates into CWD. |
api/mcp/templates/claude_mcp_section.md |
Provides canonical MCP tool guidance for Claude-style agent instructions. |
api/mcp/templates/cursorrules.template |
Provides Cursor rules template for tool selection/usage. |
tests/mcp/test_init_agent.py |
Adds CliRunner tests covering write/refuse-overwrite/force-overwrite and package-data presence. |
pyproject.toml |
Ensures MCP templates ship as package data (api.mcp/templates/*). |
start.sh |
Dispatches container startup between web and MCP stdio mode using CGRAPH_MODE. |
docker-compose.yml |
Adds an opt-in code-graph-mcp service under the mcp profile for stdio MCP. |
README.md |
Documents MCP server usage and Docker dual-mode quickstarts. |
scripts/mcp_smoke.py |
Adds an end-to-end stdio smoke test for tool availability and basic flows. |
AGENTS.md |
Adds agent-focused MCP section and points to cgraph init-agent. |
Comments suppressed due to low confidence (1)
start.sh:12
- In
CGRAPH_MODE=mcp, anything written to stdout beforecgraph-mcpstarts can corrupt the MCP stdio transport. The localredis-server ... | cat &pipeline currently writes its logs to stdout, which can break MCP whenFALKORDB_HOSTis localhost/127.0.0.x.
# Start FalkorDB Redis server in background only if using a local address (not an external instance)
if [ "${FALKORDB_HOST}" = "localhost" ] || [[ "${FALKORDB_HOST}" =~ ^127\.0\.0\.[0-9]+$ ]]; then
redis-server --loadmodule /var/lib/falkordb/bin/falkordb.so | cat &
fi
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e14f7f9 to
d6bfbde
Compare
5da78b5 to
389ca49
Compare
T13 — agent guidance bundle:
- Add `api/mcp/templates/` shipped as package data (claude_mcp_section.md,
cursorrules.template) with the canonical 8-tool MCP guidance.
- Add `cgraph init-agent [--force]` Typer command that drops
CLAUDE.md and .cursorrules into CWD.
- Update AGENTS.md with the MCP tool table and env-var reference.
T14 — packaging / image dual-mode:
- `start.sh` dispatches on `CGRAPH_MODE` env var (web|mcp). Default
(web) preserves the existing FastAPI behaviour; mcp execs cgraph-mcp.
- `docker-compose.yml` gains an opt-in `code-graph-mcp` service under
the `mcp` profile for stdio attach.
- README quickstart section for both `claude mcp add-json` registration
and Docker compose profile usage.
Tests: 4 new (CliRunner against tmp_path); MCP suite green at 61 passed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Added scripts/mcp_smoke.py — drives cgraph-mcp over real stdio (mcp
SDK ClientSession + StdioServerParameters) and exercises tool
listing, index_repo, search_code, get_callers, impact_analysis.
Findings folded back into claude_mcp_section.md:
- index_repo takes path_or_url (not path) and derives project name
from the folder/URL — agents must read it back from the response.
- Collection-returning tools land their array in
structuredContent.result, not under a {results: [...]} wrapper.
Smoke result on api/ subgraph: 8 tools listed, 6324 nodes / 6228
edges indexed, all calls returned expected payloads.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The MCP surface is the deterministic structural set — the GraphRAG `ask` tool was dropped (it remains available on the HTTP /api/chat path), and get_callers/get_callees/get_dependencies were consolidated into a single `get_neighbors(relation, direction)` with `get_file_neighbors` and `find_symbol` added. Update AGENTS.md, README.md, and the init-agent templates (claude_mcp_section.md, cursorrules.template) to the seven registered tools: index_repo, search_code, find_symbol, get_neighbors, get_file_neighbors, impact_analysis, find_path. Fix scripts/mcp_smoke.py so its expected tool set and the tools it exercises match (search_code now takes `query`, callers come from get_neighbors direction=IN). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
389ca49 to
d5deee2
Compare
- smoke: resolve a real symbol_id via find_symbol before exercising get_neighbors/impact_analysis (search_code returns FILE hits with file_id, never a symbol id, so the previous hits[0]["id"] was always None and the symbol-level tools were never actually tested) - test_init_agent: drop unused `os` import - README: use the real distribution name `falkordb-code-graph` in the MCP quickstart (matches pyproject.toml + earlier install section) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Prerequisites (merge order)
Merge in order — this PR is stacked on:
index_repo(T4)impact_analysis(T6)ask(T9/T10/T11)Base: #682.
MCP-T13 + T14 — agent guidance bundle & Docker dual-mode
Stacked on #682 (T12 auto-init). Closes #661 and #662.
T13 —
cgraph init-agentTwo canonical guidance files now ship as package data under
api/mcp/templates/:claude_mcp_section.md— full 8-tool table + rules of thumb(start with
search_code; prefer structural tools overask;run
impact_analysisbefore refactoring).cursorrules.template— Cursor-flavoured tool-selection rules.New Typer command drops them into the current directory:
AGENTS.mdupdated with the MCP section pointing at this command andthe supported env vars (
CODE_GRAPH_AUTO_INDEX,CGRAPH_MODE).T14 — Dockerised dual-mode
Same image now runs either the FastAPI web app or the MCP stdio
server based on
CGRAPH_MODE:start.shdispatches onCGRAPH_MODE=web|mcp.docker-compose.ymlgains an opt-in
code-graph-mcpservice guarded by themcpprofile (no impact on the default
up). README quickstart coversboth
claude mcp add-jsonand the Docker path.Tests
tests/mcp/test_init_agent.py(write,refuse-overwrite, force-overwrite, package-data sanity).
bash -n start.shclean.Followups
non-trivial and out of scope for this PR.
Summary by CodeRabbit
New Features
cgraph init-agentCLI command to generate agent guidance filesDocumentation
Tests