Skip to content

one toolcall request so many middware Added??? #174

@followheart26

Description

@followheart26
			var withValidate = func(h mcp.MethodHandler[*mcp.ServerSession]) mcp.MethodHandler[*mcp.ServerSession] {
				return func(ctx context.Context, s *mcp.ServerSession, method string, params mcp.Params) (result mcp.Result, err error) {
					if method != "tools/call" {
						return h(ctx, s, method, params)
					}
					token := request.Header.Get(AuthorizationHeader)
					golib.Log("info", "token:%s added to ctx, seesionId: %s", token, s.ID())
					ctx = context.WithValue(ctx, "token", token)
					return h(ctx, s, method, params)
				}
			}
			o.svr.AddReceivingMiddleware(withValidate)
			return o.svr
		}, nil)

when several requests from different process with dfferent token sent to the server , finally if i send a toolcall request, the middleware log happened 12 times, and the token has been covered many times?
is this a bug?
Or may be i can't do something like this.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions