Skip to main content

Gmail API adapter for the Model Context Standard.

Project description

mcs-adapter-gmail

Gmail API adapter for the Model Context Standard (MCS).

Provides both mail-reading and mail-sending capabilities via the Gmail REST API. Implements MailboxPort (7 methods) and MailsendPort (2 methods) so it works as a drop-in replacement for mcs-adapter-imap + mcs-adapter-smtp.

Uses mcs-adapter-http as transport layer -- no direct requests dependency.

Auth-agnostic: receives an OAuth2 access token (or a callable that returns one). Works with Auth0 Token Vault, manual OAuth2, service accounts, or any future credential provider.

Installation

pip install mcs-adapter-gmail

Quick start

from mcs.adapter.gmail import GmailAdapter

# Static token
adapter = GmailAdapter(access_token="ya29.a0...", sender_name="Alice Smith")

# Or with a token provider (e.g. Auth0 Token Vault)
adapter = GmailAdapter(access_token=lambda: get_fresh_token())

# Use with MCS drivers -- same tools, different backend
from mcs.driver.mailread import MailreadToolDriver
from mcs.driver.mailsend import MailsendToolDriver

td_read = MailreadToolDriver(_adapter=adapter)
td_send = MailsendToolDriver(_adapter=adapter)

Gmail labels vs IMAP folders

Gmail uses labels instead of folders. The adapter maps them transparently:

IMAP concept Gmail equivalent
Folder Label
\Seen flag Remove UNREAD label
\Flagged flag Add STARRED label
\Deleted flag Add TRASH label
Move to folder Add destination label, remove source label

Required OAuth2 scopes

Scope Purpose
gmail.readonly Read messages and labels
gmail.labels Create and manage labels
gmail.send Send e-mail

Links

License

Apache-2.0

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

mcs_adapter_gmail-0.1.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

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

mcs_adapter_gmail-0.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcs_adapter_gmail-0.1.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

Hashes for mcs_adapter_gmail-0.1.0.tar.gz
Algorithm Hash digest
SHA256 818d0c8c9af91b3846ba8a4ebf84fefd710eabdec5eaf15771bbd092e58698cc
MD5 97f3de73984b6655a04744d61d1003c1
BLAKE2b-256 a0f624aefcf93d877b80c98af24b744be5e49a0c3105a1af1a311162677bdfe0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcs_adapter_gmail-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4581c817f794c0179ad3e43ec891e609f6503777a5aab51a940d876221cb05f6
MD5 6d749482aaf5f50acb3f64e4932ef1a0
BLAKE2b-256 b983d568ccffb1963ec9a6af13186a314c45200e7b783e2394415541fdf5a1e4

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