Skip to content

fix: add source titles to MCP graph facts - #383

Merged
hurttlocker merged 1 commit into
hurttlocker:mainfrom
w3lld1:fix/mcp-graph-source-title
Jul 11, 2026
Merged

fix: add source titles to MCP graph facts#383
hurttlocker merged 1 commit into
hurttlocker:mainfrom
w3lld1:fix/mcp-graph-source-title

Conversation

@w3lld1

@w3lld1 w3lld1 commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

What

  • add source_title to MCP graph_explore and graph_impact fact payloads
  • derive titles through the shared search.CitationTitleForResult helper
  • batch-load each memory's source file and section once for the export
  • add MCP regression coverage for the empty-section filename fallback

Why

MCP graph consumers currently receive only the raw source path, while CLI graph JSON exports also expose a human-readable source title. This brings the two graph surfaces into parity without duplicating citation-title logic.

Fixes #381

How

The existing per-export memory lookup now selects both source_file and source_section into a map keyed by memory ID. Each graph fact uses those cached fields with CitationTitleForResult, preserving the existing source filter and avoiding per-fact database queries.

Touched surfaces:

  • internal/mcp/graph_tools.go
  • internal/mcp/graph_tools_test.go

Product behavior changed: yes, additively; MCP graph fact JSON may now include source_title.
Benchmark/eval interpretation changed: no.

Testing

  • go test ./internal/mcp -run 'TestMCPGraphExplore(SourceTitleFallsBackToBaseFilename|BySubject|SourceFilter)' -count=1 -v
  • go test ./internal/mcp -count=1
  • go test ./... -count=1
  • go vet ./...
  • go build ./cmd/cortex/
  • python3 scripts/validate_visualizer_contract.py
  • scripts/connectivity_smoke.sh
  • git diff --check

Risk

Low. The field is additive and omitted when no title can be derived. Existing source filtering and result ordering are unchanged.

AI-assisted contribution note

The implementation and test were AI-assisted. I reviewed the issue requirements, repository contribution rules, source-title helper reuse, query batching, generated diff, commit identity, and all test output listed above.

Checklist

  • Unit tests added/updated
  • Code follows Go conventions (gofmt, go vet)
  • No unrelated changes included
  • Documentation update is not required for this additive payload parity fix

@hurttlocker hurttlocker left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Verified locally: clean build, full internal/mcp suite green. Extending loadMemorySourcesForNodeViews to carry the section in the same batched IN-query was the right instinct — you closed #381 without inheriting the N+1 the CLI path has (#380 is still open if you want to bring the CLI side up to this standard). Same shared CitationTitleForResult path, regression mirrors the CLI test. Two-for-two today — merging.

@hurttlocker
hurttlocker merged commit a462069 into hurttlocker:main Jul 11, 2026
3 of 4 checks passed
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.

MCP graph tools: source_title parity with CLI graph JSON export

2 participants