akshay12390
MCP Serverakshay12390public

mcp weather oauth2 server

Reference https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/weather/starter-webmvc-oauth2-server

Repository Info

0
Stars
0
Forks
0
Watchers
0
Issues
Java
Language
-
License

About This Server

Reference https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/weather/starter-webmvc-oauth2-server

Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.

Documentation

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.

Quick Start

1

Clone the repository

git clone https://github.com/akshay12390/mcp-weather-oauth2-server
2

Install dependencies

cd mcp-weather-oauth2-server
npm install
3

Follow the documentation

Check the repository's README.md file for specific installation and usage instructions.

Repository Details

Ownerakshay12390
Repomcp-weather-oauth2-server
LanguageJava
License-
Last fetched8/10/2025

Recommended MCP Servers

💬

Discord MCP

Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.

integrationsdiscordchat
🔗

Knit MCP

Connect AI agents to 200+ SaaS applications and automate workflows.

integrationsautomationsaas
🕷️

Apify MCP Server

Deploy and interact with Apify actors for web scraping and data extraction.

apifycrawlerdata
🌐

BrowserStack MCP

BrowserStack MCP Server for automated testing across multiple browsers.

testingqabrowsers

Zapier MCP

A Zapier server that provides automation capabilities for various apps.

zapierautomation