examples: Update and fix outdated (#420)

Update examples/server/rate-limiting to use the same replace directive
strategy as the auth-middleware example, and fix the breakages.

Also remove the unneeded type parameters in examples/client/middleware.
This commit is contained in:
Kason Braley 2025-09-05 04:58:26 -07:00 • committed by GitHub
commit b774809086
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -17,10 +17,10 @@ var nextProgressToken atomic.Int64
// from the client.
func main() {
c := mcp.NewClient(&mcp.Implementation{Name: "test"}, nil)
c.AddSendingMiddleware(addProgressToken[*mcp.ClientSession])
c.AddSendingMiddleware(addProgressToken)
}
func addProgressToken[S mcp.Session](h mcp.MethodHandler) mcp.MethodHandler {
func addProgressToken(h mcp.MethodHandler) mcp.MethodHandler {
return func(ctx context.Context, method string, req mcp.Request) (result mcp.Result, err error) {
if rp, ok := req.GetParams().(mcp.RequestParams); ok {
rp.SetProgressToken(nextProgressToken.Add(1))