OAuth 2.0 Authorization Code connector for the Model Context Standard.
Project description
mcs-auth-oauth
OAuth 2.0 for AI agents. Authorization Code Flow with PKCE connector for the Model Context Standard (MCS).
A 5-second localhost callback server and your agent has an OAuth token. Works with any OAuth 2.0 provider -- Google, Auth0, Microsoft, GitHub, you name it.
Installation
pip install mcs-auth-oauth
Quick start
from mcs.auth.oauth import OAuthProvider
provider = OAuthProvider(
authorize_url="https://accounts.google.com/o/oauth2/v2/auth",
token_url="https://oauth2.googleapis.com/token",
client_id="...",
client_secret="...",
scopes={"gmail": "https://mail.google.com/"},
)
# Opens browser, user logs in, token returned
token = provider.get_token("gmail")
How it works
- Agent calls
get_token("gmail") - Browser opens with the provider's consent screen
- User logs in and grants access
- Localhost callback receives the authorization code
- Code is exchanged for tokens (with PKCE)
- Token returned to agent -- done
The entire flow happens in a single get_token() call. The localhost
server lives for exactly one request and shuts down immediately.
Use with Auth0 Token Vault
from mcs.auth.auth0 import Auth0Provider
from mcs.auth.oauth import OAuthConnector
provider = Auth0Provider(
domain="my-tenant.auth0.com",
client_id="...",
client_secret="...",
_auth=OAuthConnector(
authorize_url="https://my-tenant.auth0.com/authorize",
token_url="https://my-tenant.auth0.com/oauth/token",
client_id="...",
client_secret="...",
extra_params={"connection": "google-oauth2", "audience": "..."},
),
)
Links
- Homepage: https://www.modelcontextstandard.io
- Source: https://github.com/modelcontextstandard/python-sdk
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcs_auth_oauth-0.3.0.tar.gz.
File metadata
- Download URL: mcs_auth_oauth-0.3.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62eb320a6e43e9c39a138b39a0e6f3811e1fa9a9c5135ee1caf2933c8ca2864a
|
|
| MD5 |
7651b49a2ec0aa480ad50e383e1aeaf6
|
|
| BLAKE2b-256 |
82b62b2830a7e9a5f83dfd341fb5a22bf72c0a13342ff6b687792dbaaf5f596d
|
File details
Details for the file mcs_auth_oauth-0.3.0-py3-none-any.whl.
File metadata
- Download URL: mcs_auth_oauth-0.3.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
daba1cb19f2f14dd96d7f712574decf98f762ee6f403faadb8ef83d20f2323c2
|
|
| MD5 |
9f73e54bcd0cdfb544c320c1a845d4ed
|
|
| BLAKE2b-256 |
2d5cb789989c30538e08e33bc1a189a4f58cf10a0c97be0515b9758b178b77be
|