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.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

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.

上游原版 README

在 GitHub 查看同一版本原文

README.md · a8096ad6dfe1 · 采集于 2026-11-13 13:56:30 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

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.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

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