Repository navigation
[6.x] Refresh records built from project config between operations - #20583
Merged
brandonkelly merged 1 commit intoNov 13, 2026
Merged
brandonkelly merged 1 commit into
brandonkelly merged 1 commit into
Conversation
Contributor
📚 Storybook previews@craftcms/ui — open Storybook No changed components detected in this Storybook. resources/js — open Storybook No changed components detected in this Storybook. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the changes that refresh project configuration between stdio requests.
No open issues 🎉
What changed in this PR
Refreshes project-config state between requests in long-running stdio MCP sessions, addressing the stale reads, overwritten external changes, and persistent write failures reported in #20568.
Changes:
- Clears facade and
once()caches, resets loaded project config, and refreshes cached configuration records for each request. - Adds a regression test that simulates external changes between messages and checks fresh values, updated revisions, and preservation of those changes when saving.
| File | Description |
|---|---|
tests/Feature/Mcp/StdioTest.php |
Adds between-message change simulation and assertions for configuration freshness and safe updates. |
src/Mcp/StdioEventDispatcher.php |
Resets request-local state and configuration caches before processing each stdio request. |
Review effort: Balanced
Long-lived processes, such as Octane workers and the stdio MCP server, already reload the project config before each operation, but the fields, entry types, volumes, site groups, and image transforms services kept the records they had loaded. The stdio MCP server then returned stale records, and an update with a current expectedRevision saved those stale values over changes made in the control panel or CLI. PrepareCraftForNextOperation now refreshes those services too. Fixes #20568 Amp-Thread-ID: https://ampcode.com/threads/T-01a1c684-2755-73e3-9764-31efd573c59b Co-authored-by: Amp <amp@ampcode.com>
riasvdv
force-pushed
the
rias/cms-2657-6x-stdio-mcp-server-doesnt-see-project-config
branch
from
November 12, 2026 21:06
762f4be to
d8682ce
Compare
brandonkelly
deleted the
rias/cms-2657-6x-stdio-mcp-server-doesnt-see-project-config
branch
November 13, 2026 05:16
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
#20641 made long-lived processes (Octane workers and the stdio MCP server) reload the project config before each operation. The services that hold records built from it still kept what they had loaded, so
configuration_getreturned stale records. The revision came from the fresh project config, so an update with a currentexpectedRevisionpassed and saved the stale values over changes made in the control panel or CLI.PrepareCraftForNextOperation::prepare()now refreshes those services as well:Sections, sites, and routes are already scoped or refreshed.
Evidence
New test in
tests/Feature/Mcp/StdioTest.php:Failed asserting that null is identical to 'Changed elsewhere', and the update savedinstructions: null.After: passes. Also passing:
tests/Feature/Mcp(370),OctaneWorkerTest, andcomposer ci.Before this rebase, a real
craft:mcp:serveprocess withcraft:project-config:setrun between messages also showed stale entry types, site groups, and volumes.Related issues