Skip to content

test(everything): pin that requestState expires after its 600-second TTL - #5617

Open
cliffhall wants to merge 1 commit into
v2/mainfrom
v2/chore/5542-everything-requeststate-expiry-test
Open

cliffhall wants to merge 1 commit into
v2/mainfrom
v2/chore/5542-everything-requeststate-expiry-test

Conversation

@cliffhall

Copy link
Copy Markdown
Member

Closes #5542

Description

Adds one test to src/everything/__tests__/modern.test.ts, beside the existing requestState cases in multi-round-trip requests on 2026-07-28: a correctly signed, untampered requestState is refused with -32602 once its 600-second TTL has passed.

The test freezes Date before the state is minted (the fake-Date pattern the minted-resource TTL test in the same file uses), then sends the same continuation twice:

  • at +599 s it is accepted (the tool moves on to the color question), and
  • at +601 s it is refused with -32602.

The in-TTL half is there because an expired state and a tampered one are the same error on the wire ({"code":-32602,"message":"Invalid or expired requestState","data":{"reason":"invalid_request_state"}} for both), so a lone -32602 assertion would not show that the refusal is the expiry. The file's existing afterEach already calls vi.useRealTimers(), so the real clock is restored when the test fails too.

The file header's summary gains "or expired". No source change.

Server Details

  • Server: everything
  • Changes to: tests only (__tests__/modern.test.ts)

Motivation and Context

#5542: the tests pinned tamper rejection and the happy-path round trip, but not expiry, which is the security-relevant half of the TTL declared on roundStateCodec (ttlSeconds: 600 in server/index.ts).

How Has This Been Tested?

This change has no client-observable surface (a test only), so the evidence is a targeted probe: the test made to fail by breaking what it pins, then passing against the unmodified source.

Source under test (server/index.ts, changed locally and restored) Result of the new test
Unmodified (ttlSeconds: 600) passes
ttlSeconds: 6000 (no expiry at +601 s) fails: expected undefined to match object { code: -32602 } (the +601 s continuation was accepted)
ttlSeconds: 500 (expires early) fails: expected { code: -32602, … } to be undefined (the +599 s continuation was refused)
  • npm test -w src/everything -- __tests__/modern.test.ts: 54 passed.
  • npm run local:gate: exit 0 on the pushed head.

Breaking Changes

None. No user-facing change.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

None of the four applies: this adds a test.

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follow MCP security best practices
  • I have updated the server's README accordingly (not applicable: no change to tools, resources, prompts or configuration)
  • I have added a changeset (npm run changeset) if this changes what a TypeScript server publishes (not applicable: tests are not published)
  • I have tested this with an LLM client (not applicable: no server behavior changed; see the probe above)
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling (not applicable: no source change)
  • I have documented all environment variables and configuration options (not applicable: none added)

Additional context

The test uses 599 s and 601 s rather than the exact boundary: whether a state is still good in its 600th second is the SDK codec's detail (exp < now, in whole seconds), not something this server declares.

🤖 Generated with Claude Code

The requestState cases pinned tamper rejection and the round trip, but not
expiry: that a correctly signed, untampered state is refused once its time
has run out. The new case freezes the clock, continues the same state at
+599 s (accepted) and at +601 s (refused with -32602), so it fails if the
expiry check is absent or the TTL changes.

Closes #5542

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
@cliffhall cliffhall added the v2 label Nov 18, 2026
@changeset-bot

changeset-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f67c1c0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

everything: MCP interface diff

Base: 7f383a8e0f34 (Merge pull request #5597 from modelcontextprotocol/changeset-release/v2/main)
Head: the build in this checkout, at 816838f977b2 (Merge f67c1c0 into 7f383a8)

Diffed because it was named (--server).

✅ No interface changes detected.

Tools Prompts Resources Resource templates
Base 22 4 8 5
Head 22 4 8 5

Updated by this run for f67c1c0a23db3eaf1ce196821184892f672c8e31.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the added request-state expiry regression coverage.

No open issues 🎉

What changed in this PR

Adds regression coverage for the everything server’s 600-second requestState expiry, addressing #5542 without changing server behavior.

Changes:

  • Adds a fake-clock test confirming the same untampered continuation is accepted at +599 seconds and rejected with -32602 at +601 seconds.
  • Updates the test file’s header comment to include expired-state coverage.
File Description
src/​everything/​__tests__/​modern.test.ts Adds request-state TTL regression coverage and updates the coverage summary comment.

Review effort: Balanced

@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 1 (review 5962995958, on f67c1c0): clean. No comments and no suppressed findings, so the review loop ends here on the first clean round. Nothing was pushed after the review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

everything: add a test that requestState expires after its 600-second TTL

2 participants