Requirements
- A Mastra project with
@mastra/coreand@mastra/mcpinstalled. - A Sendmux key for the surface you are calling. Mailbox work needs an
smx_mbx_key or a scopedsmx_agent_token. - Python available in the same runtime if you use the local stdio connection.
Install
Connect over local stdio
Mastra launches the server as a child process and passes your key through the process environment.mcp/client.ts
sendmux-mcp entry point instead:
Connect over private HTTP
Use this when your Mastra service runs somewhere it cannot spawn a process. Start the server yourself:MCPClient at it and send the bearer token on every request:
mcp/client.ts
Give the tools to an agent
Load the tools once at startup when the key is the same for every request.agents/inbox-agent.ts
Give each user their own mailbox
When the key changes per tenant, per customer, or per agent, build the client at request time and pass its toolsets into the call instead of binding them to the agent.A mailbox-scoped key is the isolation boundary. An agent holding one
structurally cannot read another tenant’s mail, so provision a key per
mailbox rather than sharing one across tenants.
Sending stays gated
A durablesmx_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
No tools appear on the agent
No tools appear on the agent
Confirm the surfaces the server started with.
sendmux-mcp requires
SENDMUX_MCP_SURFACES; the single-surface entry points do not.The server exits before Mastra connects
The server exits before Mastra connects
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_.Private HTTP returns 401
Private HTTP returns 401
Send
Authorization: Bearer <SENDMUX_MCP_HTTP_BEARER_TOKEN> on every
request through requestInit.headers.You granted more than one mailbox
You granted more than one mailbox
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.
Mailbox API guides
Understand targeting, search, threads, and sync.
TypeScript SDK
Call Sendmux directly when you want full endpoint coverage.