feat(mcp): v0.1.10 — auto-downsample get_temperature_history to fit under 1 MB cap#9
Merged
Merged
Conversation
Claude Desktop's ~1 MB / 25k-token tool-result cap was blocking 7-day
history fetches across all zones (~2.6 MB raw). FastMCP / the Python
MCP SDK has no server-side response-size knob — the cap is enforced
client-side — so the only fix is to shrink the payload on the server.
`get_temperature_history` now bucket-averages each zone's series down
to at most 600 samples (10-min resolution over a week, 30-min over a
month). Empirically: 7-day × 8 zones drops from 2,733,887 → 161,612
bytes — 17x reduction, well under every known client cap. Samples
keep the `{x, y}` wire shape so existing agent code keeps working;
the response gains a `downsample` envelope reporting pre/post counts
per zone.
CLI `emodul stats linear` is unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_temperature_historynow bucket-averages each zone's series to at most 600 samples before returning. Empirical 7-day × 8 zones: 2,733,887 → 161,612 bytes (17x reduction).downsampleenvelope ({downsampled, max_points_per_zone, per_zone: {<key>: {original, returned}}}) so the agent can surface the pre-bucket sample count. The{x, y}shape and series keys are unchanged.Background — why downsampling, not a FastMCP setting
I checked the MCP Python SDK (
mcp.server.fastmcp) — neitherSettingsnor theFastMCP(...)constructor exposes any response-size knob (max_response_size,max_message_size, nothing). The 1 MB cap lives client-side in Claude Desktop / Claude Code — controlled there byMAX_MCP_OUTPUT_TOKENS(default 25k tokens, docs). The official server-side mitigations Anthropic suggests are: (a) declare ananthropic/maxResultSizeCharsannotation, or (b) paginate/downsample. We can't change the client cap from the server, so downsampling is the correct lever.Test plan
ruff check emodul/ --select=E,F,I,B --ignore=E501— cleanget_temperature_historyadvertises downsampling in its description_downsample_series(empty, small-passthrough, at-threshold, over-threshold, mixed None-y,max_points=0safety)emodul stats linearuntouched — separate code path--module Parteronce merged