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

Method AddSendingMiddleware

mcp/server.go:1337–1341  ·  view source on GitHub ↗

AddSendingMiddleware wraps the current sending method handler using the provided middleware. Middleware is applied from right to left, so that the first one is executed first. For example, AddSendingMiddleware(m1, m2, m3) augments the method handler as m1(m2(m3(handler))). Sending middleware is ca

(middleware ...Middleware)

Source from the content-addressed store, hash-verified

1335// Sending middleware is called when a request is sent. It is useful for tasks
1336// such as tracing, metrics, and adding progress tokens.
1337func (s *Server) AddSendingMiddleware(middleware ...Middleware) {
1338 s.mu.Lock()
1339 defer s.mu.Unlock()
1340 addMiddleware(&s.sendingMethodHandler_, middleware)
1341}
1342
1343// AddReceivingMiddleware wraps the current receiving method handler using
1344// the provided middleware. Middleware is applied from right to left, so that the

Callers 1

TestMiddlewareFunction · 0.95

Calls 1

addMiddlewareFunction · 0.85

Tested by 1

TestMiddlewareFunction · 0.76