Pydantic AI MCP OAuth — AI skill for Claude Code
A runnable, fully offline example of a pydantic-ai Agent calling an OAuth-protected MCP server over streamable HTTP (pydantic-ai 2.x, mcp 2.x).
How to install Pydantic AI MCP OAuth
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open TB0515/pydantic-ai-mcp-oauth and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
What Pydantic AI MCP OAuth does
A runnable, fully offline example of a pydantic-ai Agent calling an OAuth-protected MCP server over streamable HTTP (pydantic-ai 2.x, mcp 2.x). It answers the public request in pydantic/pydantic-ai#19 [Built entirely by AI agents]
Alternatives in AI
- Osaurus — Own your AI. The native macOS harness for AI agents -- any model, persistent memory, autonomous execution, cry 5.1k ★
- Upstream Watch — Review pydantic-ai and pydantic-ai-harness releases published since the last watch entry, and record a verdict 361 ★
- Execute Pydantic AI Prp — Execute Pydantic AI Agent PRP 132 ★
README
pydantic-ai-mcp-oauth
**Built by autonomous AI agents (Kiln); not affiliated with Pydantic.** Written, reviewed and maintained by AI agents (Claude, by Anthropic). Issues are read by AI agents.
A small, fully offline example of a [pydantic-ai](https://github.com/pydantic/pydantic-ai) `Agent` calling an **OAuth-protected MCP server** over streamable HTTP. It answers [pydantic/pydantic-ai#1957](https://github.com/pydantic/pydantic-ai/issues/1957). No API keys, no external network (127.0.0.1 only). Targets pydantic-ai-slim 2.68.0 and mcp 2.3.0.
Tested with pydantic-ai 2.68.0 (pydantic-ai-slim 2.68.0) and mcp 2.3.0 on 2026-11-17.
Quickstart
python3.12 -m venv .venv && . .venv/bin/activate && pip install -r requirements.txt
python server.py # terminal 1: MCP server + toy token issuer on 127.0.0.1:8000
python agent.py # terminal 2: prints the tool result (uses TestModel, no key)
Run the tests (they start their own server): `pytest -q`. They check no token → 401 with `WWW-Authenticate`, bad token → 401, good token → the agent's tool call succeeds.
How the auth flow works
Agent Toy issuer (/token) MCP server (/mcp)
| POST client_credentials | |
|------------------------>| |
|<-- access_token --------| |
| MCPToolset(url, auth=token) -> Authorization: Bearer
|---------------------------------------------> | TokenVerifier.verify_token()
|<-- 401 + WWW-Authenticate (missing/bad token) | or 200 + tool results
server.py:mcp.server.mcpserver.MCPServer(token_verifier=..., auth=AuthSettings(...))makes the/mcpendpoint require a bearer token. The SDK's middleware sends the 401 andWWW-Authenticateheader.agent.py: fetches a token, thenMCPToolset(url, auth=token)attaches it to every MCP request.
Swap in a real OAuth provider
The `/token` endpoint and `ToyVerifier` in `server.py` are a **demo iss
Related Skills
Orbit Support Agent
A small, runnable demo of the one idea that changed in Pydantic AI 2.0: you stop
Ghidra MCP
Remote claude.ai MCP connector for Ghidra — headless daemon with OAuth 2.1 + SSE/Streamable-HTTP, deployable o
MCP Starter Kit
Build a secure, production-ready MCP server for any project — connect Claude, ChatGPT & any AI agent to your b
LLM Routing And Judge Eval Harness Pattern
Pattern guide for provider-agnostic LLM routing with deterministic offline fallback, plus a runnable LLM-as-ju
AI Parody Video Claude Code
Worked example: an AI-generated parody video made end to end by a coding agent (Claude Code) from one request,
Retriva
Self-hosted, production-ready RAG chatbot agent — upload documents, get accurate AI answers with citations, ag
Related Agents
Code API Contract
API / contract reviewer in the Code Review Board — request/response contracts, the schema pipeline from server
MCP Integrator
Decides what tool or data access a task needs and how to wire it via MCP, preferring an existing server over a
Boilerplate Renamer
Zero-logic changes only: renames of symbols, files, routes and keys in every case form; moves with import fixe