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

Function defaultReceivingMethodHandler

mcp/shared.go:148–155  ·  view source on GitHub ↗

defaultReceivingMethodHandler is the initial MethodHandler for servers and clients, before being wrapped by middleware.

(ctx context.Context, method string, req Request)

Source from the content-addressed store, hash-verified

146
147// defaultReceivingMethodHandler is the initial MethodHandler for servers and clients, before being wrapped by middleware.
148func defaultReceivingMethodHandler[S Session](ctx context.Context, method string, req Request) (Result, error) {
149 info, ok := req.GetSession().receivingMethodInfos()[method]
150 if !ok {
151 // This can be called from user code, with an arbitrary value for method.
152 return nil, jsonrpc2.ErrNotHandled
153 }
154 return info.handleMethod(ctx, method, req)
155}
156
157func handleReceive[S Session](ctx context.Context, session S, jreq *jsonrpc.Request) (Result, error) {
158 info, err := checkRequest(jreq, session.receivingMethodInfos())

Callers

nothing calls this directly

Calls 2

receivingMethodInfosMethod · 0.65
GetSessionMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…