anthropics / anthropics/claude-agent-sdk-typescript
SDK MCP servers fail to connect from concurrent query() calls - 60s timeout
- Vorherrschende Sprache
- Shell
- Sterne
- 1.8k
- Forks
- 226
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
## Description
When multiple `query()` calls are made concurrently with an SDK MCP server configured via `createSdkMcpServer()`, only the first request connects successfully. All other concurrent requests fail to connect to the SDK MCP server and block for 60 seconds until the MCP connection timeout expires.
## Expected Behavior
All concurrent `query()` calls should be able to use the SDK MCP server simultaneously.
## Actual Behavior
1. First `query()` connects to SDK MCP server → completes in ~8s
2. Concurrent `query()` calls fail to connect → wait 60s for timeout → complete in ~65s
Debug logs show the error:
[ERROR] MCP server "test-server" Failed to connect SDK MCP server:
McpError: MCP error -32001: Request timed out
## Reproduction
```typescript
import { query, tool, createSdkMcpServer } from '@anthropic-ai/claude-agent-sdk';
import { z } from 'zod';
const server = createSdkMcpServer({
name: 'test-server',
tools: [tool('echo', 'Echo', { msg: z.string() }, async (a) => a.msg)],
});
// Launch 3 concurrent queries
await Promise.all([1, 2, 3].map(() =>
(async () => {
const start = Date.now();
const result = query({
prompt: 'Say hello',
options: {
model: 'claude-sonnet-4-20250514',
mcpServers: { 'test-server': server },
maxTurns: 1,
permissionMode: 'bypassPermissions',
allowDangerouslySkipPermissions: true,
},
});
for await (const msg of result) if (msg.type === 'result') break;
console.log(`Done in ${((Date.now() - start) / 1000).toFixed(1)}s`);
})()
));
// Output:
// Done in 6.9s ← first request succeeds
// Done in 63.2s ← second request waits 60s timeout
// Done in 63.6s ← third request waits 60s timeout
```
Environment
- @anthropic-ai/claude-agent-sdk: 0.2.2
- Node.js: v24.10.0
- macOS Darwin 25.1.0
Notes
- Stdio MCP servers work correctly with concurrent requests
- The issue is specific to SDK MCP servers created with createSdkMcpServer()
- All CLI subprocesses spawn concurrently (verified via debug logs) - the bottleneck is in the SDK's IPC connection to the in-process MCP server
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.