Skip to main content

Shared OAuth infrastructure for MCP remote servers

Project description

mcp-remote-auth

Shared OAuth infrastructure for MCP remote servers. Extracts the common OAuth proxy pattern used by gmail-mcp-remote, gcal-mcp-remote, notion-mcp-remote, and linkedin-scheduler-remote into a reusable library.

Install

pip install mcp-remote-auth-ldraney

Usage

from mcp_remote_auth import (
    ProviderConfig, TokenStore, OAuthProxyProvider,
    configure_mcp_auth, configure_transport_security,
    register_standard_routes, register_onboarding_routes,
    build_app_with_middleware,
)

config = ProviderConfig(
    provider_name="Gmail",
    authorize_url="https://accounts.google.com/o/oauth2/auth",
    token_url="https://oauth2.googleapis.com/token",
    client_id=os.environ["OAUTH_CLIENT_ID"],
    client_secret=os.environ["OAUTH_CLIENT_SECRET"],
    base_url=os.environ["BASE_URL"],
    scopes="https://www.googleapis.com/auth/gmail.readonly",
    extra_authorize_params={"access_type": "offline", "prompt": "consent"},
    upstream_token_key="google_refresh_token",
    upstream_response_token_field="refresh_token",
)

store = TokenStore(secret=os.environ["SESSION_SECRET"])
provider = OAuthProxyProvider(store=store, config=config)

configure_mcp_auth(mcp, provider, BASE_URL)
configure_transport_security(mcp, BASE_URL, os.environ.get("ADDITIONAL_ALLOWED_HOSTS", ""))
register_standard_routes(mcp, provider, BASE_URL)
register_onboarding_routes(mcp, provider, store, config, os.environ.get("ONBOARD_SECRET", ""))

app = build_app_with_middleware(mcp, use_body_inspection=True)
uvicorn.run(app, host="0.0.0.0", port=8000)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_remote_auth_ldraney-0.1.0.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_remote_auth_ldraney-0.1.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file mcp_remote_auth_ldraney-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_remote_auth_ldraney-0.1.0.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for mcp_remote_auth_ldraney-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f7886d149d65999b5b14d6088380dd885ab784ad069724d47e12498d0734b3e5
MD5 b7c0711621cb32ef7988fac13414aa0c
BLAKE2b-256 ff31d65dd224beb3166d20fc4257993080a168e4a93d6a993a288019c9572993

See more details on using hashes here.

File details

Details for the file mcp_remote_auth_ldraney-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_remote_auth_ldraney-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 91835de9e1bbc5700128e60e8dd6f3dc7f4a63532df2c49897c1ed64b748c03c
MD5 12bf7b59057cca09568bdda90ddaaae9
BLAKE2b-256 d1b9c78f3dc659c01bb009f8b1e0ee5910dc7e69b0a5b17b854451d0ae9e9212

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page