diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a1647446f..e77593285 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v6 - uses: actions/setup-go@v6 with: - go-version: stable + go-version: '1.25' - name: golangci-lint uses: golangci/golangci-lint-action@v9 with: diff --git a/pkg/http/handler.go b/pkg/http/handler.go index df0b819fc..875d54bbb 100644 --- a/pkg/http/handler.go +++ b/pkg/http/handler.go @@ -31,6 +31,7 @@ type Handler struct { inventoryFactoryFunc InventoryFactoryFunc oauthCfg *oauth.Config scopeFetcher scopes.FetcherInterface + schemaCache *mcp.SchemaCache } type HandlerOptions struct { @@ -101,6 +102,10 @@ func NewHTTPMcpHandler( inventoryFactory = DefaultInventoryFactory(cfg, t, opts.FeatureChecker, scopeFetcher) } + // Create a shared schema cache to avoid repeated JSON schema reflection + // when a new MCP Server is created per request in stateless mode. + schemaCache := mcp.NewSchemaCache() + return &Handler{ ctx: ctx, config: cfg, @@ -112,6 +117,7 @@ func NewHTTPMcpHandler( inventoryFactoryFunc: inventoryFactory, oauthCfg: opts.OAuthConfig, scopeFetcher: scopeFetcher, + schemaCache: schemaCache, } } @@ -195,6 +201,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { Resources: &mcp.ResourceCapabilities{}, Prompts: &mcp.PromptCapabilities{}, } + so.SchemaCache = h.schemaCache }, }, })