Summary
Several tools accept optional integer array parameters (e.g., names in symbols, queries in batch_query) but only validate non-empty at the collection level. At /Users/widthdom/Projects/mine/cdidx/CodeIndex/src/CodeIndex/Mcp/McpToolHandlers.cs:143-150, ReadStringList silently drops null, whitespace, and non-string elements without reporting truncation. A client sending ["", null, 123, "validName"] will silently reduce to ["validName"] with no indication that 3 invalid entries were dropped. For batch_query (line 1129-1135), a malformed queries array with invalid tool objects will add errors to resultsArray but never report how many entries were skipped before processing.
Where
McpToolHandlers.cs:143-150 ReadStringList silent filtering
McpToolHandlers.cs:187-202 ReadPathList silent filtering
McpToolHandlers.cs:323-340 symbols names validation with silent drops
McpToolHandlers.cs:1129-1155 batch_query queries array processing
Suggested approach
- Add a
tryReadStringList overload that returns (values, invalidCount, invalidSamples).
- Track invalid entries during filtering and report count in error if
invalidCount > 0.
- In batch_query, validate each queries[i] has required "tool" and "arguments" fields before processing.
- Return a summary object:
["valid_count", "invalid_count", "skipped_reasons"] to help clients debug input issues.
- Add tool description notes: "Empty or null entries in this list are silently dropped."
- Write integration tests sending mixed-valid-invalid arrays.
Summary
Several tools accept optional integer array parameters (e.g.,
namesin symbols,queriesin batch_query) but only validate non-empty at the collection level. At /Users/widthdom/Projects/mine/cdidx/CodeIndex/src/CodeIndex/Mcp/McpToolHandlers.cs:143-150,ReadStringListsilently drops null, whitespace, and non-string elements without reporting truncation. A client sending["", null, 123, "validName"]will silently reduce to["validName"]with no indication that 3 invalid entries were dropped. For batch_query (line 1129-1135), a malformedqueriesarray with invalid tool objects will add errors to resultsArray but never report how many entries were skipped before processing.Where
McpToolHandlers.cs:143-150ReadStringList silent filteringMcpToolHandlers.cs:187-202ReadPathList silent filteringMcpToolHandlers.cs:323-340symbols names validation with silent dropsMcpToolHandlers.cs:1129-1155batch_query queries array processingSuggested approach
tryReadStringListoverload that returns(values, invalidCount, invalidSamples).invalidCount > 0.["valid_count", "invalid_count", "skipped_reasons"]to help clients debug input issues.