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

Method AddReceivingMiddleware

mcp/client.go:892–896  ·  view source on GitHub ↗

AddReceivingMiddleware wraps the current receiving method handler using the provided middleware. Middleware is applied from right to left, so that the first one is executed first. For example, AddReceivingMiddleware(m1, m2, m3) augments the method handler as m1(m2(m3(handler))). Receiving middlewa

(middleware ...Middleware)

Source from the content-addressed store, hash-verified

890// Receiving middleware is called when a request is received. It is useful for tasks
891// such as authentication, request logging and metrics.
892func (c *Client) AddReceivingMiddleware(middleware ...Middleware) {
893 c.mu.Lock()
894 defer c.mu.Unlock()
895 addMiddleware(&c.receivingMethodHandler_, middleware)
896}
897
898// clientMethodInfos maps from the RPC method name to serverMethodInfos.
899//

Callers 2

TestMiddlewareFunction · 0.95

Calls 1

addMiddlewareFunction · 0.85

Tested by 2

TestMiddlewareFunction · 0.76