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

  1. Start drush mcp-tools:serve (or connect via Claude Desktop)
  2. Wait several minutes
  3. Create a node, media, or taxonomy term via MCP tools
  4. Check created/changed in 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: ContentService
  • mcp_tools_media: MediaService
  • mcp_tools_batch: BatchService
  • mcp_tools_structure: TaxonomyManagementService

Validation

Tested via MCP tools:

  • Node creation: created/changed timestamps 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: changed timestamp within 6 seconds

PR will follow !

Issue fork mcp_tools-3575317

Command icon 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

guillaumeg created an issue. See original summary.

  • mowens committed 0e4e3314 on master authored by guillaumeg
    #3575317 Use getCurrentTime() to avoid frozen REQUEST_TIME in server...

  • mowens committed b1803b6d on master
    Fix remaining frozen REQUEST_TIME in server mode
    
    Follow-up to #3575317...
mowens’s picture

Resolved thanks for the help!

  • mowens committed 220fdd0c on master
    Fix remaining frozen REQUEST_TIME in server mode
    
    Follow-up to #3575317...

  • mowens committed 550b08d2 on master authored by guillaumeg
    #3575317 Use getCurrentTime() to avoid frozen REQUEST_TIME in server...
mowens’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.