Bug
The longRunningOperation tool in examples/everything causes a transport error: transport closed when called over stdio, even with minimal parameters (duration: 0.1, steps: 1).
Reproduction
cd examples/everything
go build -o /tmp/everything-server .
# Call the tool via MCP stdio
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' | timeout 10 /tmp/everything-server
Or using mcp-assert:
name: longRunningOperation completes
server:
command: /tmp/everything-server
assert:
tool: longRunningOperation
args:
duration: 0.1
steps: 1
expect:
not_error: true
timeout: 30s
FAIL longRunningOperation completes 152ms
tool call longRunningOperation failed: transport error: transport closed
Root cause
The tool handler at main.go:418-459 calls time.Sleep() during execution. When progressToken is nil (no token in request meta), the tool still sleeps. The stdio transport appears to close before the response is sent, causing a race between the sleep completing and the transport teardown.
The other 5 tools in the same server (echo, add, notify, getTinyImage, get_resource_link) all pass without issue.
Environment
- mcp-go: latest (cloned from HEAD)
- Go: 1.25.5
- OS: Ubuntu (GitHub Actions CI) and macOS
- Transport: stdio
- Client: mcp-assert v0.1.1
Found while building a comprehensive test suite for the mcp-go SDK example servers. All other tools in everything, typed_tools, and structured_input_and_output pass (17/18 assertions).
Bug
The
longRunningOperationtool inexamples/everythingcauses atransport error: transport closedwhen called over stdio, even with minimal parameters (duration: 0.1,steps: 1).Reproduction
Or using mcp-assert:
Root cause
The tool handler at
main.go:418-459callstime.Sleep()during execution. WhenprogressTokenis nil (no token in request meta), the tool still sleeps. The stdio transport appears to close before the response is sent, causing a race between the sleep completing and the transport teardown.The other 5 tools in the same server (
echo,add,notify,getTinyImage,get_resource_link) all pass without issue.Environment
Found while building a comprehensive test suite for the mcp-go SDK example servers. All other tools in
everything,typed_tools, andstructured_input_and_outputpass (17/18 assertions).