mcp: refactor the streamable client test to be more flexible

Use a fake streamable server to facilitate testing client behavior.
For this commit, just update the existing test (moved to a new file for
isolation). Subsequent CLs will add more tests.

Improve one client error message that occurred while debuging tests.

For #393
This commit is contained in:
Rob Findley 2025-09-04 15:34:39 +00:00 • committed by Robert Findley
commit a4313f92bf

View file

@ -1234,7 +1234,14 @@ func (c *streamableClientConn) Write(ctx context.Context, msg jsonrpc.Message) e
default:
resp.Body.Close()
return fmt.Errorf("unsupported content type %q", ct)
switch msg := msg.(type) {
case *jsonrpc.Request:
return fmt.Errorf("unsupported content type %q when sending %q (status: %d)", ct, msg.Method, resp.StatusCode)
case *jsonrpc.Response:
return fmt.Errorf("unsupported content type %q when sending jsonrpc response #%d (status: %d)", ct, msg.ID, resp.StatusCode)
default:
panic("unreachable")
}
}
return nil
}