docs: fix middleware example function signature (#236)
- Correct MethodHandler type parameter to use fully qualified mcp.ServerSession - Update parameter types to use proper mcp.Params and mcp.Result instead of any - Ensure example code matches the actual API
This commit is contained in:
parent
90a0b1fb23
commit
31c18fba2d
1 changed files with 2 additions and 2 deletions
|
|
@ -456,8 +456,8 @@ func (s *Server) AddReceivingMiddleware(middleware ...Middleware[*ServerSession]
|
|||
As an example, this code adds server-side logging:
|
||||
|
||||
```go
|
||||
func withLogging(h mcp.MethodHandler[*ServerSession]) mcp.MethodHandler[*ServerSession]{
|
||||
return func(ctx context.Context, s *mcp.ServerSession, method string, params any) (res any, err error) {
|
||||
func withLogging(h mcp.MethodHandler[*mcp.ServerSession]) mcp.MethodHandler[*mcp.ServerSession]{
|
||||
return func(ctx context.Context, s *mcp.ServerSession, method string, params mcp.Params) (res mcp.Result, err error) {
|
||||
log.Printf("request: %s %v", method, params)
|
||||
defer func() { log.Printf("response: %v, %v", res, err) }()
|
||||
return h(ctx, s , method, params)
|
||||
|
|
|
|||
Loading…
Reference in a new issue