1 What you'll learn
Everything the TypeScript MCP tutorial teaches, on FastMCP and payments-py.
- Protect a Python MCP server with Nevermined using FastMCP
- Serve full OAuth 2.1 discovery (RFC 8414 / 9728) endpoints
- Pay per use with credits via x402 tokens
- Optionally enrich forecasts with OpenAI gpt-4o-mini
2 How it works
Same protocol surface as the TypeScript server — weather.today tool, weather://today resource, weather.ensureCity prompt — with the Bearer-authenticated session and in-band _meta payment. Requires payments-py[fastapi] ≥ 1.15.
Bearer sessionOAuth 2.1
call tool_meta x402/payment
check + deductcredits
resultweather
3 Under the hood
Python 3.10+FastMCPpayments-py[fastapi] ≥ 1.15PoetryOpenAI
# MCP surface
weather.today # tool — current weather for any city
weather://today # resource — static weather data
weather.ensureCity # prompt — guide the LLM to request weather| src/ | FastMCP server with Nevermined payments + OAuth discovery |
| README.md | installation and configuration |
4 See it run
Sandbox agent — real payment round-trips (402 → authorize → settle) with a per-session credit balance, no external service and no real money. Same MCP flow on FastMCP (Python); the sandbox runs the exchange locally. See the README to connect a hosted weather-mcp-py server.