qubrics-mcp 3.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. qubrics_mcp-3.0.0/.gitignore +22 -0
  2. qubrics_mcp-3.0.0/LICENSE +21 -0
  3. qubrics_mcp-3.0.0/PKG-INFO +256 -0
  4. qubrics_mcp-3.0.0/README.md +231 -0
  5. qubrics_mcp-3.0.0/evals.xml +42 -0
  6. qubrics_mcp-3.0.0/pyproject.toml +57 -0
  7. qubrics_mcp-3.0.0/qubrics/mcp/__init__.py +6 -0
  8. qubrics_mcp-3.0.0/qubrics/mcp/__main__.py +6 -0
  9. qubrics_mcp-3.0.0/qubrics/mcp/a2a.py +434 -0
  10. qubrics_mcp-3.0.0/qubrics/mcp/cli.py +135 -0
  11. qubrics_mcp-3.0.0/qubrics/mcp/config.py +213 -0
  12. qubrics_mcp-3.0.0/qubrics/mcp/contract.py +205 -0
  13. qubrics_mcp-3.0.0/qubrics/mcp/curation.py +645 -0
  14. qubrics_mcp-3.0.0/qubrics/mcp/hosted.py +368 -0
  15. qubrics_mcp-3.0.0/qubrics/mcp/hosted_auth.py +73 -0
  16. qubrics_mcp-3.0.0/qubrics/mcp/hosted_proxy.py +336 -0
  17. qubrics_mcp-3.0.0/qubrics/mcp/live_e2e.py +245 -0
  18. qubrics_mcp-3.0.0/qubrics/mcp/mcp-contract.json +37285 -0
  19. qubrics_mcp-3.0.0/qubrics/mcp/observability.py +278 -0
  20. qubrics_mcp-3.0.0/qubrics/mcp/openapi/__init__.py +1 -0
  21. qubrics_mcp-3.0.0/qubrics/mcp/permissions.py +164 -0
  22. qubrics_mcp-3.0.0/qubrics/mcp/py.typed +1 -0
  23. qubrics_mcp-3.0.0/qubrics/mcp/response_ownership.py +36 -0
  24. qubrics_mcp-3.0.0/qubrics/mcp/retry.py +166 -0
  25. qubrics_mcp-3.0.0/qubrics/mcp/runtime_openapi/__init__.py +1 -0
  26. qubrics_mcp-3.0.0/qubrics/mcp/runtime_openapi/openapi-app.json +22719 -0
  27. qubrics_mcp-3.0.0/qubrics/mcp/runtime_openapi/openapi-sending.json +1883 -0
  28. qubrics_mcp-3.0.0/qubrics/mcp/security.py +144 -0
  29. qubrics_mcp-3.0.0/qubrics/mcp/server.py +994 -0
  30. qubrics_mcp-3.0.0/qubrics/mcp/smoke.py +69 -0
  31. qubrics_mcp-3.0.0/qubrics/mcp/specs.py +83 -0
  32. qubrics_mcp-3.0.0/qubrics/mcp/verification.py +36 -0
@@ -0,0 +1,22 @@
1
+ node_modules/
2
+ .venv/
3
+ .pytest_cache/
4
+ dist/
5
+ .tmp/
6
+ coverage/
7
+ .DS_Store
8
+ *.log
9
+ *.snap
10
+ snapcraft-*.txt
11
+ *.codegen.json
12
+ .codegen/
13
+ .codegraph/
14
+ *.tsbuildinfo
15
+ packages/ts/cli/oclif.manifest.json
16
+ packages/ts/cli/tmp/
17
+ .phpunit.result.cache
18
+ __pycache__/
19
+ *.py[cod]
20
+ vendor/
21
+ .bundle/
22
+ target/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sendmux
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,256 @@
1
+ Metadata-Version: 2.4
2
+ Name: qubrics-mcp
3
+ Version: 3.0.0
4
+ Summary: Email inbox API and outbound sending tools for AI Agents.
5
+ Project-URL: Repository, https://github.com/qubrics/qubrics-sdk
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Requires-Python: >=3.10
15
+ Requires-Dist: a2a-sdk[http-server]==1.1.2
16
+ Requires-Dist: anyio<5,>=4.9
17
+ Requires-Dist: fastmcp==4.0.3
18
+ Requires-Dist: httpx2<3,>=2.5
19
+ Requires-Dist: httpx<1,>=0.28.1
20
+ Requires-Dist: jsonschema<5,>=4.20
21
+ Requires-Dist: mcp==2.2.0
22
+ Requires-Dist: posthog<8,>=7.21.0
23
+ Requires-Dist: qubrics-core<3.0.0,>=2.0.0
24
+ Description-Content-Type: text/markdown
25
+
26
+ # Email Inbox API + Sending by Qubrics
27
+
28
+ [![PyPI version](https://img.shields.io/pypi/v/qubrics-mcp)](https://pypi.org/project/qubrics-mcp/)
29
+ [![Python versions](https://img.shields.io/pypi/pyversions/qubrics-mcp)](https://pypi.org/project/qubrics-mcp/)
30
+ [![PyPI downloads](https://img.shields.io/pypi/dm/qubrics-mcp)](https://pypi.org/project/qubrics-mcp/)
31
+ [![Licence](https://img.shields.io/pypi/l/qubrics-mcp)](https://github.com/qubrics/qubrics-sdk/blob/main/LICENSE)
32
+
33
+ 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 Qubrics.
34
+
35
+ This package is the Qubrics MCP. Keep it separate from any documentation-search MCP used by docs tooling.
36
+
37
+ <!-- mcp-name: io.github.Sendmux/sendmux-mcp -->
38
+
39
+ ## Documentation
40
+
41
+ - Qubrics docs: [qubrics.com/docs](https://qubrics.com/docs)
42
+ - Management API reference: [qubrics.com/docs/api/introduction](https://qubrics.com/docs/api/introduction)
43
+ - Mailbox API reference: [qubrics.com/docs/mailbox-api/introduction](https://qubrics.com/docs/mailbox-api/introduction)
44
+ - Sending API reference: [qubrics.com/docs/sending-api/introduction](https://qubrics.com/docs/sending-api/introduction)
45
+ - Source repository: [qubrics/qubrics-sdk](https://github.com/qubrics/qubrics-sdk)
46
+
47
+ ## Requirements
48
+
49
+ - Python 3.10 or newer.
50
+ - A send-capable `smx_mbx_*` key or owner-approved Sending-resource `smx_agent_*` token for Sending tools.
51
+ - A mailbox-scoped `smx_mbx_*` key or scoped `smx_agent_*` token for Mailbox tools.
52
+ - A root `smx_root_*` key for Management tools.
53
+
54
+ <a id="unreleased-200-upgrade"></a>
55
+
56
+ ## Attachment input migration
57
+
58
+ MCP attachment tools use upload references instead of local `file_path` and
59
+ roots inputs. Before upgrading a self-managed package or server, retain the prior
60
+ known-working package environment, dependency state, and MCP client and tool
61
+ configuration. Update attachment callers to use the
62
+ [attachment workflow for agents](#attachment-workflow-for-agents), then verify
63
+ tool discovery and each attachment workflow your agents use.
64
+
65
+ To roll back a self-managed installation, restore the retained package
66
+ environment, dependency state, and MCP client and tool configuration together.
67
+ Verify tool discovery and the relevant attachment workflow before resuming
68
+ agents. A package rollback doesn't reverse uploads or sends that have already
69
+ completed.
70
+
71
+ For clients that use Qubrics's hosted endpoint, changing a local `pip`
72
+ environment doesn't change the deployed server version. A hosted deployment
73
+ rollback is a separate operator release action and must be verified against the
74
+ hosted endpoint.
75
+
76
+ ## Installation
77
+
78
+ These commands target the Qubrics release of `qubrics-mcp`. Until it is published, install `sendmux-mcp` with its existing import names.
79
+
80
+ ```sh
81
+ pip install qubrics-mcp
82
+ ```
83
+
84
+ ## Usage
85
+
86
+ Run a single local server with the per-surface commands.
87
+
88
+ ```sh
89
+ QUBRICS_API_KEY=smx_mbx_... qubrics-mcp-mailbox
90
+ QUBRICS_API_KEY=smx_root_... qubrics-mcp-management
91
+ QUBRICS_API_KEY=smx_mbx_... qubrics-mcp-sending
92
+ ```
93
+
94
+ Run a combined local server with `qubrics-mcp`.
95
+
96
+ ```sh
97
+ QUBRICS_MCP_SURFACES=mailbox,sending \
98
+ QUBRICS_MAILBOX_API_KEY=smx_mbx_... \
99
+ QUBRICS_SENDING_API_KEY=smx_mbx_... \
100
+ qubrics-mcp
101
+ ```
102
+
103
+ Run all three local surfaces when you have both key types.
104
+
105
+ ```sh
106
+ QUBRICS_MCP_SURFACES=mailbox,management,sending \
107
+ QUBRICS_MAILBOX_API_KEY=smx_mbx_... \
108
+ QUBRICS_MANAGEMENT_API_KEY=smx_root_... \
109
+ QUBRICS_SENDING_API_KEY=smx_mbx_... \
110
+ qubrics-mcp
111
+ ```
112
+
113
+ The generic `qubrics-mcp` command also accepts `--surface` or `--surfaces`. The wrapper commands select exactly one surface.
114
+
115
+ ## Transports
116
+
117
+ `stdio` is the default transport for local agent clients.
118
+
119
+ ```sh
120
+ QUBRICS_API_KEY=smx_mbx_... qubrics-mcp-mailbox --transport stdio
121
+ ```
122
+
123
+ `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.
124
+
125
+ ```sh
126
+ QUBRICS_API_KEY=smx_mbx_... \
127
+ QUBRICS_MCP_HTTP_BEARER_TOKEN=local-mcp-token \
128
+ qubrics-mcp-mailbox --transport http --host 127.0.0.1 --port 8765 --path /mcp
129
+ ```
130
+
131
+ `/health` returns a small JSON health response for the selected surfaces.
132
+
133
+ ## Hosted Endpoint
134
+
135
+ The public hosted MCP endpoint is `https://mcp.qubrics.com/mcp`.
136
+
137
+ 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.
138
+
139
+ 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.
140
+
141
+ The packaged `qubrics-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.
142
+
143
+ ## Hosted A2A Endpoint
144
+
145
+ The same hosted runtime exposes deterministic A2A 1.0 over HTTP+JSON at `https://a2a.qubrics.com/a2a/v1`. Discover it from `https://a2a.qubrics.com/.well-known/agent-card.json`; OAuth resource metadata is at `https://a2a.qubrics.com/.well-known/oauth-protected-resource`.
146
+
147
+ Send exactly one JSON `DataPart` to the A2A `message:send` operation. Its data selects a curated Qubrics operation and supplies that operation's inputs:
148
+
149
+ ```json
150
+ {
151
+ "operationId": "managementListDomains",
152
+ "pathParameters": {},
153
+ "query": { "limit": 10 },
154
+ "headers": {},
155
+ "body": null,
156
+ "mailboxId": null
157
+ }
158
+ ```
159
+
160
+ `operationId` uses the same curated operation IDs as the hosted MCP service. OAuth grants are audience-bound to the A2A resource and retain their Qubrics 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).
161
+
162
+ The A2A endpoint is immediate and stateless: streaming, push notifications, persistent tasks, and task cancellation are not advertised or routed.
163
+
164
+ ## Configuration
165
+
166
+ | Setting | Environment | Default |
167
+ | --- | --- | --- |
168
+ | Tool surfaces | `QUBRICS_MCP_SURFACES` | required for `qubrics-mcp`; wrapper commands select one surface |
169
+ | API key fallback | `QUBRICS_API_KEY` | accepted for compatible single-key setups |
170
+ | Mailbox API key | `QUBRICS_MAILBOX_API_KEY` | required when mailbox is selected unless a compatible fallback is provided |
171
+ | Management API key | `QUBRICS_MANAGEMENT_API_KEY` | required when management is selected unless a compatible fallback is provided |
172
+ | Sending API key | `QUBRICS_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 |
173
+ | App API base URL | `QUBRICS_APP_BASE_URL` | `https://app.qubrics.com/api/v1` |
174
+ | Sending API base URL | `QUBRICS_SENDING_BASE_URL` | `https://smtp.qubrics.com/api/v1` |
175
+ | Transport | `QUBRICS_MCP_TRANSPORT` | `stdio` |
176
+ | HTTP host | `QUBRICS_MCP_HOST` | `127.0.0.1` |
177
+ | HTTP port | `QUBRICS_MCP_PORT` | `8765` |
178
+ | HTTP path | `QUBRICS_MCP_PATH` | `/mcp` |
179
+ | HTTP bearer token | `QUBRICS_MCP_HTTP_BEARER_TOKEN` | required for HTTP unless opt-out is enabled |
180
+ | Allow unauthenticated HTTP | `QUBRICS_MCP_ALLOW_UNAUTHENTICATED_HTTP` | `false` |
181
+ | Allowed browser origins | `QUBRICS_MCP_ALLOWED_ORIGINS` | no browser origins |
182
+ | Snapshot directory override | `QUBRICS_MCP_OPENAPI_INPUT_DIR` or `OPENAPI_INPUT_DIR` | packaged snapshots |
183
+ | App snapshot override | `QUBRICS_MCP_APP_OPENAPI` | packaged app snapshot |
184
+ | Sending snapshot override | `QUBRICS_MCP_SENDING_OPENAPI` | packaged sending snapshot |
185
+ | Request timeout | `QUBRICS_MCP_TIMEOUT_SECONDS` | `30` |
186
+ | Retry attempts | `QUBRICS_MCP_RETRY_MAX_ATTEMPTS` | `3` |
187
+ | Retry time budget, in seconds | `QUBRICS_MCP_RETRY_MAX_ELAPSED_SECONDS` | unset |
188
+
189
+ 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.
190
+
191
+ 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.
192
+
193
+ ## Tool Surfaces
194
+
195
+ - 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`.
196
+ - Management: tools for domains, mailboxes, logs, metrics, spend summary, and webhooks. Requires an `smx_root_*` key.
197
+ - Sending: tools for attachment upload refs, single sends, and batch sends. Requires an `smx_mbx_*` key or owner-approved Sending-resource `smx_agent_*` token.
198
+
199
+ The server rejects keys with the wrong prefix before starting.
200
+
201
+ ## Package Contract For Maintainers
202
+
203
+ The source checkout includes `qubrics/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.
204
+
205
+ After installing a build that contains the contract, read it without credentials or network requests:
206
+
207
+ ```python
208
+ from qubrics.mcp.contract import load_contract
209
+
210
+ contract = load_contract()
211
+ print(contract["package"])
212
+ ```
213
+
214
+ 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.
215
+
216
+ `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.
217
+
218
+ 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 qubrics.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.
219
+
220
+ ## Attachment Workflow For Agents
221
+
222
+ Use `qubrics_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.
223
+
224
+ When a message has attachments:
225
+
226
+ 1. Call `qubrics_mailbox_read_attachment` with `message_id` and `attachment_id` when you need the attachment contents.
227
+ 2. For small text-like attachments, read the returned `text`.
228
+ 3. For binary or oversized attachments, use the returned `resource_link` / `download_url` promptly outside model context.
229
+ 4. Use `qubrics_mailbox_get_attachment` only when metadata is enough or you need to refresh the link.
230
+
231
+ Use `qubrics_mailbox_upload_attachment` for outbound attachments over MCP. It accepts exactly one input mode:
232
+
233
+ - `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`.
234
+ - `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.
235
+
236
+ Presigned uploads use the mailbox attachment cap, currently `7,500,000` bytes per attachment, and pin the exact declared byte length and content type.
237
+
238
+ For mailbox sends, `qubrics_mailbox_send_message` accepts either tiny inline base64 attachment objects (`content`, `filename`, `content_type`) or uploaded attachment references (`blob_id`, `filename`, `content_type`).
239
+
240
+ For Sending API sends, use `qubrics_sending_upload_attachment` only for tiny inline content, or call `qubrics_sending_create_attachment_upload` and PUT bytes outside model context. Then pass `{"attachment_id": "att_..."}` in `qubrics_sending_send_email.attachments[]`.
241
+
242
+ ## Console Scripts
243
+
244
+ - `qubrics-mcp`
245
+ - `qubrics-mcp-mailbox`
246
+ - `qubrics-mcp-management`
247
+ - `qubrics-mcp-sending`
248
+ - `qubrics-mcp-hosted`
249
+
250
+ ## Support
251
+
252
+ Open an issue in [qubrics/qubrics-sdk](https://github.com/qubrics/qubrics-sdk/issues) with the package name, version, command, transport, and request ID from any API error.
253
+
254
+ ## Licence
255
+
256
+ MIT. See the [licence file](https://github.com/qubrics/qubrics-sdk/blob/main/LICENSE).
@@ -0,0 +1,231 @@
1
+ # Email Inbox API + Sending by Qubrics
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/qubrics-mcp)](https://pypi.org/project/qubrics-mcp/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/qubrics-mcp)](https://pypi.org/project/qubrics-mcp/)
5
+ [![PyPI downloads](https://img.shields.io/pypi/dm/qubrics-mcp)](https://pypi.org/project/qubrics-mcp/)
6
+ [![Licence](https://img.shields.io/pypi/l/qubrics-mcp)](https://github.com/qubrics/qubrics-sdk/blob/main/LICENSE)
7
+
8
+ 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 Qubrics.
9
+
10
+ This package is the Qubrics MCP. Keep it separate from any documentation-search MCP used by docs tooling.
11
+
12
+ <!-- mcp-name: io.github.Sendmux/sendmux-mcp -->
13
+
14
+ ## Documentation
15
+
16
+ - Qubrics docs: [qubrics.com/docs](https://qubrics.com/docs)
17
+ - Management API reference: [qubrics.com/docs/api/introduction](https://qubrics.com/docs/api/introduction)
18
+ - Mailbox API reference: [qubrics.com/docs/mailbox-api/introduction](https://qubrics.com/docs/mailbox-api/introduction)
19
+ - Sending API reference: [qubrics.com/docs/sending-api/introduction](https://qubrics.com/docs/sending-api/introduction)
20
+ - Source repository: [qubrics/qubrics-sdk](https://github.com/qubrics/qubrics-sdk)
21
+
22
+ ## Requirements
23
+
24
+ - Python 3.10 or newer.
25
+ - A send-capable `smx_mbx_*` key or owner-approved Sending-resource `smx_agent_*` token for Sending tools.
26
+ - A mailbox-scoped `smx_mbx_*` key or scoped `smx_agent_*` token for Mailbox tools.
27
+ - A root `smx_root_*` key for Management tools.
28
+
29
+ <a id="unreleased-200-upgrade"></a>
30
+
31
+ ## Attachment input migration
32
+
33
+ MCP attachment tools use upload references instead of local `file_path` and
34
+ roots inputs. Before upgrading a self-managed package or server, retain the prior
35
+ known-working package environment, dependency state, and MCP client and tool
36
+ configuration. Update attachment callers to use the
37
+ [attachment workflow for agents](#attachment-workflow-for-agents), then verify
38
+ tool discovery and each attachment workflow your agents use.
39
+
40
+ To roll back a self-managed installation, restore the retained package
41
+ environment, dependency state, and MCP client and tool configuration together.
42
+ Verify tool discovery and the relevant attachment workflow before resuming
43
+ agents. A package rollback doesn't reverse uploads or sends that have already
44
+ completed.
45
+
46
+ For clients that use Qubrics's hosted endpoint, changing a local `pip`
47
+ environment doesn't change the deployed server version. A hosted deployment
48
+ rollback is a separate operator release action and must be verified against the
49
+ hosted endpoint.
50
+
51
+ ## Installation
52
+
53
+ These commands target the Qubrics release of `qubrics-mcp`. Until it is published, install `sendmux-mcp` with its existing import names.
54
+
55
+ ```sh
56
+ pip install qubrics-mcp
57
+ ```
58
+
59
+ ## Usage
60
+
61
+ Run a single local server with the per-surface commands.
62
+
63
+ ```sh
64
+ QUBRICS_API_KEY=smx_mbx_... qubrics-mcp-mailbox
65
+ QUBRICS_API_KEY=smx_root_... qubrics-mcp-management
66
+ QUBRICS_API_KEY=smx_mbx_... qubrics-mcp-sending
67
+ ```
68
+
69
+ Run a combined local server with `qubrics-mcp`.
70
+
71
+ ```sh
72
+ QUBRICS_MCP_SURFACES=mailbox,sending \
73
+ QUBRICS_MAILBOX_API_KEY=smx_mbx_... \
74
+ QUBRICS_SENDING_API_KEY=smx_mbx_... \
75
+ qubrics-mcp
76
+ ```
77
+
78
+ Run all three local surfaces when you have both key types.
79
+
80
+ ```sh
81
+ QUBRICS_MCP_SURFACES=mailbox,management,sending \
82
+ QUBRICS_MAILBOX_API_KEY=smx_mbx_... \
83
+ QUBRICS_MANAGEMENT_API_KEY=smx_root_... \
84
+ QUBRICS_SENDING_API_KEY=smx_mbx_... \
85
+ qubrics-mcp
86
+ ```
87
+
88
+ The generic `qubrics-mcp` command also accepts `--surface` or `--surfaces`. The wrapper commands select exactly one surface.
89
+
90
+ ## Transports
91
+
92
+ `stdio` is the default transport for local agent clients.
93
+
94
+ ```sh
95
+ QUBRICS_API_KEY=smx_mbx_... qubrics-mcp-mailbox --transport stdio
96
+ ```
97
+
98
+ `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.
99
+
100
+ ```sh
101
+ QUBRICS_API_KEY=smx_mbx_... \
102
+ QUBRICS_MCP_HTTP_BEARER_TOKEN=local-mcp-token \
103
+ qubrics-mcp-mailbox --transport http --host 127.0.0.1 --port 8765 --path /mcp
104
+ ```
105
+
106
+ `/health` returns a small JSON health response for the selected surfaces.
107
+
108
+ ## Hosted Endpoint
109
+
110
+ The public hosted MCP endpoint is `https://mcp.qubrics.com/mcp`.
111
+
112
+ 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.
113
+
114
+ 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.
115
+
116
+ The packaged `qubrics-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.
117
+
118
+ ## Hosted A2A Endpoint
119
+
120
+ The same hosted runtime exposes deterministic A2A 1.0 over HTTP+JSON at `https://a2a.qubrics.com/a2a/v1`. Discover it from `https://a2a.qubrics.com/.well-known/agent-card.json`; OAuth resource metadata is at `https://a2a.qubrics.com/.well-known/oauth-protected-resource`.
121
+
122
+ Send exactly one JSON `DataPart` to the A2A `message:send` operation. Its data selects a curated Qubrics operation and supplies that operation's inputs:
123
+
124
+ ```json
125
+ {
126
+ "operationId": "managementListDomains",
127
+ "pathParameters": {},
128
+ "query": { "limit": 10 },
129
+ "headers": {},
130
+ "body": null,
131
+ "mailboxId": null
132
+ }
133
+ ```
134
+
135
+ `operationId` uses the same curated operation IDs as the hosted MCP service. OAuth grants are audience-bound to the A2A resource and retain their Qubrics 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).
136
+
137
+ The A2A endpoint is immediate and stateless: streaming, push notifications, persistent tasks, and task cancellation are not advertised or routed.
138
+
139
+ ## Configuration
140
+
141
+ | Setting | Environment | Default |
142
+ | --- | --- | --- |
143
+ | Tool surfaces | `QUBRICS_MCP_SURFACES` | required for `qubrics-mcp`; wrapper commands select one surface |
144
+ | API key fallback | `QUBRICS_API_KEY` | accepted for compatible single-key setups |
145
+ | Mailbox API key | `QUBRICS_MAILBOX_API_KEY` | required when mailbox is selected unless a compatible fallback is provided |
146
+ | Management API key | `QUBRICS_MANAGEMENT_API_KEY` | required when management is selected unless a compatible fallback is provided |
147
+ | Sending API key | `QUBRICS_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 |
148
+ | App API base URL | `QUBRICS_APP_BASE_URL` | `https://app.qubrics.com/api/v1` |
149
+ | Sending API base URL | `QUBRICS_SENDING_BASE_URL` | `https://smtp.qubrics.com/api/v1` |
150
+ | Transport | `QUBRICS_MCP_TRANSPORT` | `stdio` |
151
+ | HTTP host | `QUBRICS_MCP_HOST` | `127.0.0.1` |
152
+ | HTTP port | `QUBRICS_MCP_PORT` | `8765` |
153
+ | HTTP path | `QUBRICS_MCP_PATH` | `/mcp` |
154
+ | HTTP bearer token | `QUBRICS_MCP_HTTP_BEARER_TOKEN` | required for HTTP unless opt-out is enabled |
155
+ | Allow unauthenticated HTTP | `QUBRICS_MCP_ALLOW_UNAUTHENTICATED_HTTP` | `false` |
156
+ | Allowed browser origins | `QUBRICS_MCP_ALLOWED_ORIGINS` | no browser origins |
157
+ | Snapshot directory override | `QUBRICS_MCP_OPENAPI_INPUT_DIR` or `OPENAPI_INPUT_DIR` | packaged snapshots |
158
+ | App snapshot override | `QUBRICS_MCP_APP_OPENAPI` | packaged app snapshot |
159
+ | Sending snapshot override | `QUBRICS_MCP_SENDING_OPENAPI` | packaged sending snapshot |
160
+ | Request timeout | `QUBRICS_MCP_TIMEOUT_SECONDS` | `30` |
161
+ | Retry attempts | `QUBRICS_MCP_RETRY_MAX_ATTEMPTS` | `3` |
162
+ | Retry time budget, in seconds | `QUBRICS_MCP_RETRY_MAX_ELAPSED_SECONDS` | unset |
163
+
164
+ 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.
165
+
166
+ 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.
167
+
168
+ ## Tool Surfaces
169
+
170
+ - 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`.
171
+ - Management: tools for domains, mailboxes, logs, metrics, spend summary, and webhooks. Requires an `smx_root_*` key.
172
+ - Sending: tools for attachment upload refs, single sends, and batch sends. Requires an `smx_mbx_*` key or owner-approved Sending-resource `smx_agent_*` token.
173
+
174
+ The server rejects keys with the wrong prefix before starting.
175
+
176
+ ## Package Contract For Maintainers
177
+
178
+ The source checkout includes `qubrics/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.
179
+
180
+ After installing a build that contains the contract, read it without credentials or network requests:
181
+
182
+ ```python
183
+ from qubrics.mcp.contract import load_contract
184
+
185
+ contract = load_contract()
186
+ print(contract["package"])
187
+ ```
188
+
189
+ 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.
190
+
191
+ `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.
192
+
193
+ 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 qubrics.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.
194
+
195
+ ## Attachment Workflow For Agents
196
+
197
+ Use `qubrics_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.
198
+
199
+ When a message has attachments:
200
+
201
+ 1. Call `qubrics_mailbox_read_attachment` with `message_id` and `attachment_id` when you need the attachment contents.
202
+ 2. For small text-like attachments, read the returned `text`.
203
+ 3. For binary or oversized attachments, use the returned `resource_link` / `download_url` promptly outside model context.
204
+ 4. Use `qubrics_mailbox_get_attachment` only when metadata is enough or you need to refresh the link.
205
+
206
+ Use `qubrics_mailbox_upload_attachment` for outbound attachments over MCP. It accepts exactly one input mode:
207
+
208
+ - `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`.
209
+ - `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.
210
+
211
+ Presigned uploads use the mailbox attachment cap, currently `7,500,000` bytes per attachment, and pin the exact declared byte length and content type.
212
+
213
+ For mailbox sends, `qubrics_mailbox_send_message` accepts either tiny inline base64 attachment objects (`content`, `filename`, `content_type`) or uploaded attachment references (`blob_id`, `filename`, `content_type`).
214
+
215
+ For Sending API sends, use `qubrics_sending_upload_attachment` only for tiny inline content, or call `qubrics_sending_create_attachment_upload` and PUT bytes outside model context. Then pass `{"attachment_id": "att_..."}` in `qubrics_sending_send_email.attachments[]`.
216
+
217
+ ## Console Scripts
218
+
219
+ - `qubrics-mcp`
220
+ - `qubrics-mcp-mailbox`
221
+ - `qubrics-mcp-management`
222
+ - `qubrics-mcp-sending`
223
+ - `qubrics-mcp-hosted`
224
+
225
+ ## Support
226
+
227
+ Open an issue in [qubrics/qubrics-sdk](https://github.com/qubrics/qubrics-sdk/issues) with the package name, version, command, transport, and request ID from any API error.
228
+
229
+ ## Licence
230
+
231
+ MIT. See the [licence file](https://github.com/qubrics/qubrics-sdk/blob/main/LICENSE).
@@ -0,0 +1,42 @@
1
+ <evals>
2
+ <eval id="1">
3
+ <question>Send a short message from the authenticated mailbox to a supplied recipient, then list recent mailbox messages to confirm the mailbox can still be read.</question>
4
+ <expected>Call mailbox_send_message with an idempotency key, then mailbox_list_messages with a small limit.</expected>
5
+ </eval>
6
+ <eval id="2">
7
+ <question>Find the latest message matching a subject fragment and read its body.</question>
8
+ <expected>Call mailbox_search_message_snippets, choose a message_id, then call mailbox_list_body or mailbox_list_content.</expected>
9
+ </eval>
10
+ <eval id="3">
11
+ <question>Show unread message volume and list the first page of messages without fetching full bodies.</question>
12
+ <expected>Call mailbox_count_messages, then mailbox_list_messages with a small limit.</expected>
13
+ </eval>
14
+ <eval id="4">
15
+ <question>Archive or mark a set of mailbox messages after the user supplies message IDs.</question>
16
+ <expected>Call mailbox_batch_update_messages with the supplied IDs and desired flag or folder changes.</expected>
17
+ </eval>
18
+ <eval id="5">
19
+ <question>Summarise the current mailbox identity and the folders available for filing messages.</question>
20
+ <expected>Call mailbox_get_identity and mailbox_list_folders.</expected>
21
+ </eval>
22
+ <eval id="6">
23
+ <question>Prepare a domain for sending and return the DNS records the user should configure.</question>
24
+ <expected>Call management_create_domain if needed, then management_get_domain_zone_file.</expected>
25
+ </eval>
26
+ <eval id="7">
27
+ <question>Create a mailbox and produce a mailbox API key for an agent that should only access that mailbox.</question>
28
+ <expected>Call management_create_mailbox, then management_create_mailbox_key for the new mailbox.</expected>
29
+ </eval>
30
+ <eval id="8">
31
+ <question>Investigate a delivery issue for a known email log ID.</question>
32
+ <expected>Call management_get_email_log and use the structured result to explain the delivery status.</expected>
33
+ </eval>
34
+ <eval id="9">
35
+ <question>Send one transactional email through the sending surface and include an idempotency key.</question>
36
+ <expected>Call sending_send_email with a complete message body and Idempotency-Key.</expected>
37
+ </eval>
38
+ <eval id="10">
39
+ <question>Explain why a mailbox-key MCP server cannot manage domains or create mailbox keys.</question>
40
+ <expected>List mailbox tools only; management tools are absent and management startup rejects smx_mbx_ credentials.</expected>
41
+ </eval>
42
+ </evals>
@@ -0,0 +1,57 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "qubrics-mcp"
7
+ version = "3.0.0"
8
+ description = "Email inbox API and outbound sending tools for AI Agents."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ classifiers = [
13
+ "License :: OSI Approved :: MIT License",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.10",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Programming Language :: Python :: 3.13",
19
+ ]
20
+ dependencies = [
21
+ "a2a-sdk[http-server]==1.1.2",
22
+ "anyio>=4.9,<5",
23
+ "fastmcp==4.0.3",
24
+ "httpx>=0.28.1,<1",
25
+ "httpx2>=2.5,<3",
26
+ "jsonschema>=4.20,<5",
27
+ "mcp==2.2.0",
28
+ "posthog>=7.21.0,<8",
29
+ "qubrics-core>=2.0.0,<3.0.0",
30
+ ]
31
+
32
+ [project.scripts]
33
+ qubrics-mcp = "qubrics.mcp.cli:main"
34
+ qubrics-mcp-hosted = "qubrics.mcp.hosted:run_hosted"
35
+ qubrics-mcp-mailbox = "qubrics.mcp.cli:main_mailbox"
36
+ qubrics-mcp-management = "qubrics.mcp.cli:main_management"
37
+ qubrics-mcp-sending = "qubrics.mcp.cli:main_sending"
38
+
39
+ [project.urls]
40
+ Repository = "https://github.com/qubrics/qubrics-sdk"
41
+
42
+ [tool.hatch.build]
43
+ exclude = ["qubrics/mcp/openapi/*.json"]
44
+
45
+ [tool.hatch.build.targets.sdist]
46
+ core-metadata-version = "2.4"
47
+ include = [
48
+ "LICENSE",
49
+ "README.md",
50
+ "evals.xml",
51
+ "qubrics",
52
+ ]
53
+
54
+ [tool.hatch.build.targets.wheel]
55
+ core-metadata-version = "2.4"
56
+ packages = ["qubrics"]
57
+ artifacts = ["qubrics/mcp/runtime_openapi/*.json"]
@@ -0,0 +1,6 @@
1
+ from __future__ import annotations
2
+
3
+ from qubrics.mcp.config import ServerConfig, Surface
4
+ from qubrics.mcp.server import create_server
5
+
6
+ __all__ = ["ServerConfig", "Surface", "create_server"]
@@ -0,0 +1,6 @@
1
+ from __future__ import annotations
2
+
3
+ from qubrics.mcp.cli import main
4
+
5
+ if __name__ == "__main__":
6
+ raise SystemExit(main())