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

Method Read

mcp/sse.go:464–483  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

462}
463
464func (c *sseClientConn) Read(ctx context.Context) (jsonrpc.Message, error) {
465 select {
466 case <-ctx.Done():
467 return nil, ctx.Err()
468
469 case <-c.done:
470 return nil, io.EOF
471
472 case data := <-c.incoming:
473 // TODO(rfindley): do we really need to check this? We receive from c.done above.
474 if c.isDone() {
475 return nil, io.EOF
476 }
477 msg, err := jsonrpc2.DecodeMessage(data)
478 if err != nil {
479 return nil, err
480 }
481 return msg, nil
482 }
483}
484
485func (c *sseClientConn) Write(ctx context.Context, msg jsonrpc.Message) error {
486 data, err := jsonrpc2.EncodeMessage(msg)

Callers

nothing calls this directly

Calls 4

isDoneMethod · 0.95
DecodeMessageFunction · 0.92
DoneMethod · 0.45
ErrMethod · 0.45

Tested by

no test coverage detected