* 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[])
| 764 | * `required` list (status/files) gains `['projectPath']`. |
| 765 | */ |
| 766 | function withRequiredProjectPath(defs: ToolDefinition[]): ToolDefinition[] { |
| 767 | return defs.map((tool) => { |
| 768 | if (!tool.inputSchema.properties.projectPath) return tool; |
| 769 | const required = tool.inputSchema.required ?? []; |
| 770 | if (required.includes('projectPath')) return tool; |
| 771 | return { |
| 772 | ...tool, |
| 773 | inputSchema: { ...tool.inputSchema, required: [...required, 'projectPath'] }, |
| 774 | }; |
| 775 | }); |
| 776 | } |
| 777 | |
| 778 | /** |
| 779 | * Allowlist-filtered tool definitions WITHOUT an engine — the static surface the |