@@ -12,6 +12,7 @@ import (
1212 "time"
1313
1414 "github.com/github/github-mcp-server/pkg/github"
15+ "github.com/github/github-mcp-server/pkg/http/middleware"
1516 "github.com/github/github-mcp-server/pkg/http/oauth"
1617 "github.com/github/github-mcp-server/pkg/lockdown"
1718 "github.com/github/github-mcp-server/pkg/translations"
@@ -113,11 +114,20 @@ func RunHTTPServer(cfg ServerConfig) error {
113114 if err != nil {
114115 return fmt .Errorf ("failed to create OAuth handler: %w" , err )
115116 }
116- oauthHandler .RegisterRoutes (r )
117- logger .Info ("OAuth protected resource endpoints registered" , "baseURL" , cfg .BaseURL )
118117
119118 handler := NewHTTPMcpHandler (ctx , & cfg , deps , t , logger , WithOAuthConfig (oauthCfg ))
120- handler .RegisterRoutes (r )
119+
120+ // MCP routes with middleware
121+ r .Group (func (r chi.Router ) {
122+ r .Use (middleware .WithRequestConfig )
123+ handler .RegisterRoutes (r )
124+ })
125+
126+ // OAuth routes without MCP middleware
127+ r .Group (func (r chi.Router ) {
128+ oauthHandler .RegisterRoutes (r )
129+ })
130+ logger .Info ("OAuth protected resource endpoints registered" , "baseURL" , cfg .BaseURL )
121131
122132 addr := fmt .Sprintf (":%d" , cfg .Port )
123133 httpSvr := http.Server {
0 commit comments