What dependencies are needed to add OAuth2 to an MCP server?
The sample uses Spring Security (infrastructure), Spring Authorization Server (token issuance), and Spring Security OAuth2 Resource Server (token-based authentication).
@akshay12390
Basic information
Reference https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/weather/starter-webmvc-oauth2-server
Add this server to your MCP-compatible client using the configuration below.
{
"mcpServers": {
"mcp-weather-oauth2-server": {
"command": "npx",
"args": [
"@modelcontextprotocol/inspector@0.6.0"
]
}
}
}Tool list not available yet
This listing does not currently have a tool list to display. This does not mean the server has no tools; check its documentation for supported capabilities.
Fetch the live tool list by running this server in a temporary sandbox using the button above.
MCP with OAuth is a sample project that demonstrates how to secure an MCP (Model Context Protocol) server using OAuth2, following the MCP specification’s authorization section. It is intended for developers who need to add OAuth2 authentication to an MCP server.
Run the project with ./mvnw spring-boot:run. Obtain tokens via client credentials or auth code (PKCE). For client credentials, call /oauth2/token with grant_type=client_credentials and authenticate as mcp-client:secret. For PKCE, first run pkce_generator.py and then token_request.py. Use the token with the MCP inspector (npx @modelcontextprotocol/inspector@0.6.0) by pasting it and clicking connect.
The sample uses Spring Security (infrastructure), Spring Authorization Server (token issuance), and Spring Security OAuth2 Resource Server (token-based authentication).
Tokens are valid for 15 minutes.
No. Spring Authorization Server does not support the reactive stack, so issuing tokens only works in Servlet environments.
Store the token obtained from the `/oauth2/token` endpoint, boot the MCP inspector (`npx @modelcontextprotocol/inspector@0.6.0`), paste the token, and click connect.

Built by movie lovers, for movie lovers and their assistants. SceneF puts every screen in California and Hawaii on one board — 33 regions, from San Francisco's single-screen neighborhood houses and nightly repertory cale

Turn your songs into lyric videos (9:16, 16:9, 1:1) and Spotify Canvas loops. Find a song, browse Looks, get an exact credit quote, and render only after you say yes.

Run complete AI fashion photoshoots from ChatGPT, Claude, or Codex. Turn flat-lay, packshot, and mannequin product images into catalog-ready on-model photos and video with saved art direction, automatic QA, and catalog-s

Make AI videos, images, voiceovers and full AI Video Story episodes from Claude, ChatGPT, Cursor or any MCP client, then post them to TikTok, YouTube and Instagram. Veo, Kling, Seedance and more, on your own aicut accoun

EveryGen AI MCP Server lets AI assistants create videos, images, voiceovers, music and complete multi-shot films. Connect your EveryGen AI account, describe what you want, review the credit quote and approve the creation
Comments