Skip to content

chore(mcp): set an idle timeout for the flow MCP server - #445

Merged
jahvon merged 3 commits into
mainfrom
chore/mcp-idle-timeout
Aug 27, 2026
Merged

chore(mcp): set an idle timeout for the flow MCP server#445
jahvon merged 3 commits into
mainfrom
chore/mcp-idle-timeout

Conversation

@jahvon

@jahvon jahvon commented Aug 27, 2026

Copy link
Copy Markdown
Member

Part 2/2. Stacked on #444.

Summary

Bounds how long an MCP client waits on a silent flow tool call before giving up.

"flow": { "type": "stdio", "command": "flow", "args": ["mcp"], "timeout": 600000 }

This is a backstop, not the fix for the hang that prompted it — that was the panic in #444. Worth keeping regardless, so a genuine hang ends in minutes rather than never.

Notable Changes

  • Scoped per-server rather than set globally via CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT, so it does not loosen timeouts for every other MCP server a user has connected.
  • Ten minutes matches the longest timeout in CI (build binary, test e2e). It is an idle timeout — time without output or progress, not total runtime — so a legitimately slow run like validate on a cold cache is unaffected.
  • .mcp.json is committed, so this applies to every clone. That is deliberate and consistent with why the file is checked in: flow's own dev tasks legitimately run for minutes, and every contributor wants the same headroom.

Testing

Config-only; no code paths change. flow validate passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01R328pa3FUUfga4gYah1iQi

jahvon and others added 2 commits August 27, 2026 00:22
Any MCP tool call whose flow subprocess exited non-zero left the client
waiting on a request that never got a response, until it hit an idle timeout.

The target passed to errors.As was exec.ExitError, a value. ExitError's Error
method has a pointer receiver, so the value type does not implement error, and
errors.As panics on such a target ("*target must be interface or implement
error"). That panic killed the tool handler's goroutine before it could reply.

Nothing about the failure was visible from outside: the subprocess had already
run and recorded its terminal status in flow's history, and the server kept
serving other requests normally — only the one request was lost.

The one-character fix is *exec.ExitError, matching tests/utils/runner.go, which
had it right. This also restores the behavior the comment always described:
a non-zero exit is a normal outcome whose detail is already in the captured
output, so it returns as output with a nil error.

Affects every tool that shells out — execute, run_command, run_executable,
get_execution_logs, sync_executables — for any failing command.

The regression test drives the real FlowCLIExecutor against a stand-in binary
via FLOW_CLI_BINARY; it fails with the original panic before the fix.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R328pa3FUUfga4gYah1iQi
Bounds how long an MCP client waits on a silent flow tool call before giving
up. This is a backstop, not the fix for the hang that prompted it — that was a
panic in the exit-error path, fixed separately.

Scoped per-server rather than set globally via CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT
so it does not loosen timeouts for every other MCP server a user has connected.

Ten minutes matches the longest timeout in CI. It is an idle timeout — time
without output or progress, not total runtime — so a legitimately slow run like
`validate` on a cold cache is unaffected, while a genuine hang still ends.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R328pa3FUUfga4gYah1iQi
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Base automatically changed from fix/mcp-exit-error-panic to main August 27, 2026 05:43
@jahvon
jahvon merged commit f0b5b72 into main Aug 27, 2026
21 checks passed
@jahvon
jahvon deleted the chore/mcp-idle-timeout branch August 27, 2026 05:46
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.

1 participant