MCP with OAuth
About
Reference https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/weather/starter-webmvc-oauth2-server
Details
- Author
- akshay12390
- Downloads
- 204
- Categories
- Media
Jump to
- OAuth2 client credentials flow support
- OAuth2 authorization code with PKCE flow
- Token issuance via Spring Authorization Server
- Token validation using Spring Security Resource Server
- Ready-to-run Spring Boot sample
- MCP Inspector integration for testing
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
MCP with OAuthCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
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.
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"mcp with oauth": {
"mcp-weather-oauth2-server": {
"command": "npx",
"args": [
"@modelcontextprotocol/inspector@0.6.0"
]
}
}
}
}
McpServers
{
"mcp-weather-oauth2-server": {
"command": "npx",
"args": [
"@modelcontextprotocol/inspector@0.6.0"
]
}
}
MCP with OAuth
This sample demonstrates how to secure an MCP server using OAuth2, as per
the MCP specification.
Getting started
Run the project with:
./mvnw spring-boot:run
Client Credentials
Obtain a token by calling the/oauth2/token endpoint:
```shell
curl -XPOST "http://localhost:8080/oauth2/token" \
--data grant_type=client_credentials \
--user "mcp-client:secret"
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.
