Fix MCP server: create separate McpServer instance per session
Previously shared one McpServer instance across all sessions/transports, which caused Protocol._transport to be overwritten when new sessions connected. This broke message routing for requests on previous transports after long-running SSE streams. Now creates a new McpServer instance per session, following the stateful session pattern from the MCP SDK documentation. Each session gets its own server+transport pair, preventing transport reference conflicts. Fixes issue where get_agent_status would fail after wait_for_agent completed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -491,6 +491,9 @@ class ClaudeAgentSession implements AgentSession {
|
||||
permissionMode: this.currentMode,
|
||||
agents: this.defaults?.agents,
|
||||
canUseTool: this.handlePermissionRequest,
|
||||
stderr: (data: string) => {
|
||||
console.error("[ClaudeAgentSDK]", data.trim());
|
||||
},
|
||||
...this.config.extra?.claude,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user