Found while dogfooding the locally built cdidx on branch codex/search-audit-issues-20260619.
Duplicate check: no open issue found for MCP scalar arguments GetValue type mismatch batch queries AsArray invalid argument.
Evidence:
src/CodeIndex/Mcp/McpToolHandlers.cs:382, :391, and :510 use GetValue<int>() for numeric arguments.
src/CodeIndex/Mcp/McpToolHandlers.cs:3816 uses args?["queries"]?.AsArray() for batch query input.
Problem:
Malformed MCP argument shapes should consistently return structured invalid-argument errors. Direct GetValue<T>() / AsArray() calls can throw for wrong JSON shapes unless every caller is protected by a wrapper.
Acceptance criteria:
- Replace direct scalar/array extraction in MCP argument paths with
TryGetValue or shared validators.
- Return categorized MCP invalid-argument errors for wrong numeric or array types.
- Add tests for string/object/array values supplied to numeric arguments and non-array
batch_query.queries.
Found while dogfooding the locally built
cdidxon branchcodex/search-audit-issues-20260619.Duplicate check: no open issue found for
MCP scalar arguments GetValue type mismatch batch queries AsArray invalid argument.Evidence:
src/CodeIndex/Mcp/McpToolHandlers.cs:382,:391, and:510useGetValue<int>()for numeric arguments.src/CodeIndex/Mcp/McpToolHandlers.cs:3816usesargs?["queries"]?.AsArray()for batch query input.Problem:
Malformed MCP argument shapes should consistently return structured invalid-argument errors. Direct
GetValue<T>()/AsArray()calls can throw for wrong JSON shapes unless every caller is protected by a wrapper.Acceptance criteria:
TryGetValueor shared validators.batch_query.queries.