Skip to content

Expire idle local MCP sessions - #2602

Open
kunaaaalcodes wants to merge 1 commit into
UsefulSoftwareCo:v2from
kunaaaalcodes:fix/local-mcp-session-eviction
Open

kunaaaalcodes wants to merge 1 commit into
UsefulSoftwareCo:v2from
kunaaaalcodes:fix/local-mcp-session-eviction

Conversation

@kunaaaalcodes

Copy link
Copy Markdown

Summary

The local daemon reused MCP sessions without an idle lifetime, so a valid mcp-session-id could remain usable indefinitely. This change adds a local idle-expiration guard: sessions past their TTL are no longer accepted and get the MCP-compatible 404 Session not found response used for unknown or expired sessions.

Fixes #2598

What changed

  • Tracks the last-seen timestamp for each mcp-session-id in the local MCP handler.
  • Adds EXECUTOR_MCP_SESSION_IDLE_TTL_MS (milliseconds), with a 30-minute default.
  • Refreshes the idle window whenever an authenticated request carries a session id.
  • Rejects sessions idle past the TTL and removes their local last-seen entry.
  • Leaves requests without a session id, authorization behavior, and unknown-session handling unchanged.
  • Exposes origin from startLocalProduct so e2e tests can call the local product directly over HTTP.

Behavior

Case Result
Within TTL Session works normally
After activity Idle timer resets from the latest request
Past TTL 404 with JSON-RPC error code -32600
No session id No behavior change

Scope

Limited to the local daemon path described in #2598. Self-host and cloud MCP session handling already have their own bounded/expiring session behavior and are unchanged.

Tests

Added focused local e2e coverage in e2e/tests/local-mcp-session-idle.spec.ts:

  • An idle session expiring after the configured TTL.
  • A session staying valid while activity keeps refreshing the TTL.
  • Expiry after the refreshed idle window passes.

Checks run locally

  • lint
  • filtered TypeScript checks on changed files
  • e2e boundary check
  • no-unit-test guard
  • git diff --check
  • pr:check

Add an on-access idle TTL for local MCP sessions, configurable with EXECUTOR_MCP_SESSION_IDLE_TTL_MS and defaulting to 30 minutes. Add focused local e2e coverage for expiry and refresh.

Release-note: Fix: Local MCP sessions now expire after being idle.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] v1.6.11 local daemon (executor daemon run): MCP sessions without DELETE are never evicted (the #1684 fix does not cover apps/local)

1 participant