Skip to content
Qiita·Indexed by this site · Originally published· Tools →

Claude Code's MCP tool calls time out after 60 seconds — complete implementation of a job submission pattern that prevents ghost duplicate executions

AI summary

The author had Claude Code batch-convert 30 PDF folders via an MCP tool; the synchronous implementation took about 90 seconds and timed out at the client's 60-second wait limit. The timeout only means the client stopped waiting; the server-side process was still running. Claude Code judged the tool to have failed and retried, so the same task was submitted again, and two processes wrote to the same output path, producing 3 corrupted text files. The author notes that increasing the timeout value and sleeping inside the tool to return progress in segments both fail; the only solution is to separate the response from the processing. The article gives a complete implementation of the job submission pattern: the tool returns a job_id within 1 second, the AI polls the running/done/failed status with get_job_status, and a running task with the same target is reused directly, making retries idempotent. The article ends with a .mcp.json configuration, a comparison table of three approaches, and a 7-question implementation checklist, and notes that the in-memory JobStore loses tasks after a server restart, so SQLite can be used when persistence is needed.

Read originalqiita.com