name: kg-mcp description: "This skill should be used when the user asks to expose the project graph as MCP tools, register the graphify MCP server (python -m graphify.serve) in Claude config, says 'graphify mcp 서버', 'MCP로 그래프 쿼리', or invokes /kg-mcp [register|status|unregister]. Configures Claude's .mcp.json so subsequent /kg-query and /kg-orient can call graphify MCP tools instead of loading graph.json directly. Edits user config — requires explicit approval." trigger: /kg-mcp
/kg-mcp — Register graphify MCP Server in Claude Config
Expose the project's graph as MCP tools so other kg skills can query the graph without loading graph.json into the LLM context. The server is the Python module python -m graphify.serve <graph.json> (or the graphify-mcp console script in graphify v0.8.36+) — not a bare CLI flag; --mcp is not a graphify CLI verb. Target graphifyy>=0.8.24 (recommended 0.8.39); the mcp Python package is required — install the dedicated extra uv tool install "graphifyy[mcp]" (or pip install "graphifyy[mcp]"; graphifyy[all] also bundles it), matching graphify's own runtime error guidance.
Activate When
- User asks "graphify mcp 서버", "MCP로 그래프 쿼리", "register graphify mcp"
- User invokes
/kg-mcp [register|status|unregister] - Before running many
/kg-queryoperations on a large graph (MCP avoids reloading graph.json every time) - After
/kg-updateproduces a fresh graph and user wants subsequent queries to use it via MCP
Do Not Activate When
- One-off graph query →
/kg-query(loads graph.json directly, no MCP setup needed) - graph.json doesn't exist →
/kg-updatefirst - User wants Obsidian Canvas visualization →
/kg-canvas(separate output, not MCP) - User wants to merge multiple graphs →
/kg-merge
Preconditions
graphifyCLI v0.8.x installed (which graphify;uv tool install graphifyy). Thegraphify-mcpconsole-script launch form needs>=0.8.36; thepython -m graphify.serveform works on any 0.8.x (incl. the 0.8.24 floor).- Target project has
graphify-out/graph.json(verify mtime per~/.claude/skills/kg/references/architecture.mdfreshness gate) ~/.claude.jsonor project-local.mcp.jsonexists and is writable
MCP tools exposed (by python -m graphify.serve)
Per graphify v0.8.x serve.py. The launch command in .mcp.json (set up by register --apply) runs <python> -m graphify.serve <graph.json>, which exposes the tools below over stdio.
| Tool | Purpose |
|---|---|
query_graph |
BFS/DFS search with token budget (replaces in-context graph.json loading) |
get_node |
Full details for a node by label/ID |
get_neighbors |
Direct neighbors with edge details |
get_community |
All nodes in a community by ID |
god_nodes |
Most connected nodes (anchor concepts) |
graph_stats |
Summary stats (nodes/edges/communities/confidence breakdown) |
shortest_path |
Shortest path between two concepts (used by /kg-ingest Confirmation gate, /kg-connect, /kg-postmortem pattern detection) |
list_prs / get_pr_impact / triage_prs |
PR-dashboard tools (v0.8.x). Need a git/PR context — usually irrelevant to a kg corpus; ignore unless graphing a repo with open PRs. |
Transport (v0.8.34+): stdio is the default (one local process per developer). To share one graph across a team, serve over HTTP — python -m graphify.serve <graph.json> --transport http --host 0.0.0.0 --port 8080 --api-key "$SECRET" — and point each .mcp.json at http://<host>:8080/mcp. Set --host 0.0.0.0 and --api-key together; the default 127.0.0.1 bind is loopback-only. Every query_graph call is logged to ~/.cache/graphify-queries.log (disable with GRAPHIFY_QUERY_LOG_DISABLE=1). Note: /kg-mcp register --apply only emits the stdio command/args entry — the HTTP client entry needs a url/http-transport shape, so for HTTP you hand-edit .mcp.json to point at http://<host>:8080/mcp (the server side is real, but register does not wire it up).
Subcommands
/kg-mcp (no subcommand) — defaults to status
Bare invocation /kg-mcp (without register|status|unregister) is treated as /kg-mcp status (read-only inspection). Rationale: status is the only read-only subcommand; defaulting to it lets users inspect current registration with minimal typing. Mutations are always blocked from bare invocation by the existing --scope + --apply Authority gate.
When defaulting to status, prepend this note to the output:
Note:
/kg-mcp(no subcommand) maps tostatus(read-only). Mutations require explicitregister --scope <user|project> --applyorunregister --scope <user|project> --apply.
/kg-mcp register --scope <user|project> [--apply]
- Detect target
graph.json(cwd or arg). - Print the proposed MCP server entry to add to
.mcp.json. For auv tool installof graphify (recommended), use the self-resolvinggraphify-mcpconsole script (v0.8.36+) — its shebang carries the right venv interpreter, so you don't have to locate apythonthat can import graphify:
NOTE (graphify v0.8.x):{ "mcpServers": { "graphify-<project-slug>": { "command": "graphify-mcp", "args": ["<absolute-path-to-graph.json>"] } } }graphify-mcplaunchesgraphify.serve; there is no bare--mcpCLI verb. Thegraphify-mcpconsole script requires graphify>=0.8.36— on the documented>=0.8.24floor up to0.8.35it does not exist, so on those versions (or any install wheregraphify-mcpis not on PATH) use the<python> -m graphify.serveform instead. That alternative form{"command": "<python>", "args": ["-m", "graphify.serve", "<graph.json>"]}works only when<python>is the exact interpreter that canimport graphify— for auv tool installthat is NOT system python (graphify lives in a uv-managed venv;system python3 -c "import graphify"→ModuleNotFoundError). Find it via thegraphify-mcpshebang oruv tool dir, or just prefer the console script. Themcppackage is required:uv tool install "graphifyy[mcp]"(orpip install "graphifyy[mcp]";graphifyy[all]bundles it). Verify withgraphify-mcp --help, or<that-python> -c "import mcp.server.stdio"before writing config — NOTimport graphify.serve, which succeeds even whenmcpis absent (serve.py importsmcplazily) and then the server dies at runtime withImportError: mcp not installed. Run: pip install "graphifyy[mcp]". - Without
--apply: print the proposal and STOP. Do not edit any file. Do not interpret a follow-up user "yes"/"go" as approval. The user must re-issue the command with--applyexplicitly added to the same scope. This prevents an LLM-mediated escape hatch around the Authority gate. - With
--apply: edit.mcp.json(user scope =~/.claude.json, project scope =<cwd>/.mcp.json). --scopeis required, no default. If the user omits--scope, stop and ask which scope; do not assumeprojectoruser. User-scope edits affect every Claude session, so silently defaulting either way is wrong.- Report which MCP tools are now available; instruct user to restart Claude Code session for MCP server to load.
/kg-mcp status
- Inspect both
~/.claude.jsonand<cwd>/.mcp.jsonforgraphify-*MCP server entries - Report:
- Whether
graphify-*MCP servers are registered - For each, the graph.json path they point to
- Freshness of each pointed-to graph.json (mtime)
- Whether
- Outdated-registration sensor (v0.5.5) — scan project for graphs newer than the registered one:
- Scan scope: cwd recursively, EXCLUDE these dirs:
node_modules/,.git/,__pycache__/,*.egg-info/,build/,dist/,vendor/,vendored/,tmp/,.tmp/,_archive/,_examples/,_fixtures/ - Priority order when multiple graphs exist:
graphify-out/merged-graph.jsonat project root (cross-corpus union — most generally useful)- Any
*/graphify-out/graph.json(per-corpus graphs)
- If a candidate graph has mtime newer than the currently-registered one by ≥ 5 minutes, emit warning:
⚠ Outdated registration: Registered: <path> (mtime: <ts>) Newer available: <newer-path> (mtime: <ts>) — type: merged | per-corpus Suggested: /kg-mcp register --scope <X> --apply (with new path) - 5-minute grace prevents false positives from filesystem time skew or routine re-runs.
- Scan scope: cwd recursively, EXCLUDE these dirs:
- Read-only — never edits.
/kg-mcp unregister [--scope user|project] [--apply]
- Show which
graphify-*entries exist in target.mcp.json - Without
--apply: stop and confirm. - With
--apply: remove the entry, preserve other MCP servers.
Output Contract
MCP register result: PASS | REFUSED | FAIL | (status: see status block)
Mode: register | status | unregister
Target config: ~/.claude.json | <cwd>/.mcp.json
Target graph: <absolute path to graph.json>
Graph freshness: FRESH | STALE (<N days>)
Proposed/current MCP servers entry — graphify >=0.8.36 with graphify-mcp on PATH -> command = graphify-mcp (as shown); graphify 0.8.24-0.8.35 or graphify-mcp not on PATH -> command = the interpreter that can import graphify, args = ["-m", "graphify.serve", "<graph.json>"]:
{ "graphify-<slug>": { "command": "graphify-mcp", "args": ["<abs-path-to-graph.json>"] } }
Tools that will be / are exposed:
- query_graph, get_node, get_neighbors, get_community, god_nodes, graph_stats, shortest_path
Action taken:
- Without --apply: nothing written; awaiting approval
- With --apply: <added | removed | already-present | not-present>
Restart required: yes | no
Approval needed: yes (without --apply) | no (status mode)
Confidence: high | medium | low
Caveats:
- <stale graph | other MCP servers in same config | none>
Next command:
- /kg-mcp register --scope <user|project> --apply (after reviewing proposal; --scope required)
- /kg-query "<question>" (after restart, will auto-use MCP if available)
Exceptions and Escalation
- graphify CLI not found → stop, suggest
uv tool install graphifyy(recommended overpip). - Target
graph.jsonmissing → suggest/kg-updatefirst; do not register a non-existent path. - Target
graph.jsonis stale (≥7d) → warn and ask user; do not block, but Caveats must mention. .mcp.jsonis malformed JSON → stop, do not attempt repair. Report exact parse error and require user fix.- Without
--applyflag → never edit config; only print the proposal. A subsequent user "yes"/"approve"/"go" message is not a substitute for--apply. The user must re-issue the same/kg-mcpcommand with--applyexplicitly present. --scopeomission → stop and ask. There is no default scope; user-scope and project-scope have very different blast radii.- Editing user-scope
~/.claude.jsonaffects all sessions → require both--scope userAND--applyexplicit per Authority Matrix: user config edits = Human approval. - Never delete other MCP servers when unregistering — only remove
graphify-*entries.
Authority
Per ~/.claude/skills/kg/references/authority-matrix.md:
.mcp.jsonedits = Human authority (explicit--applyflag required)statusmode = LLM (read-only)- This skill never edits
wiki/orgraphify-out/
Quality Gates
Before final answer:
- graphify CLI verified installed
- Target graph.json verified to exist (register/unregister modes)
- Without --apply, no file modified
- With --apply, only
graphify-*entries touched (other MCP servers preserved) - Restart-required note when config changed
- Stale graph noted in Caveats