Skip to content

feat(mcp): query tools — get_callers/callees/deps, find_path, search_code (T5/T7/T8)#679

Draft
DvirDukhan wants to merge 1 commit into
dvirdukhan/mcp-t4-index-repofrom
dvirdukhan/mcp-t5-t7-t8-query-tools
Draft

feat(mcp): query tools — get_callers/callees/deps, find_path, search_code (T5/T7/T8)#679
DvirDukhan wants to merge 1 commit into
dvirdukhan/mcp-t4-index-repofrom
dvirdukhan/mcp-t5-t7-t8-query-tools

Conversation

@DvirDukhan
Copy link
Copy Markdown
Contributor

Bundles T5 (#653), T7 (#655), and T8 (#656). Stacked on #678#677#676#675#666.

Tools

Tool Direction Backing op
search_code(prefix) prefix_search (FalkorDB fulltext)
get_callers(symbol_id) IN inline Cypher (src)-[:CALLS]->(n)
get_callees(symbol_id) OUT inline Cypher (n)-[:CALLS]->(dest)
get_dependencies(symbol_id, rels=[CALLS, IMPORTS, DEFINES]) OUT multi-rel + dedup
find_path(source_id, dest_id, max_paths=5) find_paths (CALLS-only)

Shared helpers in api/mcp/tools/structural.py: _node_summary (flattens encode_node's {id, labels, properties: {...}} and drops the Searchable label), _coerce_node_id (int or stringified int; rejects bool), _project_arg (returns AsyncGraphQuery).

Tests

tests/mcp/test_query_tools.py — 13 tests, all green against FalkorDB on 6390. Full MCP suite: 25 passed in 23s.

Side fix

Dropped stray tests/mcp/fixtures/sample_project/venv/ that was polluting prefix-search results.

Out of scope

T6 (#654, impact_analysis) — variable-depth Cypher with cycle avoidance, deserves its own PR.

Closes #653, #655, #656.

…code

Bundles T5 (#653), T7 (#655), T8 (#656) into one PR; all three are thin
async wrappers around existing AsyncGraphQuery operations and share the
same _node_summary / _coerce_node_id / _project_arg helpers.

- search_code: prefix search backed by the FalkorDB fulltext index.
  Surfaces flat {id, name, label, file, line} so agents can hand the
  id straight to the navigation tools.
- get_callers / get_callees: incoming / outgoing CALLS edges. The
  shared _neighbors_payload inlines the IN-direction Cypher because
  AsyncGraphQuery.get_neighbors only walks OUT.
- get_dependencies: same machinery, but aggregates a configurable set
  of relations (default CALLS/IMPORTS/DEFINES) and dedups by node id.
- find_path: returns up to N CALLS-only paths between two symbols as
  a node sequence; strips encode_edge entries from the alternating
  [node, edge, ...] list produced by AsyncGraphQuery.find_paths.

Helpers:
- _node_summary flattens the encode_node shape (which nests data under
  'properties' and includes the 'Searchable' fulltext-index label)
  into the {id, name, label, file, line} agents want.
- _coerce_node_id accepts int or stringified-int and rejects bool.

Tests (tests/mcp/test_query_tools.py, 13 tests):
- search_code prefix happy/limit/no-match/serialisability paths.
- get_callees(entrypoint) ⊇ {service}; get_callers(service) ⊇ {entrypoint}.
- get_dependencies includes the CALLS relation.
- Neighbor tools accept string ids; reject garbage.
- find_path(entrypoint → db) ≥ 1; reverse direction returns [];
  max_paths is honored.
- All five tools are registered on the MCP app.

Also drops a stray venv/ that snuck into the fixture directory and
was polluting the prefix-search results.

Closes #653, #655, #656.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 585f8c49-973d-418d-896e-96299eb5daaa

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dvirdukhan/mcp-t5-t7-t8-query-tools

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant