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

Method validateOptionalPath

src/mcp/tools.ts:2942–2956  ·  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

2940 * valid (or undefined), or a ToolResult with the error.
2941 */
2942 private validateOptionalPath(
2943 value: unknown,
2944 name: string
2945 ): string | undefined | ToolResult {
2946 if (value === undefined || value === null) return undefined;
2947 if (typeof value !== 'string') {
2948 return this.errorResult(`${name} must be a string`);
2949 }
2950 if (value.length > MAX_PATH_LENGTH) {
2951 return this.errorResult(
2952 `${name} exceeds maximum length of ${MAX_PATH_LENGTH} characters (got ${value.length})`
2953 );
2954 }
2955 return value;
2956 }
2957
2958 /**
2959 * 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