Summary
On a large project, the get-changed-stories MCP tool returns a payload big enough to exceed the agent's tool-output token limit, so the agent never receives the result. When this happens the agent silently falls back to a worse path (preview-stories + self-curated IDs) and the published review is noticeably degraded. There is no smaller/paginated mode to fall back to, so the failure scales with repo size and is invisible to the user.
Environment
storybook@0.0.0-pr-34837-sha-afb9fe72
@storybook/addon-mcp@main (pkg.pr.new) → @storybook/mcp commit fd459590
- Repro project: chakra-ui monorepo (
@chakra-ui/react, ~117 stories), pnpm, Storybook run from the git root.
- Agent: Claude Code (headless), connected to the addon-mcp HTTP endpoint.
What happens
After editing a few components, the agent called get-changed-stories and got back, instead of a result:
Error: result (125,660 characters across 1,040 lines) exceeds maximum allowed tokens.
Output has been saved to /…/tool-results/mcp-storybook-get-changed-stories-….txt.
Format: Plain text
i.e. the tool produced ~125 KB / 1,040 lines in a single response. The MCP/agent layer truncates and spills it to a file, so the model never sees the structured result.
Impact (the important part)
The agent recovered by grepping the spilled file, then routed around the tool — it called preview-stories with a handful of hand-picked IDs and published the review from those. Compared to runs where get-changed-stories returned normally, the resulting review was much thinner:
| Run |
get-changed-stories |
Published review |
| chakra-ui (overflow) |
❌ exceeded token limit |
3 storyIds / 2 collections |
| wikitok / reshaped / baklava / evergreen-ui |
✅ ok |
12–13 storyIds / 4 collections |
So the headline review feature silently degrades on exactly the large/real projects it's most useful for, with no error surfaced to the user — the review just comes back smaller and the agent doesn't flag that discovery failed.
Repro
- In a large Storybook (~100+ stories), have the agent edit a few components.
- Have it call
get-changed-stories.
- Observe the result exceeds the tool-output token limit and is spilled to a file instead of returned.
Suggested fixes
- Cap/paginate the response. Return ranked
storyId + distance (+ minimal metadata) only, with a maxResults and pagination — never inline full content/diffs of every related story.
- Add a compact mode (IDs-only) the agent can request, or make compact the default and offer a
verbose opt-in.
- If a result would exceed a safe size, return a truncated, still-structured result with a
truncated: true flag and a count, so the agent knows discovery was incomplete (and can narrow by component) rather than silently self-curating.
Summary
On a large project, the
get-changed-storiesMCP tool returns a payload big enough to exceed the agent's tool-output token limit, so the agent never receives the result. When this happens the agent silently falls back to a worse path (preview-stories+ self-curated IDs) and the published review is noticeably degraded. There is no smaller/paginated mode to fall back to, so the failure scales with repo size and is invisible to the user.Environment
storybook@0.0.0-pr-34837-sha-afb9fe72@storybook/addon-mcp@main(pkg.pr.new) →@storybook/mcpcommitfd459590@chakra-ui/react, ~117 stories), pnpm, Storybook run from the git root.What happens
After editing a few components, the agent called
get-changed-storiesand got back, instead of a result:i.e. the tool produced ~125 KB / 1,040 lines in a single response. The MCP/agent layer truncates and spills it to a file, so the model never sees the structured result.
Impact (the important part)
The agent recovered by grepping the spilled file, then routed around the tool — it called
preview-storieswith a handful of hand-picked IDs and published the review from those. Compared to runs whereget-changed-storiesreturned normally, the resulting review was much thinner:get-changed-storiesSo the headline review feature silently degrades on exactly the large/real projects it's most useful for, with no error surfaced to the user — the review just comes back smaller and the agent doesn't flag that discovery failed.
Repro
get-changed-stories.Suggested fixes
storyId+distance(+ minimal metadata) only, with amaxResultsand pagination — never inline full content/diffs of every related story.verboseopt-in.truncated: trueflag and a count, so the agent knows discovery was incomplete (and can narrow by component) rather than silently self-curating.