Skip to content

fix(server): thread graph_rel_types through the mcp kb_context tool - #722

Merged
plind-junior merged 2 commits into
vouchdev:testfrom
Yurii214:fix/kb-context-graph-rel-types
Jul 31, 2026
Merged

fix(server): thread graph_rel_types through the mcp kb_context tool#722
plind-junior merged 2 commits into
vouchdev:testfrom
Yurii214:fix/kb-context-graph-rel-types

Conversation

@Yurii214

Copy link
Copy Markdown
Contributor

summary

the mcp kb_context tool exposes the graph-expansion knobs expand_graph / graph_depth / graph_limit but drops graph_rel_types, which the jsonl _h_context handler threads and build_context_pack fully supports (context.pygraph.graph_neighbors_for_seeds(..., rel_types=...)).

so an mcp agent — claude code / cursor / codex, the primary way vouch is consumed — can graph-expand a context pack and tune its depth/breadth, but cannot restrict which relation types the walk follows. expand_graph=true pulls neighbors across every relation type (contradicts, supersedes, references, …) with no way to scope to, e.g., only references. a jsonl/http /rpc client can. the sibling kb_neighbors tool already exposes rel_types on mcp, so relation-type filtering is a first-class mcp capability everywhere except context-pack graph expansion.

this is the same surface-drift class as the kb_export exclude fix: pr #185 added graph_rel_types to build_context_pack and the jsonl handler but its mcp-tool hunk never threaded it.

fix

add the optional graph_rel_types: list[str] | None param to kb_context and thread it into build_context_pack, mirroring _h_context.

test

test_kb_context_mcp_honors_graph_rel_types (in tests/test_graph.py) builds a claim with a references edge to auth and a blocks edge to risk, then calls the mcp tool with graph_rel_types=["references"] and asserts auth is included and risk is filtered out. it fails on the current code (TypeError: unexpected keyword argument 'graph_rel_types') and passes with the fix.

validation

mypy src (117 files, no issues), ruff check on the touched files, and the graph / context / capabilities / server-tool-surface / jsonl-server-surface suites all pass locally.

the mcp kb_context tool exposes expand_graph/graph_depth/graph_limit but
drops graph_rel_types, which the jsonl _h_context handler threads and
build_context_pack supports. so an mcp agent — the primary vouch client —
can graph-expand a context pack but cannot scope the walk to specific
relation types, unlike a jsonl/http client (and unlike the kb_neighbors
tool, which does expose rel_types on mcp). thread it, mirroring _h_context.
@Yurii214
Yurii214 requested a review from plind-junior as a code owner July 31, 2026 16:19
@github-actions github-actions Bot added mcp mcp, jsonl, and http surfaces retrieval context, search, synthesis, and evaluation tests tests and fixtures size: XS less than 50 changed non-doc lines labels Jul 31, 2026
@plind-junior
plind-junior merged commit 0530942 into vouchdev:test Jul 31, 2026
8 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

diff coverage: n/a — this PR changes no python under src/vouch/, so there is nothing for the gate to measure.

@github-actions github-actions Bot added the ci: passing ci is green label Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci: passing ci is green mcp mcp, jsonl, and http surfaces retrieval context, search, synthesis, and evaluation size: XS less than 50 changed non-doc lines tests tests and fixtures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants