Skip to content

Wrap batch_query results in correlation envelope with request_index #1838

Description

@Widthdom

Summary

batch_query (McpToolHandlers.cs:1137-1189) returns a flat array of per-tool results without any envelope identifying which sub-result corresponds to which sub-request, which sub-results were truncated, or which failed. A client that fans out 5 mixed tool calls in one batch must rely entirely on positional indexing, which breaks the moment a sub-call is silently dropped or reordered (e.g. by future async/streaming features). Sibling concern to #1527 (CLI --json envelope) and the just-filed #1808 (search truncated/total envelope), but in the batch_query layer.

Where

  • src/CodeIndex/Mcp/McpToolHandlers.cs:1137-1189 (batch_query result assembly)

Suggested approach

(1) Wrap each sub-result in {request_index: i, tool_name: "search", ok: true|false, error: ..., result: {...}} so consumers can correlate by request_index rather than position. (2) Carry a top-level _meta: {total_requests, completed, failed, truncated_indices: [...], elapsed_ms} envelope. (3) When a sub-call is server-side cancelled or rejected (cross-link #1418 — MCP cancel), include the failure reason in error.data (cross-link #1581 — MCP error envelope shape). (4) Document the envelope under "batch_query response shape" and reference it from the tool description (cross-link the just-filed #1810 — tool examples). (5) Add per-tool JSON-schema validation tests (cross-link the just-filed #1820). (6) Cross-link with #1616 (batch_query partial completion) and #1472 (pagination cursors).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions