Skip to content

http streaming logging example is broken #632

@maxless

Description

@maxless

I used both the latest codex v0.57.0 and the included test client for testing and they both hang up since the wrapped handler never returns.

Steps to reproduce the behavior:

  1. Download and build example server/client code from examples/http/
  2. Start the server
  3. Start the client

I expect the client to get the time from the tool function.

Logs when I run it without changes:

Client:

me@host ~/t/mcp-gosdk> ./test -port 8143 -host localhost client
2025/11/10 19:41:03 Connecting to MCP server at http://localhost:8143

Server:

me@host ~/t/mcp-gosdk> ./test -port 8143 -host localhost server
2025/11/10 19:40:58 MCP server listening on localhost:8143
2025/11/10 19:40:58 Available tool: cityTime (cities: nyc, sf, boston)
2025/11/10 19:41:03 [REQUEST] 2025-11-10T19:41:03+02:00 | 127.0.0.1:33146 | POST /
2025/11/10 19:41:03 [RESPONSE] 2025-11-10T19:41:03+02:00 | 127.0.0.1:33146 | POST / | Status: 200 | Duration: 360.3µs
2025/11/10 19:41:03 [REQUEST] 2025-11-10T19:41:03+02:00 | 127.0.0.1:33146 | GET /
2025/11/10 19:43:23 [RESPONSE] 2025-11-10T19:43:23+02:00 | 127.0.0.1:33146 | GET / | Status: 200 | Duration: 2m19.967667151s

When I replace this call:

handler.ServeHTTP(wrapped, r)

with

handler.ServeHTTP(w, r)

Logs are as follows:

Client:

2025/11/10 19:43:52 Connecting to MCP server at http://localhost:8143
2025/11/10 19:43:52 Connected to server (session ID: CBYKSWW66XFLN43FQRLLPYQQGG)
2025/11/10 19:43:52 Listing available tools...
2025/11/10 19:43:52   - cityTime: Get the current time in NYC, San Francisco, or Boston
2025/11/10 19:43:52 Getting time for each city...
2025/11/10 19:43:52   The current time in New York City is 2025-11-10T09:43:52-05:00
2025/11/10 19:43:52   The current time in San Francisco is 2025-11-10T06:43:52-08:00
2025/11/10 19:43:52   The current time in Boston is 2025-11-10T09:43:52-05:00
2025/11/10 19:43:52 Client completed successfully

Server:

2025/11/10 19:43:49 MCP server listening on localhost:8143
2025/11/10 19:43:49 Available tool: cityTime (cities: nyc, sf, boston)
2025/11/10 19:43:52 [REQUEST] 2025-11-10T19:43:52+02:00 | 127.0.0.1:33752 | POST /
2025/11/10 19:43:52 [RESPONSE] 2025-11-10T19:43:52+02:00 | 127.0.0.1:33752 | POST / | Status: 200 | Duration: 785.3µs
2025/11/10 19:43:52 [REQUEST] 2025-11-10T19:43:52+02:00 | 127.0.0.1:33764 | GET /
2025/11/10 19:43:52 [REQUEST] 2025-11-10T19:43:52+02:00 | 127.0.0.1:33778 | POST /
2025/11/10 19:43:52 [RESPONSE] 2025-11-10T19:43:52+02:00 | 127.0.0.1:33778 | POST / | Status: 200 | Duration: 69.7µs
2025/11/10 19:43:52 [REQUEST] 2025-11-10T19:43:52+02:00 | 127.0.0.1:33778 | POST /
2025/11/10 19:43:52 [RESPONSE] 2025-11-10T19:43:52+02:00 | 127.0.0.1:33778 | POST / | Status: 200 | Duration: 450.2µs
2025/11/10 19:43:52 [REQUEST] 2025-11-10T19:43:52+02:00 | 127.0.0.1:33790 | POST /
2025/11/10 19:43:52 [RESPONSE] 2025-11-10T19:43:52+02:00 | 127.0.0.1:33790 | POST / | Status: 200 | Duration: 374.1µs
2025/11/10 19:43:52 [REQUEST] 2025-11-10T19:43:52+02:00 | 127.0.0.1:33796 | POST /
2025/11/10 19:43:52 [RESPONSE] 2025-11-10T19:43:52+02:00 | 127.0.0.1:33796 | POST / | Status: 200 | Duration: 6.6927ms
2025/11/10 19:43:52 [REQUEST] 2025-11-10T19:43:52+02:00 | 127.0.0.1:33806 | POST /
2025/11/10 19:43:52 [RESPONSE] 2025-11-10T19:43:52+02:00 | 127.0.0.1:33806 | POST / | Status: 200 | Duration: 444.2µs
2025/11/10 19:43:52 [REQUEST] 2025-11-10T19:43:52+02:00 | 127.0.0.1:33812 | DELETE /
2025/11/10 19:43:52 [RESPONSE] 2025-11-10T19:43:52+02:00 | 127.0.0.1:33764 | GET / | Status: 200 | Duration: 11.2963ms
2025/11/10 19:43:52 [RESPONSE] 2025-11-10T19:43:52+02:00 | 127.0.0.1:33812 | DELETE / | Status: 200 | Duration: 37.9µs
2025/11/10 19:43:52 [REQUEST] 2025-11-10T19:43:52+02:00 | 127.0.0.1:33764 | GET /
2025/11/10 19:43:52 [RESPONSE] 2025-11-10T19:43:52+02:00 | 127.0.0.1:33764 | GET / | Status: 200 | Duration: 27.1µs

The responseWriter wrapper breaks everything. Also shouldn't running the examples be a part of the CI workflow?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions