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

Function EncodeMessage

internal/jsonrpc2/messages.go:148–156  ·  view source on GitHub ↗
(msg Message)

Source from the content-addressed store, hash-verified

146}
147
148func EncodeMessage(msg Message) ([]byte, error) {
149 wire := wireCombined{VersionTag: wireVersion}
150 msg.marshal(&wire)
151 data, err := jsonMarshal(&wire)
152 if err != nil {
153 return nil, fmt.Errorf("marshaling jsonrpc message: %w", err)
154 }
155 return data, nil
156}
157
158// EncodeIndent is like EncodeMessage, but honors indents.
159// TODO(rfindley): refactor so that this concern is handled independently.

Callers 14

TestWireMessageFunction · 0.92
doMethod · 0.92
TestStreamableGETFunction · 0.92
ReadMethod · 0.92
WriteMethod · 0.92
WriteMethod · 0.92
marshalMessagesFunction · 0.92
servePOSTMethod · 0.92
WriteMethod · 0.92
jsonBodyFunction · 0.92
WriteMethod · 0.92

Calls 2

jsonMarshalFunction · 0.85
marshalMethod · 0.65

Tested by 5

TestWireMessageFunction · 0.74
doMethod · 0.74
TestStreamableGETFunction · 0.74
jsonBodyFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…