(modulePath: string, toolId: string)
| 88 | } |
| 89 | |
| 90 | function validateModulePath(modulePath: string, toolId: string): string[] { |
| 91 | if (!modulePath.startsWith("tools.")) { |
| 92 | err({ |
| 93 | code: "workspace_mcp_catalog_entry_invalid", |
| 94 | path: `mcp_registry.catalog.${toolId}.module_path`, |
| 95 | message: "workspace local tool modules must be under 'tools.'" |
| 96 | }); |
| 97 | } |
| 98 | const parts = modulePath.split("."); |
| 99 | if (!parts.every((part) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(part))) { |
| 100 | err({ |
| 101 | code: "workspace_mcp_catalog_entry_invalid", |
| 102 | path: `mcp_registry.catalog.${toolId}.module_path`, |
| 103 | message: `module path '${modulePath}' is not a valid dotted module` |
| 104 | }); |
| 105 | } |
| 106 | return parts; |
| 107 | } |
| 108 | |
| 109 | function ensurePathInsideWorkspace(workspaceDir: string, candidatePath: string, toolId: string): string { |
| 110 | const workspaceRoot = path.resolve(workspaceDir); |
no test coverage detected