src/mcp/ · server-instructions.ts 是主 agent 指引的單一來源MCP server 把 CodeGraph 暴露給 agent。兩個關鍵設計:預設只列 codegraph_explore(其它 7 個工具可用但不列出),以及使用指引直接塞進 MCP initialize response——主 agent 不用看文件就知道怎麼用。sub-agent 與非 MCP harness 看不到那個 response,所以安裝器另寫 marker-fenced 段落進 instructions 檔(見 installer)。
內容重點:結構性問題直接答(圖就是 pre-built 索引,grep/read 是重複做工);codegraph_explore 幾乎什麼都能用;相信結果別再 grep 驗證;編輯後看 staleness banner。README 說「The exact text is src/mcp/server-instructions.ts — the single source of truth for the main agent」,所以它必須與 user-facing tool guidance 保持同步(CLAUDE.md 特別註記)。
tools.ts 定義工具清單與 CODEGRAPH_MCP_TOOLS allowlist 邏輯;engine.ts 組 explore 的答案(用 ContextBuilder + traverser)。7 個未列工具回的東西已內嵌在 explore 回應裡。projectPath 參數讓「server 自己 root 沒有索引」時也能查別的專案。
explore 回應前檢查 CodeGraph.getPendingFiles()(見 main):引用到 pending 檔 → 前置 ⚠️ banner 叫 agent 直接 Read;沒引用的 pending 檔 → 小 footer。已用 Claude Code 驗證 agent 會照做。