Skip to main content
Use this page to attach Sendmux to an OpenAI Agents SDK agent. Servers passed to mcp_servers expose their tools to the agent automatically, so you do not write tool wrappers.
Replace placeholder keys and tokens before running any snippet. Do not commit smx_root_, smx_mbx_, or private HTTP bearer tokens to version control.

Requirements

  • Python 3.10 or newer.
  • openai-agents installed.
  • A Sendmux key for the surface you are calling. Mailbox work needs an smx_mbx_ key or a scoped smx_agent_ token.

Install

Connect over local stdio

The SDK manages the subprocess for you and passes your key through its environment.
triage.py
Run more than one surface by switching to the sendmux-mcp entry point:

Connect over private HTTP

Use this when the agent runs somewhere it cannot spawn a process. Start the server yourself:
Then connect with the streamable HTTP server:

Require approval before an agent sends

The SDK can hold a tool for approval before it runs. Pair this with the Sendmux sending gate when a human should see the message first.
tool_filter narrows what the model can see at all. Use it to build a read-only triage agent, then add the sending tools only to the agent that is meant to reply.

Give each user their own mailbox

Mailbox-scoped keys are the isolation boundary. Open a server per tenant so the agent working one tenant structurally cannot read another tenant’s mail.

Sending stays gated

A durable smx_agent_ token includes mailbox.read and email.receive, not email.send. After a named human owner accepts the invite and approves sending, exchange the durable token for a one-hour Sending-resource token and pass that as SENDMUX_SENDING_API_KEY.

Troubleshooting

Confirm the surfaces the server started with. sendmux-mcp requires SENDMUX_MCP_SURFACES; the single-surface entry points do not. Check tool_filter as well, since it hides everything it does not name.
Check the key prefix. Mailbox accepts smx_mbx_ or a scoped smx_agent_, Sending accepts a send-capable smx_mbx_ or an owner-approved Sending-resource smx_agent_, and Management requires smx_root_.
Raise client_session_timeout_seconds, and set max_retry_attempts so transient list and call failures retry with backoff.
Start the workflow with mailbox_list_granted_mailboxes and pass the returned mailbox_id to tools that act on one mailbox.

Next steps

Agent frameworks

Compare connections across frameworks.

MCP

Review environment variables and tool discovery.

Agent access

Register an agent and complete owner approval.

Python SDK

Call Sendmux directly when you want full endpoint coverage.