The article discusses how to implement OAuth2 authorization in Spring AI MCP Servers by using standalone Authorization Servers.
The latest revision of the MCP Security specification simplifies the process by allowing external Authorization Servers to issue access tokens to MCP Servers.
The blog post goes through securing the MCP Server by adding OAuth2 support using Spring Boot and Spring Security.
Configurations for making the MCP Server an OAuth2 Resource Server are outlined, including setting the issuer URI of the Authorization Server.
To build an OAuth2 Authorization Server, dependencies are specified, and configuration settings in application.yml are provided.
For setting up an MCP client, additional security considerations are discussed, including adding OAuth2 to the MCP Client using WebClient.
The article details configuring OAuth2 clients for different grant types and explains the usage of authorization_code and client_credentials.
Custom configurations and implementations involving Spring Security's SecurityFilterChain and ExchangeFilterFunction are shared for adding OAuth2 to MCP Clients.
By following the provided setup, one can securely interact with the MCP Server and Authorization Server to execute actions like Weather MCP tool calls.
Future plans include simplifying OAuth2 integration for Spring AI MCP Servers and enhancing permissions for different tools/resources within MCP Servers.