Skip to content

feat: add get graph context retrieval loop#68

Open
maehwasoo wants to merge 4 commits intomainfrom
feat/graph-rag-retrieval-loop
Open

feat: add get graph context retrieval loop#68
maehwasoo wants to merge 4 commits intomainfrom
feat/graph-rag-retrieval-loop

Conversation

@maehwasoo
Copy link
Copy Markdown
Owner

What

  • Add a new MCP read tool get_graph_context that runs a GraphRAG-style retrieval loop (semantic seeds, bounded typed-link expansion, and curated snippets) in one call.
  • Register the new tool in the MCP server runtime and expose structured output with seeds, graph nodes/edges, and ranked context notes.
  • Add HTTP integration tests for scoped outgoing expansion and optional incoming backrefs (include_backrefs=true).
  • Update docs and skill metadata to include get_graph_context across tool references and workflow guidance.

Why

How

  • Implement packages/mcp/src/tools/getGraphContext.ts with query embedding, seed selection, hop-bounded typed-link traversal (max_hops), relation filtering (rels), scope filtering (path_prefix), and deterministic ranking.
  • Support optional incoming expansion using typed-link backrefs when include_backrefs=true.
  • Add tests in packages/mcp/test/httpTools.getGraphContext.test.ts and keep docs/tool-list consistency green.
  • Validation run: pnpm format:check, pnpm lint, pnpm typecheck, pnpm typecheck:repo, pnpm test.

@maehwasoo maehwasoo self-assigned this Feb 9, 2026
@github-actions github-actions bot added docs Improvements or additions to documentation mcp MCP server labels Feb 9, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 20541681eb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +421 to +425
outgoingFollowed += 1;

const resolved = resolveNotePathsByWikilinkTarget(
deps.db,
link.toTarget,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Count outgoing edges, not just links, for max_links_per_note

The tool promises max_links_per_note as a cap on typed-link edges followed per note, but outgoingFollowed is incremented once per typed-link before resolving targets. Since resolveNotePathsByWikilinkTarget can return multiple paths for a single typed link, one link can emit several edges and exceed max_links_per_note without triggering truncation. This means callers relying on the edge cap can receive many more outgoing edges than requested when targets are ambiguous or multiply-resolved.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex
Updated get_graph_context so max_links_per_note now caps emitted outgoing edges(including multi-resolve cases), added a regression test, and pushed the fix. Re-review please

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

Labels

docs Improvements or additions to documentation mcp MCP server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: GraphRAG retrieval loop (semantic seed + typed-links expansion)

1 participant