* Return `defs` with `projectPath` marked `required` in each tool's inputSchema. * * Used for the NO-DEFAULT-PROJECT tool surface (issue #993): when the MCP server * has no default project to fall back to — a gateway server started outside any * repo, or a monorepo root whose `.codegraph/` index
(defs: ToolDefinition[])
| 1268 | * `required` list (status/files) gains `['projectPath']`. |
| 1269 | */ |
| 1270 | function withRequiredProjectPath(defs: ToolDefinition[]): ToolDefinition[] { |
| 1271 | return defs.map((tool) => { |
| 1272 | if (!tool.inputSchema.properties.projectPath) return tool; |
| 1273 | const required = tool.inputSchema.required ?? []; |
| 1274 | if (required.includes('projectPath')) return tool; |
| 1275 | return { |
| 1276 | ...tool, |
| 1277 | inputSchema: { ...tool.inputSchema, required: [...required, 'projectPath'] }, |
| 1278 | }; |
| 1279 | }); |
| 1280 | } |
| 1281 | |
| 1282 | /** |
| 1283 | * Allowlist-filtered tool definitions WITHOUT an engine — the static surface the |