Skip to content

Merge/read source mcp tool#1842

Open
kevinoldching wants to merge 2 commits into
Graphify-Labs:v8from
kevinoldching:merge/read-source-mcp-tool
Open

Merge/read source mcp tool#1842
kevinoldching wants to merge 2 commits into
Graphify-Labs:v8from
kevinoldching:merge/read-source-mcp-tool

Conversation

@kevinoldching

Copy link
Copy Markdown

Add read_source MCP tool to read original source via shared server.

ningguoqiang added 2 commits July 10, 2026 16:50
…red server

The shared HTTP MCP server exposed only the graph.json index — graph queries
returned a source_file + source_location pointer but no file content, so
clients had to fall back to a local checkout. read_source makes a single
shared deployment serve both query and read-original.

- read_source tool: node label (resolves source_file + source_location,
  context window) or repo-relative file + optional start/end range.
- Core logic in module-level _read_source_slice (unit-testable without mcp).
- New --source-root flag (env GRAPHIFY_SOURCE_ROOT) anchors repo-relative
  source_file paths for containerised deployments.
- Security (F-010): reject absolute paths; enforce resolve() containment;
  sanitize_label every line; hard cap 500 lines / 64 KiB.
- 10 new tests in tests/test_serve.py.
Resolved conflicts between v8's multi-project context cache (_ctx_cache)
and feat branch's _source_root inference. Both features are preserved:
- v8's per-graph context cache and hot-reload infrastructure
- feat's read_source tool with source_root inference and path traversal protection

All 90 tests pass including 10 read_source-specific tests.
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