@@ -92,7 +92,6 @@ func verifyJWT(ctx context.Context, tokenString string) (*auth.TokenInfo, error)
9292 }
9393 return jwtSecret , nil
9494 })
95-
9695 if err != nil {
9796 // Return standard error for invalid tokens.
9897 return nil , fmt .Errorf ("%w: %v" , auth .ErrInvalidToken , err )
@@ -207,19 +206,6 @@ func CreateResource(ctx context.Context, req *mcp.CallToolRequest, args createRe
207206 }, nil , nil
208207}
209208
210- // authMiddleware extracts token information and adds it to the context
211- func authMiddleware (next http.Handler ) http.Handler {
212- return http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
213- // In a real application, you would extract token info from the auth middleware's context
214- // For this example, we simulate the token info that would be available
215- ctx := context .WithValue (r .Context (), "user_info" , & auth.TokenInfo {
216- Scopes : []string {"read" , "write" },
217- Expiration : time .Now ().Add (time .Hour ),
218- })
219- next .ServeHTTP (w , r .WithContext (ctx ))
220- })
221- }
222-
223209// createMCPServer creates an MCP server with authentication-aware tools
224210func createMCPServer () * mcp.Server {
225211 server := mcp .NewServer (& mcp.Implementation {Name : "authenticated-mcp-server" }, nil )
@@ -264,8 +250,8 @@ func main() {
264250 }, nil )
265251
266252 // Apply authentication middleware to the MCP handler.
267- authenticatedHandler := jwtAuth (authMiddleware ( handler ) )
268- apiKeyHandler := apiKeyAuth (authMiddleware ( handler ) )
253+ authenticatedHandler := jwtAuth (handler )
254+ apiKeyHandler := apiKeyAuth (handler )
269255
270256 // Create router for different authentication methods.
271257 http .HandleFunc ("/mcp/jwt" , authenticatedHandler .ServeHTTP )
0 commit comments