Skip to main content

Email Inbox API + Sending by Sendmux

PyPI version Python versions PyPI downloads Licence

Email inbox API, inbound mail, and outbound sending MCP and A2A servers for AI agents, with inbound email, clean JSON parsing, webhooks, and multi-provider routing through Sendmux.

This package is the Sendmux MCP. Keep it separate from any documentation-search MCP used by docs tooling.

Documentation

Requirements

  • Python 3.10 or newer.
  • A send-capable smx_mbx_* key or owner-approved Sending-resource smx_agent_* token for Sending tools.
  • A mailbox-scoped smx_mbx_* key or scoped smx_agent_* token for Mailbox tools.
  • A root smx_root_* key for Management tools.

2.0.0 upgrade

Version 2.0.0 removes local file_path and roots inputs from MCP attachment tools. Before upgrading a self-managed package or server, retain the prior known-working package environment, dependency state, and MCP client and tool configuration. Update attachment callers to use the attachment workflow for agents, then verify tool discovery and each attachment workflow your agents use.

To roll back a self-managed installation, restore the retained package environment, dependency state, and MCP client and tool configuration together. Verify tool discovery and the relevant attachment workflow before resuming agents. A package rollback doesn't reverse uploads or sends that have already completed.

For clients that use Sendmux's hosted endpoint, changing a local pip environment doesn't change the deployed server version. A hosted deployment rollback is a separate operator release action and must be verified against the hosted endpoint.

Installation

pip install sendmux-mcp

Usage

Run a single local server with the per-surface commands.

SENDMUX_API_KEY=smx_mbx_... sendmux-mcp-mailbox
SENDMUX_API_KEY=smx_root_... sendmux-mcp-management
SENDMUX_API_KEY=smx_mbx_... sendmux-mcp-sending

Run a combined local server with sendmux-mcp.

SENDMUX_MCP_SURFACES=mailbox,sending \
SENDMUX_MAILBOX_API_KEY=smx_mbx_... \
SENDMUX_SENDING_API_KEY=smx_mbx_... \
sendmux-mcp

Run all three local surfaces when you have both key types.

SENDMUX_MCP_SURFACES=mailbox,management,sending \
SENDMUX_MAILBOX_API_KEY=smx_mbx_... \
SENDMUX_MANAGEMENT_API_KEY=smx_root_... \
SENDMUX_SENDING_API_KEY=smx_mbx_... \
sendmux-mcp

The generic sendmux-mcp command also accepts --surface or --surfaces. The wrapper commands select exactly one surface.

Transports

stdio is the default transport for local agent clients.

SENDMUX_API_KEY=smx_mbx_... sendmux-mcp-mailbox --transport stdio

http and streamable-http expose the MCP endpoint over HTTP. HTTP mode defaults to 127.0.0.1:8765/mcp and requires a separate MCP bearer token unless you explicitly opt out.

SENDMUX_API_KEY=smx_mbx_... \
SENDMUX_MCP_HTTP_BEARER_TOKEN=local-mcp-token \
sendmux-mcp-mailbox --transport http --host 127.0.0.1 --port 8765 --path /mcp

/health returns a small JSON health response for the selected surfaces.

Hosted Endpoint

The public hosted MCP endpoint is https://mcp.sendmux.ai/mcp.

For hosted clients, use HTTP transport with OAuth. Do not add manual Authorization headers, API keys, custom OAuth endpoints, or custom scopes unless your client explicitly requires them.

Hosted OAuth clients that omit requested scopes during registration or authorization are supported; the server advertises the hosted scope set through discovery and bearer challenges.

The packaged sendmux-mcp-hosted command runs the hosted server runtime. Local and private deployments should use the local commands above unless you are operating a compatible OAuth-backed hosted environment.

Hosted A2A Endpoint

The same hosted runtime exposes deterministic A2A 1.0 over HTTP+JSON at https://a2a.sendmux.ai/a2a/v1. Discover it from https://a2a.sendmux.ai/.well-known/agent-card.json; OAuth resource metadata is at https://a2a.sendmux.ai/.well-known/oauth-protected-resource.

Send exactly one JSON DataPart to the A2A message:send operation. Its data selects a curated Sendmux operation and supplies that operation's inputs:

{
  "operationId": "managementListDomains",
  "pathParameters": {},
  "query": { "limit": 10 },
  "headers": {},
  "body": null,
  "mailboxId": null
}

operationId uses the same curated operation IDs as the hosted MCP service. OAuth grants are audience-bound to the A2A resource and retain their Sendmux surface and permission limits. The service returns one JSON DataPart containing the upstream status, safe response headers, and JSON body (or bodyBase64 for non-JSON responses).

The A2A endpoint is immediate and stateless: streaming, push notifications, persistent tasks, and task cancellation are not advertised or routed.

Configuration

Setting Environment Default
Tool surfaces SENDMUX_MCP_SURFACES required for sendmux-mcp; wrapper commands select one surface
API key fallback SENDMUX_API_KEY accepted for compatible single-key setups
Mailbox API key SENDMUX_MAILBOX_API_KEY required when mailbox is selected unless a compatible fallback is provided
Management API key SENDMUX_MANAGEMENT_API_KEY required when management is selected unless a compatible fallback is provided
Sending API key SENDMUX_SENDING_API_KEY required when sending is selected unless the fallback key is a send-capable smx_mbx_* key or owner-approved Sending-resource smx_agent_* token
App API base URL SENDMUX_APP_BASE_URL https://app.sendmux.ai/api/v1
Sending API base URL SENDMUX_SENDING_BASE_URL https://smtp.sendmux.ai/api/v1
Transport SENDMUX_MCP_TRANSPORT stdio
HTTP host SENDMUX_MCP_HOST 127.0.0.1
HTTP port SENDMUX_MCP_PORT 8765
HTTP path SENDMUX_MCP_PATH /mcp
HTTP bearer token SENDMUX_MCP_HTTP_BEARER_TOKEN required for HTTP unless opt-out is enabled
Allow unauthenticated HTTP SENDMUX_MCP_ALLOW_UNAUTHENTICATED_HTTP false
Allowed browser origins SENDMUX_MCP_ALLOWED_ORIGINS no browser origins
Snapshot directory override SENDMUX_MCP_OPENAPI_INPUT_DIR or OPENAPI_INPUT_DIR packaged snapshots
App snapshot override SENDMUX_MCP_APP_OPENAPI packaged app snapshot
Sending snapshot override SENDMUX_MCP_SENDING_OPENAPI packaged sending snapshot
Request timeout SENDMUX_MCP_TIMEOUT_SECONDS 30
Retry attempts SENDMUX_MCP_RETRY_MAX_ATTEMPTS 3
Retry time budget, in seconds SENDMUX_MCP_RETRY_MAX_ELAPSED_SECONDS unset

Retries honour Retry-After and X-RateLimit-Reset without applying the local backoff ceiling, and stop for retryable: false. Set the optional retry budget with RetryConfig(max_elapsed_seconds=30), the environment variable above, or --retry-max-elapsed-seconds 30. A retry that would exceed the remaining budget returns the original error; in-flight requests keep their normal HTTP timeouts.

Packaged OpenAPI snapshots are the default so released tool names, schemas, and descriptions stay stable. Path, directory, and URL overrides are available for development, canary, and debugging runs.

Tool Surfaces

  • Mailbox: tools for granted mailboxes, profile/session discovery, messages, attachments, bounded message waits, threads, folders, search, counts, and mailbox sends. Requires an smx_mbx_* key or scoped smx_agent_* token. Agent tokens remain limited by server-side scopes; pre-claim self-registered agent tokens do not include email.send.
  • Management: tools for domains, mailboxes, logs, metrics, spend summary, and webhooks. Requires an smx_root_* key.
  • Sending: tools for attachment upload refs, single sends, and batch sends. Requires an smx_mbx_* key or owner-approved Sending-resource smx_agent_* token.

The server rejects keys with the wrong prefix before starting.

Package Contract For Maintainers

The source checkout includes sendmux_mcp/mcp-contract.json, generated from the actual server factory's public tool discovery. Use its tools.by_surface entries and tools.count instead of maintaining a separate catalogue. Each entry retains the tool's description, input/output schemas, and annotations. The contract also separates hosted resource, local transports, API origins, certified protocol revisions, and the runtime versions used during generation.

After installing a build that contains the contract, read it without credentials or network requests:

from sendmux_mcp.contract import load_contract

contract = load_contract()
print(contract["package"])

The result identifies the installed distribution and version. load_contract() raises ValueError for stale source/version evidence, a mismatched pinned FastMCP runtime, or unsupported certified revisions. The recorded transitive MCP version is provenance, not a narrower dependency constraint. Reading the artifact does not certify a newly resolved dependency version or prove a deployed service matches this build.

uploads distinguishes the locally enforced inline and Mailbox byte caps from Sending's returned max_size_bytes authority. The Sending presign request schema does not impose a numeric maximum; use the upload intent response, not a historical source constant. URL expiry and physical attachment retention are not equivalent, and this artifact does not certify storage cleanup.

From the repository root, pnpm generate:mcp refreshes native editable metadata and writes deterministic contract bytes. With that environment prepared, pnpm exec .tmp/python-venv/bin/python -m sendmux_mcp.contract --check checks freshness without rewriting. pnpm build:mcp verifies tests, wheel/sdist inclusion, installed consumption, and frozen conformance checks. Checkout changes are not available through pip install until their release is published.

Attachment Workflow For Agents

Use mailbox_wait_for_message when a user asks an agent to wait for new mail. The tool is bounded; if it returns matched=false, call it again rather than holding an MCP tool call open indefinitely.

When a message has attachments:

  1. Call mailbox_read_attachment with message_id and attachment_id when you need the attachment contents.
  2. For small text-like attachments, read the returned text.
  3. For binary or oversized attachments, use the returned resource_link / download_url promptly outside model context.
  4. Use mailbox_get_attachment only when metadata is enough or you need to refresh the link.

Use mailbox_upload_attachment for outbound attachments over MCP. It accepts exactly one input mode:

  • presign_upload_url=true for hosted MCP or shell-capable agents; upload the file to the returned URL with exact headers and no API key, then send with the returned blob_id.
  • content_base64 only for tiny agent-authored files, capped at 32 KiB decoded. If it is too large, switch to a presigned upload, CLI --attach, or SDK file helpers.

Presigned uploads use the mailbox attachment cap, currently 7,500,000 bytes per attachment, and pin the exact declared byte length and content type.

For mailbox sends, mailbox_send_message accepts either tiny inline base64 attachment objects (content, filename, content_type) or uploaded attachment references (blob_id, filename, content_type).

For Sending API sends, use sending_upload_attachment only for tiny inline content, or call sending_create_attachment_upload and PUT bytes outside model context. Then pass {"attachment_id": "att_..."} in sending_send_email.attachments[].

Console Scripts

  • sendmux-mcp
  • sendmux-mcp-mailbox
  • sendmux-mcp-management
  • sendmux-mcp-sending
  • sendmux-mcp-hosted

Support

Open an issue in Sendmux/sendmux-sdk with the package name, version, command, transport, and request ID from any API error.

Licence

MIT. See the licence file.

Download files

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

Source Distribution

sendmux_mcp-2.0.0.tar.gz (135.0 kB view details)

Uploaded Source

Built Distribution

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

sendmux_mcp-2.0.0-py3-none-any.whl (149.2 kB view details)

Uploaded Python 3

File details

Details for the file sendmux_mcp-2.0.0.tar.gz.

File metadata

  • Download URL: sendmux_mcp-2.0.0.tar.gz
  • Upload date:
  • Size: 135.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for sendmux_mcp-2.0.0.tar.gz
Algorithm Hash digest
SHA256 884bdb74aad635a075de5de5ebb6e676e2efb0d45fcff359d7eb2ad43e00dc30
MD5 2f647ed5329a5f2410feb71f94820de0
BLAKE2b-256 7544bb77fa68aced8832bd3020401e0a11c7363995ac87b824de59dd7438ec84

See more details on using hashes here.

Provenance

The following attestation bundles were made for sendmux_mcp-2.0.0.tar.gz:

Publisher: release-please.yml on Sendmux/sendmux-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sendmux_mcp-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: sendmux_mcp-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 149.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for sendmux_mcp-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 81c73a5770391f44550a74e7173f763f83ba3011eff45b8269a0b25e694beaa8
MD5 b91dbf2420e80d568a303669f5ad3a9b
BLAKE2b-256 434ad084eaf7d62be1779585055820750456e5fea783ca4f191a7ec19f52502d

See more details on using hashes here.

Provenance

The following attestation bundles were made for sendmux_mcp-2.0.0-py3-none-any.whl:

Publisher: release-please.yml on Sendmux/sendmux-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

2.1.0

2 files

This release

2.0.0 This release

2 files

1.8.0

2 files

1.7.0

2 files

1.6.1

2 files

1.6.0

2 files

1.5.1

2 files

1.5.0

2 files

1.4.0

2 files

1.3.1

2 files

1.3.0

2 files

1.2.1

2 files

1.2.0

2 files

1.1.5

2 files

1.1.4

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page