MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / validateOptionalPath

Method validateOptionalPath

src/mcp/tools.ts:2757–2771  ·  view source on GitHub ↗

* Validate an optional path-like string input. Returns the value if * valid (or undefined), or a ToolResult with the error.

(
    value: unknown,
    name: string
  )

Source from the content-addressed store, hash-verified

2755 * valid (or undefined), or a ToolResult with the error.
2756 */
2757 private validateOptionalPath(
2758 value: unknown,
2759 name: string
2760 ): string | undefined | ToolResult {
2761 if (value === undefined || value === null) return undefined;
2762 if (typeof value !== 'string') {
2763 return this.errorResult(`${name} must be a string`);
2764 }
2765 if (value.length > MAX_PATH_LENGTH) {
2766 return this.errorResult(
2767 `${name} exceeds maximum length of ${MAX_PATH_LENGTH} characters (got ${value.length})`
2768 );
2769 }
2770 return value;
2771 }
2772
2773 /**
2774 * Cached git worktree/index mismatch for a tool call's effective project.

Callers 1

executeMethod · 0.95

Calls 1

errorResultMethod · 0.95

Tested by

no test coverage detected