API Reference

opinionated_mcp: Zero-config OAuth for MCP servers

Opinionated decisions: - Google OAuth only - Fernet-encrypted user ID cookies - Automatic auth redirects - PKCE with no client secrets - FastAPI + FastMCP integration

class opinionated_mcp.OpinionatedMCP(name: str, google_client_id: str, session_key: str, base_url: str, host: str = 'localhost', port: int = 8000)[source]

Zero-config OAuth MCP server with Google auth

authenticated_endpoint(path: str, methods: list = ['GET'])[source]

Create an authenticated FastAPI endpoint that receives user_id

property redirect_uri: str

Generate redirect URI from base URL

require_auth(func)[source]

Decorator to require authentication for MCP tools

reset_session_key(new_session_key: str)[source]

Rotate the session key (invalidates all existing sessions)

run(**kwargs)[source]

Run the server

tool(**kwargs)[source]

Register an MCP tool (proxies to FastMCP)

opinionated_mcp.generate_session_key() str[source]

Generate a session key for Fernet encryption