#4669·mcp

aws-healthomics-mcp-server: pagination returnedCount depends on response key insertion order

Author: markjschreiberCreated Sep 24, 2026Updated Sep 24, 2026
Labelsaws-healthomics-mcp

Summary

In src/aws-healthomics-mcp-server/awslabs/aws_healthomics_mcp_server/utils/pagination.py, the pagination block's returnedCount is computed with _first_list_length(result.values()) (used around lines 194 and 203). That helper returns the length of the first list-valued field it encounters in the response dict.

Its docstring asserts "exactly one list per response", but that does not hold. SearchGenomicsFiles responses contain at least two list-valued fields, results and storage_systems_searched. The count is correct today only because build_search_response happens to insert results first.

Impact

Reordering keys in a response builder, or adding a new list-valued field ahead of the results list, silently reports a wrong returnedCount to the calling agent. No existing test fails, because every fixture shares the current insertion order. Agents use returnedCount to reason about completeness, so a wrong value is actively misleading rather than merely cosmetic.

Suggested fix

Select the results list deterministically rather than positionally, for example by preferring a documented set of result-list keys, and add a test that reorders a fixture's keys and asserts the count is unchanged. That test is the actual regression guard; the current suite has none.