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