Skip to content

Commit dc56349

Browse files
committed
feat(mcp): codegraph_review_context — structured PR-review context from a diff
Adds a new MCP tool that takes a unified diff and returns structured review context for an LLM-driven PR reviewer. Codegraph becomes a substrate for Greptile/CodeRabbit-style products without itself doing the synthesis. ## What it returns Per changed file: - status (added / modified / deleted / renamed) - hunks (line ranges) - affected symbols (line-range overlap with hunks) - tests covering the file (via tests-edges; graceful no-op if absent) Per affected symbol: - signature, docstring - top-N callers, top-N callees - impact-radius node count ## Components - src/review/diff-parser.ts: pure unified-diff parser - src/review/index.ts: buildReviewContext + co-change warnings - src/index.ts: CodeGraph.buildReviewContext public API - src/mcp/tools/review-context.ts: ToolModule (post-colbymchenry#117 form) - src/mcp/tools.ts: handleReviewContext + serializeReviewContextWithinCap (progressive-trim JSON serializer that keeps output <= MAX_OUTPUT_LENGTH while preserving JSON parseability) - __tests__/review-context.test.ts: 25 tests Output is JSON; the LLM consumer does the synthesis. This is the post-colbymchenry#117 (per-tool MCP registry) form — the original PR's case-switch dispatch is replaced by a ToolModule entry plus a 'handleReviewContext' HandlerKey. Tests that exercise co-change warnings include a graceful inline ALTER TABLE for commit_count, since that column lands with colbymchenry#112's centrality+churn migration. After colbymchenry#112 lands the ALTER becomes a no-op (column already exists).
1 parent 7a9b997 commit dc56349

9 files changed

Lines changed: 1361 additions & 2 deletions

File tree

__tests__/mcp-tool-registry.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('MCP tool registry — single source of truth', () => {
3737
expect(fromExport).toEqual(fromRegistry);
3838
});
3939

40-
it('all 9 main-line tools are registered (regression guard)', () => {
40+
it('all 10 main-line tools are registered (regression guard)', () => {
4141
const expected = [
4242
'codegraph_callees',
4343
'codegraph_callers',
@@ -46,6 +46,7 @@ describe('MCP tool registry — single source of truth', () => {
4646
'codegraph_files',
4747
'codegraph_impact',
4848
'codegraph_node',
49+
'codegraph_review_context',
4950
'codegraph_search',
5051
'codegraph_status',
5152
];

0 commit comments

Comments
 (0)