Shipra Alerts MCP Server — Portfolio Case Study
portfolio — backend MCP integration
Shipra Alerts MCP Server
Stock alerts, AI-callable.
A Python MCP server that bridges AI assistants to the Shipra stock alert platform — exposing authenticated tools for retrieving alerts, creating complex technical conditions, and fetching user data through a deployable FastMCP HTTP service.
Python 3.12
FastMCP
MCP SDK
OAuth 2.1 / JWT
Pydantic
Uvicorn
HTTPX
JWKS Discovery
uv
overview
Configuring stock alerts on a financial platform typically means filling out multiple forms with technical parameters — thresholds, ranges, expiry rules, notification preferences, and ticker targets. This project removes that friction by exposing those operations as MCP tools an AI assistant can call directly from natural language. A user asking for an RSI alert on a stock gets a validated, authenticated API call behind the scenes — no form navigation required.
how it works
User
Natural language request
"Create an RSI alert for AAPL when it drops below 30."
→
MCP Server
Tool dispatch + auth
FastMCP routes the call, verifies the JWT, resolves user context, and builds a typed payload.
→
Shipra API
Alert created
Validated API request sent to the Shipra backend under the authenticated user's account.
MCP tools
Alert management
retrieve_alertsAll active alerts for the authenticated user
retrieve_alertSingle alert lookup by ID
create_rsi_alertRSI threshold, range, and historical extreme conditions
create_price_alertPrice movement, crossings, 52-week proximity, open-price behavior
create_drawdown_alertRecovery, fall-below, surpass, and historical approach
create_dma_alertDMA touch, proximity, rise/fall %, and sustained conditions
create_pe_alertPE threshold, range, historical high/low, and trend
create_opportunity_alertUpward and downward opportunity signal conditions
User data
retrieve_user_tagsFetches tags from the user's Shipra account
whoamiReturns the authenticated user's identity
alert types supported
RSI
Threshold, range, and historical extreme conditions
Price
Movement direction, crossings, 52-week proximity, daily close, open-price
Drawdown
Recovery, fall-below, surpass, and historical approach
DMA
Touch, proximity, rise/fall percentage, sustained above/below
PE Ratio
Threshold, range, historical high/low, and trend conditions
Opportunity
Upward and downward opportunity signal detection
module structure
| mcp_main.py | FastMCP server entry point — configures auth settings and registers all tools |
| auth.py | OAuth token verification, JWKS discovery and caching, JWT validation, request-scoped user context |
| tools/alerts_tools.py | MCP alert tool definitions exposed to AI clients |
| tools/tags_tools.py | User tag retrieval tool |
| services/api.py | Shipra backend API calls for alerts and tags |
| services/create_alert.py | Reusable payload builders per alert condition type |
| server.py | Streamable HTTP server entry point via Uvicorn |
implementation highlights
01Implemented request-scoped user context so every tool call operates on the correct authenticated user — JWT verification happens at the request boundary, not globally, keeping tool logic clean and user-safe.
02Built JWKS caching into the auth layer so token verification doesn't re-fetch the authorization server's public keys on every tool call — reducing latency and external dependency in hot paths.
03Separated alert payload construction into dedicated builder functions per condition type, keeping tool definitions thin and making it straightforward to add new alert categories without touching MCP registration.
04Supported both production OAuth flow and a dev-mode token fallback, making local development and MCP Inspector testing practical without bypassing auth architecture.
05Structured the server for flexible deployment — runnable locally with `uv`, hostable under Uvicorn, reversible behind a proxy, and configurable as a Claude Desktop MCP remote endpoint.
deployment
Local (uv)
uv run python server.py
Uvicorn
uv run uvicorn server:app --host 0.0.0.0 --port 8000
Claude Desktop
mcp-remote config
MCP Inspector
dev token fallback
full tech stack
Python 3.12FastMCPMCP Python SDKUvicornPydanticHTTPXRequestsOAuth 2.1JWTJWKS Discoveryuv