MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / withIndexVersionNotice

Method withIndexVersionNotice

src/mcp/tools.ts:3022–3049  ·  view source on GitHub ↗

* Warn this MCP client once for each selected project whose persisted * extraction version predates the running engine. The state belongs to the * client session, never this shared handler: one daemon serves many clients.

(
    result: ToolResult,
    projectPath: string | undefined,
    state: IndexVersionWarningState | undefined,
  )

Source from the content-addressed store, hash-verified

3020 * client session, never this shared handler: one daemon serves many clients.
3021 */
3022 private withIndexVersionNotice(
3023 result: ToolResult,
3024 projectPath: string | undefined,
3025 state: IndexVersionWarningState | undefined,
3026 ): ToolResult {
3027 if (!state || result.isError) return result;
3028 const [first, ...rest] = result.content;
3029 if (!first || first.type !== 'text') return result;
3030
3031 let cg: CodeGraph;
3032 let root: string;
3033 try {
3034 cg = this.getCodeGraph(projectPath);
3035 if (!cg.isIndexStale()) return result;
3036 root = cg.getProjectRoot();
3037 } catch {
3038 // No initialized project (or a project that cannot be opened) has no
3039 // trustworthy build metadata to report and must not consume a warning.
3040 return result;
3041 }
3042 if (!state.claim(root)) return result;
3043
3044 const warning = formatIndexVersionWarning(cg.getIndexBuildInfo());
3045 return {
3046 ...result,
3047 content: [{ type: 'text', text: `${warning}\n\n${first.text}` }, ...rest],
3048 };
3049 }
3050
3051 /**
3052 * Execute a tool by name.

Callers 1

executeMethod · 0.95

Calls 6

getCodeGraphMethod · 0.95
isIndexStaleMethod · 0.80
claimMethod · 0.80
getIndexBuildInfoMethod · 0.80
getProjectRootMethod · 0.65

Tested by

no test coverage detected