Hi @mowens,
Another issue found and fixed with the help of Claude:
Problem/Motivation
When running drush mcp-tools:serve, Drupal captures REQUEST_TIME once at process startup. All entities created during the MCP server session inherit this frozen timestamp instead of the actual creation time, causing created/changed fields to reflect the server start time rather than when content was actually created.
Steps to reproduce
- Start
drush mcp-tools:serve(or connect via Claude Desktop) - Wait several minutes
- Create a node, media, or taxonomy term via MCP tools
- Check
created/changedin database — they reflect the process start time, not the current time
Proposed resolution
Inject TimeInterface (@datetime.time) via constructor into affected services and use $this->time->getCurrentTime() (which calls time() on each invocation) instead of \Drupal::time()->getRequestTime() (which returns the frozen REQUEST_TIME).
Affected services + .services.yml files:
mcp_tools_content:ContentServicemcp_tools_media:MediaServicemcp_tools_batch:BatchServicemcp_tools_structure:TaxonomyManagementService
Validation
Tested via MCP tools:
- Node creation:
created/changedtimestamps within 6 seconds of actual time - File upload + media creation: timestamps within 16 seconds (includes network latency)
- Batch content creation: timestamps within 6 seconds
- Taxonomy term creation:
changedtimestamp within 6 seconds
PR will follow !
Issue fork mcp_tools-3575317
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #5
mowens commentedResolved thanks for the help!
Comment #8
mowens commented