feat(security): make the response size limit configurable - #49
Merged
sylvesterdamgaard merged 1 commit intoSep 9, 2026
Merged
Conversation
The guard against oversized tool responses was a bare 100000 in wrapInStandardFormat(). The ceiling that actually matters is the calling client's context window, which differs per client and grows over time, so a site had no way to tune it without forking. Move it to statamic.mcp.security.max_response_size, default 100000 so behaviour is unchanged, env-overridable via STATAMIC_MCP_MAX_RESPONSE_SIZE, and 0 to disable the guard. Mirrors how oauth.cimd_max_response_size is already handled. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
Author
|
Hi @sylvesterdamgaard, quick note since I've opened a fair few PRs at once. First of all, thank you for building and maintaining this MCP 🥳 We opened PR's #43 to #51 while testing on our real installs with multi-site enabled and a replicator page builder structure, which is what surfaced most of them. We've tried to match the project's conventions as closely as we could. Let me know if anything is unclear. |
This was referenced Sep 9, 2026
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.
Description
The guard against oversized tool responses is a bare
100000inwrapInStandardFormat(). The ceiling that actually matters is the calling client's context window, which differs per client and grows over time, so a site has no way to tune it without forking.Moves it to
statamic.mcp.security.max_response_size, default 100000 so behaviour is unchanged,STATAMIC_MCP_MAX_RESPONSE_SIZEto override,0to disable the guard.Type of Change
Related Issue
None — hit it on a page-builder blueprint where
statamic-blueprints getwithinclude_format_specreturns 170KB at the defaultmax_format_depth, so the call fails outright and there is no way to raise the ceiling for a client that could comfortably take it.Testing
composer test)composer quality)tests/Feature/ResponseSizeLimitTest.php— 4 cases: the default is still 100000, a lower limit refuses, a raised limit allows a response the default would refuse, and 0 disables the guard.Full gate green — pint, PHPStan level 9, 1110 tests / 5610 assertions.
Environment
Checklist
Notes
Mirrors how
oauth.cimd_max_response_sizeis already handled, so this follows the package's own convention for size limits rather than introducing a new one.Worth saying explicitly: raising the limit is not a fix for a large response, it just moves the wall. The underlying problem — that
include_format_specat its default depth exceeds the guard on a real page-builder blueprint, while the truncation message tells agents to raise the depth — is separate and better solved by making the payload smaller.