MCP with OAuth
About
A sample project demonstrating how to secure an MCP server using OAuth2, following the MCP specification’s authorization section. It is built with Spring Boot and Spring Security.
Details
- Author
- akshay12390
- Downloads
- 157
- Categories
- Developer Tools
Jump to
- OAuth2 client credentials flow for token issuance
- Token validation via Spring Security OAuth2 Resource Server
- Token expiration set to 5 minutes
- Works only in the servlet stack (no reactive support for token issuance)
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 server with ./mvnw spring-boot:run. Obtain an access token by calling POST /oauth2/token with grant_type=client_credentials and the client ID/secret oidc-client:secret. Then paste the token into the MCP Inspector (v0.6.0) to connect.
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"mcp with oauth": {
"mcp-weather-starter-webmvc-oauth2-server": {
"command": "npx",
"args": [
"@modelcontextprotocol/inspector@0.6.0"
]
}
}
}
}
McpServers
{
"mcp-weather-starter-webmvc-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
Obtain a token by calling the /oauth2/token endpoint:
```shell
curl -XPOST "http://localhost:8080/oauth2/token" \
--data grant_type=client_credentials \
--user "oidc-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.





