MCPcopy Create free account
hub / github.com/holaboss-ai/holaOS / validateModulePath

Function validateModulePath

runtime/api-server/src/workspace-tool-loader.ts:90–107  ·  view source on GitHub ↗
(modulePath: string, toolId: string)

Source from the content-addressed store, hash-verified

88}
89
90function 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
109function ensurePathInsideWorkspace(workspaceDir: string, candidatePath: string, toolId: string): string {
110 const workspaceRoot = path.resolve(workspaceDir);

Callers 1

Calls 1

errFunction · 0.70

Tested by

no test coverage detected