Auth-Agent MCP - Python SDK
OAuth 2.1 authentication middleware for MCP servers using FastAPI.
Installation
pip install auth-agent-mcp
Quick Start
from fastapi import FastAPI, Request
from auth_agent_mcp import AuthAgentMiddleware
import os
app = FastAPI()
# Add Auth-Agent authentication
app.add_middleware(
AuthAgentMiddleware,
auth_server=os.getenv("AUTH_SERVER", "https://mcp.auth-agent.com"),
server_id=os.getenv("SERVER_ID"),
api_key=os.getenv("API_KEY"),
required_scopes=["files:read"],
)
@app.get("/files")
async def list_files(request: Request):
# User context injected by middleware
user_email = request.state.user_email
scopes = request.state.scopes
return {
"user": user_email,
"files": ["document.txt", "image.png"]
}
Configuration
Environment Variables
AUTH_SERVER=https://mcp.auth-agent.com
SERVER_ID=srv_abc123
API_KEY=sk_xyz789
Middleware Parameters
auth_server(str): Auth-Agent server URL (default: https://mcp.auth-agent.com)server_id(str): Your MCP server ID from registrationapi_key(str): API key for token validationrequired_scopes(List[str]): Scopes required for all endpointspublic_paths(List[str]): Paths that don't require authentication
Manual Token Validation
from auth_agent_mcp import AuthAgentClient
client = AuthAgentClient(
auth_server="https://mcp.auth-agent.com",
api_key="sk_xyz789"
)
# Introspect token
result = await client.introspect_token("eyJhbG...")
if result["active"]:
print(f"Valid token for user: {result['sub']}")
print(f"Scopes: {result['scope']}")
print(f"Audience: {result['aud']}")
# Revoke token
await client.revoke_token("eyJhbG...")
License
MIT
Metadata
Release files for auth-agent-mcp 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| auth_agent_mcp-1.0.0.tar.gz | 5.3 kB | Without provenance | Details for auth_agent_mcp-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| auth_agent_mcp-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for auth_agent_mcp-1.0.0-py3-none-any.whl |
Total release size: 10.8 kB
Release files / auth_agent_mcp-1.0.0.tar.gz
| Download URL | auth_agent_mcp-1.0.0.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
583721c7569ff20d3ecbbcfec23f01e023e748fd4c05f834918bf77b380f67b7
|
|
BLAKE2b-256 checksum How to use checksums |
72e79d6a2a108ada4b62f69be9a07127c0126953509f8dfdb579e4fffe270e46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Release files / auth_agent_mcp-1.0.0-py3-none-any.whl
| Download URL | auth_agent_mcp-1.0.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cfb5f0c174606c249fddb6a13d279d0d1dc63b123fa9abc292e70ef71a706610
|
|
BLAKE2b-256 checksum How to use checksums |
ee7839d209b833128575da3c70a858e94b39bffeb32444a675217dc64765baf9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Security for auth-agent-mcp 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.