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

Method validateString

src/mcp/tools.ts:2922–2936  ·  view source on GitHub ↗

* Validate that a value is a non-empty string within length bounds. * * The `maxLength` cap protects against MCP clients that ship huge * payloads (10MB+ query strings either by accident or maliciously). * Without this, a single oversized input can pin the FTS5 index or * exhaust memo

(
    value: unknown,
    name: string,
    maxLength: number = MAX_INPUT_LENGTH
  )

Source from the content-addressed store, hash-verified

2920 * exhaust memory before any real work runs.
2921 */
2922 private validateString(
2923 value: unknown,
2924 name: string,
2925 maxLength: number = MAX_INPUT_LENGTH
2926 ): string | ToolResult {
2927 if (typeof value !== 'string' || value.length === 0) {
2928 return this.errorResult(`${name} must be a non-empty string`);
2929 }
2930 if (value.length > maxLength) {
2931 return this.errorResult(
2932 `${name} exceeds maximum length of ${maxLength} characters (got ${value.length})`
2933 );
2934 }
2935 return value;
2936 }
2937
2938 /**
2939 * Validate an optional path-like string input. Returns the value if

Callers 6

handleSearchMethod · 0.95
handleCallersMethod · 0.95
handleCalleesMethod · 0.95
handleImpactMethod · 0.95
handleExploreMethod · 0.95
handleNodeMethod · 0.95

Calls 1

errorResultMethod · 0.95

Tested by

no test coverage detected