Skip to content

fix(mcp): emit lossless follower-stats JSON in _format_response#26

Merged
Zernio-Elean merged 1 commit into
developfrom
fix/follower-stats-mcp-serialization
Jun 24, 2026
Merged

fix(mcp): emit lossless follower-stats JSON in _format_response#26
Zernio-Elean merged 1 commit into
developfrom
fix/follower-stats-mcp-serialization

Conversation

@Zernio-Elean

Copy link
Copy Markdown
Contributor

Why

The MCP tool accounts_get_follower_stats returned only the account name (platform: username), dropping the follower count, growth and the daily series, even though the data exists server-side. Customer-origin: a developer pulling LinkedIn org follower stats (latest count 2274 + a week of daily snapshots) saw only the account name come back.

Crisp: https://app.crisp.chat/website/20dea5d6-a684-4c80-b097-2258b0b41421/inbox/session_30e968e1-b064-4020-9c16-dd9ff655b5df/

What

  • _format_response is a shared stringifier that pattern-matches on the response shape. FollowerStatsResponse has an accounts attr, so it fell into the generic account-list branch that prints only - {platform}: {username} and discarded currentFollowers, growth and the stats series.
  • Added a guard on the stats attr (unique to FollowerStatsResponse among all response models) BEFORE the generic accounts branch, returning model_dump_json(by_alias=True, exclude_none=True) so the count, growth and series reach the LLM losslessly.
  • Applied to both the emitted generated_tools.py and the generate_mcp_tools.py template so a future regen keeps it.
  • Fixed two now-stale get_follower_stats docstrings (aggregation -> stats, granularity).
  • Added two respx regression tests (the formatter test fails pre-fix, passes post-fix).
  • Added mcp>=1.8.0 to the existing dev extra so tests can import late.mcp.generated_tools.

The related model gap (FollowerStatsResponse missing stats/granularity) was already corrected on develop by an earlier OpenAPI regen, so no model change was needed here.

accounts_get_follower_stats returned only "platform: username",
dropping currentFollowers, growth and the daily series: the shared
_format_response matched the generic accounts branch. Add a guard on
the stats attr (unique to FollowerStatsResponse) before that branch,
returning model_dump_json. Applied to the emitted file and the
generator template so a regen keeps it.

Crisp: https://app.crisp.chat/website/20dea5d6-a684-4c80-b097-2258b0b41421/inbox/session_30e968e1-b064-4020-9c16-dd9ff655b5df/
@Zernio-Elean Zernio-Elean merged commit fd0eb7b into develop Jun 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant