You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: implement sliding window expiration for MCP sessions (#39)
* fix: implement sliding window expiration for MCP sessions
- Replace fixed 30-minute timeout with activity-based expiration
- Add lastActivity tracking to session metadata
- Update activity timestamp on each request via touchSession()
- Implement global setInterval cleanup (every 5 minutes)
- Sessions expire after 30 minutes of inactivity (not creation time)
- Add comprehensive test suite for session lifecycle
- Update documentation (ARCHITECTURE.md, MCP_TOOLS.md, skill docs)
Fixes frequent "Session not found. Please reinitialize." errors
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* fix: update MCP session tests to use vi.hoisted for mock bindings
- Use vi.hoisted() to create mockTransport, making it available in mock factory
- Change mock constructor from arrow function to regular function
- Use dynamic imports in each test to avoid binding issues
- Update cleanup test to verify behavior (404 response) instead of mock assertions
This fixes CI test failures caused by mock binding issues with vi.resetModules()
and fake timers. All 8 tests now pass reliably.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* fix: add auto-reconnection for MCP session in Chorus Plugin
- Fix mock constructor syntax in MCP session tests (use function instead of arrow function)
- Add automatic retry mechanism (max 3 retries) on 404 session expired
- Detect HTTP status code and reinitialize session on failure
- Resolve user pain point: session expiry no longer interrupts agent conversations
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* refactor: move Prisma query to service layer and add cleanup comment
- Add getProjectUuidsByGroup() to project.service.ts
- Replace direct Prisma query in route.ts with service call
- Add comment about setInterval assuming persistent Node.js process
Addresses PR review feedback:
- Move Prisma operations to service layer per project convention
- Document setInterval limitations in serverless/edge environments
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* fix: correct mock constructor syntax in MCP session tests
* chore: remove package-lock.json (project uses pnpm)
* chore: add package-lock.json to .gitignore
---------
Co-authored-by: code <dev@sxrzpt.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: public/chorus-plugin/skills/chorus/references/00-common-tools.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,11 @@ Results can be filtered by project(s) using optional HTTP headers in your `.mcp.
53
53
54
54
Sessions track which agent is working on which task, powering UI features (Kanban worker badges, Task Detail active workers, Settings page). The Chorus Plugin **fully automates** session lifecycle — sessions are created, heartbeated, and closed automatically. See [05-session-sub-agent.md](05-session-sub-agent.md) for details.
55
55
56
+
**MCP Session Lifecycle** (connection level):
57
+
- Sessions expire after 30 minutes of **inactivity** (sliding window)
58
+
- Each MCP request automatically renews the session
59
+
- Server restart clears all sessions (plugin auto-reconnects)
60
+
56
61
**What you do manually (the plugin handles everything else):**
Copy file name to clipboardExpand all lines: public/skill/references/00-common-tools.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,23 @@ Results can be filtered by project(s) using optional HTTP headers in your `.mcp.
51
51
52
52
---
53
53
54
+
## Session Lifecycle
55
+
56
+
MCP sessions implement **sliding window expiration** — sessions expire after 30 minutes of **inactivity**, not from creation time.
57
+
58
+
**Key points**:
59
+
- Each request automatically renews the session (updates `lastActivity`)
60
+
- Active agents can work indefinitely without timeout
61
+
- Inactive sessions are cleaned up every 5 minutes
62
+
- Server restart clears all sessions (clients should auto-reconnect)
63
+
64
+
**When you see "Session not found" (HTTP 404)**:
65
+
- The session expired due to inactivity or server restart
66
+
- Your MCP client should automatically reinitialize
67
+
- This is transparent in clients with auto-reconnect support
68
+
69
+
---
70
+
54
71
## Project Groups
55
72
56
73
Projects can be organized into **Project Groups** — a single-level grouping for categorizing related projects together (e.g., all projects for the same product). A project belongs to at most one group, or can be ungrouped.
0 commit comments