MCPcopy Index your code
hub / github.com/anus-dev/ANUS / validateToolParams

Method validateToolParams

packages/core/src/tools/ls.ts:318–338  ·  view source on GitHub ↗

* Validates the parameters for the tool * @param params Parameters to validate * @returns An error message string if invalid, null otherwise

(params: LSToolParams)

Source from the content-addressed store, hash-verified

316 * @returns An error message string if invalid, null otherwise
317 */
318 override validateToolParams(params: LSToolParams): string | null {
319 const errors = SchemaValidator.validate(
320 this.schema.parametersJsonSchema,
321 params,
322 );
323 if (errors) {
324 return errors;
325 }
326 if (!path.isAbsolute(params.path)) {
327 return `Path must be absolute: ${params.path}`;
328 }
329
330 const workspaceContext = this.config.getWorkspaceContext();
331 if (!workspaceContext.isPathWithinWorkspace(params.path)) {
332 const directories = workspaceContext.getDirectories();
333 return `Path must be within one of the workspace directories: ${directories.join(
334 ', ',
335 )}`;
336 }
337 return null;
338 }
339
340 protected createInvocation(
341 params: LSToolParams,

Callers 5

buildFunction · 0.45
glob.test.tsFile · 0.45
edit.test.tsFile · 0.45
grep.test.tsFile · 0.45
memoryTool.test.tsFile · 0.45

Calls 4

validateMethod · 0.80
getWorkspaceContextMethod · 0.80
isPathWithinWorkspaceMethod · 0.80
getDirectoriesMethod · 0.80

Tested by

no test coverage detected