OAuth2-secured MCP server sample

OAuth2-secured MCP server sample

mcp-weather-starter-webmvc-oauth2-server•byakshay12390

A sample Spring Boot application that demonstrates securing an MCP server with OAuth2, including client credentials and authorization code flows.

License: Not specified•Runtime: Awaiting documentation review•Category: auth security

WHAT IT DOES

  • •Demonstrates securing an MCP server using OAuth2 in line with the MCP authorization specification.
  • •Supports obtaining access tokens through the client credentials grant via the token endpoint.
  • •Supports an authorization code flow with PKCE for browser-based token acquisition.
  • •Issues short-lived tokens that remain valid for 15 minutes.

BEST FOR

  • •Developers who want to learn how to add OAuth2 security to an MCP server built with Spring.
  • •Teams exploring token issuance and token-based authentication for MCP servers using Spring Security components.

ABOUT MCP-WEATHER-STARTER-WEBMVC-OAUTH2-SERVER

OAuth2-secured MCP server sample is cataloged as an MCP server attributed to akshay12390. A sample Spring Boot application that demonstrates securing an MCP server with OAuth2, including client credentials and authorization code flows. It is categorized under auth security. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: Not specified. Check the source repository's current license and terms before using, modifying or distributing this software.

Capability inspector

Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.

Tools (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Resources (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Prompts (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for OAuth2-secured MCP server sample are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

Which grant types are shown for obtaining tokens?

The sample shows the client credentials grant through the token endpoint and an authorization code flow with PKCE for the browser.

How long is an issued token valid?

The README states that the token is valid for 15 minutes.

Upstream README

View this exact version on GitHub

README.md · a8096ad6dfe1 · Fetched 2026-11-13 13:56:30 UTC

Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.

Showing the last retrieved documentation snapshot; check the source for current changes.

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:

curl -XPOST "http://localhost:8080/oauth2/token" \
  --data grant_type=client_credentials \
  --user "mcp-client:secret"
# And copy-paste the access token
# Or use JQ:
curl -XPOST "http://localhost:8080/oauth2/token" \
  --data grant_type=client_credentials \
  --user "mcp-client:secret" | jq -r ".access_token"

Auth code with browser flow (PKCE)

Obtain a auth code by first calling authorize endpoint

python3 pkce_generator.py

and then fetch access token by calling the /oauth2/token endpoint

python3 token_request.py

Using MCP inspector

Store the generated token in previous step, and then boot up the MCP inspector:

npx @modelcontextprotocol/inspector@0.6.0

In the MCP inspector, paste your token. Click connect, and voilà!

Note that the token is valid for 15 minutes

Implementation considerations

Dependencies

In Spring, OAuth2 Support for MCP server means adding:

  1. Spring Security (infrastructure for security)
  2. Spring Authorization Server (issuing tokens)
  3. Spring Security: OAuth2 Resource Server ( authentication using tokens)

Note that Spring Auth Server does not support the reactive stack, so issuing tokens only works in Servlet.

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for OAuth2-secured MCP server sample from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/mcp-weather-starter-webmvc-oauth2-server)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

Downloads and pulls

Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.

No reviewed package or image identity; download statistics are not listed yet.

Related auth security MCP Servers

Alternative and complementary servers in the same category

View all in auth security →

A modular FastMCP server for interacting with Microsoft Graph API, supporting advanced queries for users, sign-in logs, MFA status, and privileged users.

Repository stats unavailable
Security & Secrets
Keycloak MCP Server
keycloak-mcp-server•sshaaf

A Model Context Protocol (MCP) server that provides programmatic access to Keycloak administration functionality.

Repository stats unavailable
Security & Secrets

An MCP server for LLM-driven penetration testing that wraps Kali tools and adds scope enforcement, engagement tracking, and structured output.

Repository stats unavailable
Security & Secrets