MCPcopy Create free account
hub / github.com/modelcontextprotocol/go-sdk / handleJSON

Method handleJSON

mcp/streamable.go:1960–1977  ·  view source on GitHub ↗
(requestSummary string, resp *http.Response)

Source from the content-addressed store, hash-verified

1958}
1959
1960func (c *streamableClientConn) handleJSON(requestSummary string, resp *http.Response) {
1961 body, err := io.ReadAll(resp.Body)
1962 resp.Body.Close()
1963 if err != nil {
1964 c.fail(fmt.Errorf("%s: failed to read body: %v", requestSummary, err))
1965 return
1966 }
1967 msg, err := jsonrpc.DecodeMessage(body)
1968 if err != nil {
1969 c.fail(fmt.Errorf("%s: failed to decode response: %v", requestSummary, err))
1970 return
1971 }
1972 select {
1973 case c.incoming <- msg:
1974 case <-c.done:
1975 // The connection was closed by the client; exit gracefully.
1976 }
1977}
1978
1979// handleSSE manages the lifecycle of an SSE connection. It can be either
1980// persistent (for the main GET listener) or temporary (for a POST response).

Callers 1

WriteMethod · 0.95

Calls 3

failMethod · 0.95
DecodeMessageFunction · 0.92
CloseMethod · 0.65

Tested by

no test coverage detected