Skip to content

Commit 2ccfae9

Browse files
ChrisJBurnsclaude
andauthored
Carry RateLimitMiddleware through vMCP buildServeConfig (#5500)
#5276 added Config.RateLimitMiddleware and wired it on the New/Config path, but the parallel Serve/ServerConfig migration API was not extended: ServerConfig had no RateLimitMiddleware field and buildServeConfig did not map it, so TestBuildServeConfigMapsSharedFields fails on main and the Serve path would silently drop rate limiting. Add the field to ServerConfig, map it in buildServeConfig, and set it in the completeness test's source config so a dropped mapping keeps failing the test. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 8da9029 commit 2ccfae9

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

pkg/vmcp/server/serve.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ type ServerConfig struct {
6969
// If nil, no authentication is required.
7070
AuthMiddleware func(http.Handler) http.Handler
7171

72+
// RateLimitMiddleware is the optional rate-limit middleware to apply after
73+
// authentication and MCP request parsing.
74+
RateLimitMiddleware func(http.Handler) http.Handler
75+
7276
// AuthInfoHandler is the optional handler for the
7377
// /.well-known/oauth-protected-resource endpoint.
7478
AuthInfoHandler http.Handler
@@ -302,6 +306,7 @@ func buildServeConfig(cfg *ServerConfig) *Config {
302306
EndpointPath: cmp.Or(cfg.EndpointPath, defaultEndpointPath),
303307
SessionTTL: cmp.Or(cfg.SessionTTL, defaultSessionTTL),
304308
AuthMiddleware: cfg.AuthMiddleware,
309+
RateLimitMiddleware: cfg.RateLimitMiddleware,
305310
AuthInfoHandler: cfg.AuthInfoHandler,
306311
AuthServer: cfg.AuthServer,
307312
TelemetryProvider: cfg.TelemetryProvider,

pkg/vmcp/server/serve_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ func TestBuildServeConfigMapsSharedFields(t *testing.T) {
347347
EndpointPath: "/e",
348348
SessionTTL: time.Second,
349349
AuthMiddleware: func(h http.Handler) http.Handler { return h },
350+
RateLimitMiddleware: func(h http.Handler) http.Handler { return h },
350351
AuthInfoHandler: http.NewServeMux(),
351352
AuthServer: &asrunner.EmbeddedAuthServer{},
352353
HealthMonitor: &health.Monitor{},

0 commit comments

Comments
 (0)