Skip to content

feat(serve): optional project_path for multi-project MCP serving#1594

Closed
joanfgarcia wants to merge 1 commit into
Graphify-Labs:v8from
joanfgarcia:feat/multi-project-mcp
Closed

feat(serve): optional project_path for multi-project MCP serving#1594
joanfgarcia wants to merge 1 commit into
Graphify-Labs:v8from
joanfgarcia:feat/multi-project-mcp

Conversation

@joanfgarcia

Copy link
Copy Markdown
Contributor

Add an optional project_path to every MCP tool so one server process can answer against many projects. Omitted -> the server's default graph (fully backward-compatible); an absolute project_path -> that project's <GRAPHIFY_OUT>/graph.json, routed per call.

Implementation (all in _build_server):

  • _ctx_cache + _load_ctx(): per-graph context cache with mtime+size hot-reload, unified across the default graph and every project graph. Unlike _load_graph it raises instead of sys.exit on a bad file.
  • _resolve_graph_path()/_select_graph(): map project_path to a graph.json and rebind G/communities/active_graph_path per call. No hot-path lock: select+handler run in one synchronous span of the call_tool coroutine.
  • Tolerant startup: serve with no default graph (pure multi-project mode) instead of exiting; a bad project_path is a tool error, not a crash.
  • project_path injected as an optional (non-required) field on all tools.

Tests: 3 new HTTP-transport tests (optional-on-every-tool, routing, bad-path-no-crash). Full serve suite green (91 passed).

Add an optional project_path to every MCP tool so one server process can
answer against many projects. Omitted -> the server's default graph (fully
backward-compatible); an absolute project_path -> that project's
<GRAPHIFY_OUT>/graph.json, routed per call.

Implementation (all in _build_server):
- _ctx_cache + _load_ctx(): per-graph context cache with mtime+size
  hot-reload, unified across the default graph and every project graph.
  Unlike _load_graph it raises instead of sys.exit on a bad file.
- _resolve_graph_path()/_select_graph(): map project_path to a graph.json
  and rebind G/communities/active_graph_path per call. No hot-path lock:
  select+handler run in one synchronous span of the call_tool coroutine.
- Tolerant startup: serve with no default graph (pure multi-project mode)
  instead of exiting; a bad project_path is a tool error, not a crash.
- project_path injected as an optional (non-required) field on all tools.

Tests: 3 new HTTP-transport tests (optional-on-every-tool, routing,
bad-path-no-crash). Full serve suite green (91 passed).
@safishamsi

Copy link
Copy Markdown
Collaborator

Merged into v8 as 9e7fbcb (your authorship). Clean, additive, and backward-compatible — omitting project_path is byte-for-byte the old behavior; the per-path lazy cache with mtime+size hot-reload and tool-error-on-missing (vs process exit) are the right calls. serve tests (93) + full suite 2800 green. Only conflict was the CHANGELOG (resolved, kept your entry). Ships next release.

@safishamsi safishamsi closed this Jul 2, 2026
safishamsi added a commit that referenced this pull request Jul 2, 2026
Two 0.9.4 regressions (CLI cross-file indirect_call, stale community labels on
re-cluster), the case-folding god-node fix (#1581), ~15 language extractor
fixes (Ruby/Groovy/Elixir/Fortran/Rust/Julia/SystemVerilog/Scala/PowerShell/
ObjC/PHP/C#/C++/Swift), merge-graphs mixed-type handling (#1606), Swift
singleton-into-local resolution (#1604), Homebrew python@ shebang (#1586),
hooks foreground-stall perf (#1601), serve query stopwords (#1597) and
multi-project MCP serving (#1594), plus JSON-loading hardening, dedup collision
warning, and Windows hook worker limit.

Built wheel validated in a clean venv: CLI reports 0.9.5, import resolves to the
installed package, the case-folding and Swift-singleton fixes verified, and a
real `graphify extract` produces indirect_call + inherits edges end-to-end.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants