# Qubrics SDKs [![npm version](https://img.shields.io/npm/v/@qubrics/sdk?label=npm)](https://www.npmjs.com/package/@qubrics/sdk) [![PyPI version](https://img.shields.io/pypi/v/qubrics-sdk?label=pypi)](https://pypi.org/project/qubrics-sdk/) [![Go Reference](https://pkg.go.dev/badge/qubrics.com/go/v4.svg)](https://pkg.go.dev/qubrics.com/go/v4) [![crates.io version](https://img.shields.io/crates/v/qubrics?label=crates.io)](https://crates.io/crates/qubrics) [![CI](https://github.com/qubrics/qubrics-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/qubrics/qubrics-sdk/actions/workflows/ci.yml) [![npm downloads](https://img.shields.io/npm/dm/@qubrics/sdk?label=npm%20downloads)](https://www.npmjs.com/package/@qubrics/sdk) [![Licence: MIT](https://img.shields.io/badge/licence-MIT-blue.svg)](LICENSE) **Marketing APIs that help AI find you customers.** Qubrics is building a gateway to bring **Marketing APIs for AI** together. The three parts of the gateway are designed to share one API key, one prepaid wallet and the same SDKs, CLI and Model Context Protocol (MCP) tools. - **Gateway** will route requests to partner APIs at the partner's list price, starting with enrichment and validation (next). - **Hosted** covers services Qubrics runs, starting with agent mailboxes (live). - **Connectors** lets teams connect their own accounts once and share access, starting with sending through Gmail, Outlook and SMTP (live). Email is live today; more categories ship on the roadmap. Use the packages below to send email, read a mailbox or manage your team's email setup. - Product documentation: [qubrics.com/docs](https://qubrics.com/docs) - Management API reference: [qubrics.com/docs/api/introduction](https://qubrics.com/docs/api/introduction) - Mailbox API reference: [qubrics.com/docs/mailbox-api/introduction](https://qubrics.com/docs/mailbox-api/introduction) - Sending API reference: [qubrics.com/docs/sending-api/introduction](https://qubrics.com/docs/sending-api/introduction) - MCP guide: [qubrics.com/docs/ai-integrations/mcp](https://qubrics.com/docs/ai-integrations/mcp) ## Packages | Ecosystem | Package | Surface | API-key / hosted auth | Install | Source | | --- | --- | --- | --- | --- | --- | | npm | `@qubrics/core` | Shared TypeScript helpers | n/a | `npm install @qubrics/core` | [`packages/ts/core`](packages/ts/core) | | npm | `@qubrics/sending` | Sending API | `smx_mbx_*` or owner-approved `smx_agent_*` | `npm install @qubrics/sending` | [`packages/ts/sending`](packages/ts/sending) | | npm | `@qubrics/mailbox` | Mailbox API | `smx_mbx_*` or `smx_agent_*` | `npm install @qubrics/mailbox` | [`packages/ts/mailbox`](packages/ts/mailbox) | | npm | `@qubrics/management` | Management API | `smx_root_*` | `npm install @qubrics/management` | [`packages/ts/management`](packages/ts/management) | | npm | `@qubrics/sdk` | TypeScript umbrella package | surface-specific | `npm install @qubrics/sdk` | [`packages/ts/sdk`](packages/ts/sdk) | | npm | `@qubrics/cli` | `qubrics` CLI | command/profile-specific | `npm install -g @qubrics/cli` | [`packages/ts/cli`](packages/ts/cli) | | npm | `@qubrics/ai-sdk` | Vercel AI SDK tools (agent inbox + sending) | REST OAuth or send + receive `smx_mbx_*` / `smx_agent_*` | `npm install @qubrics/ai-sdk ai zod` | [`packages/ts/ai-sdk`](packages/ts/ai-sdk) | | npm | `sendmux-mcp` | Published stdio bridge to hosted MCP | OAuth | `npx -y sendmux-mcp` | [`packages/ts/mcp-compat`](packages/ts/mcp-compat) | | Homebrew | `qubrics` | `qubrics` CLI | command/profile-specific | `brew install qubrics/tap/qubrics` | [`qubrics/homebrew-tap`](https://github.com/qubrics/homebrew-tap) | | PyPI | `qubrics-core` | Shared Python helpers | n/a | `pip install qubrics-core` | [`packages/python/core`](packages/python/core) | | PyPI | `qubrics-sending` | Sending API | `smx_mbx_*` or owner-approved `smx_agent_*` | `pip install qubrics-sending` | [`packages/python/sending`](packages/python/sending) | | PyPI | `qubrics-mailbox` | Mailbox API | `smx_mbx_*` or `smx_agent_*` | `pip install qubrics-mailbox` | [`packages/python/mailbox`](packages/python/mailbox) | | PyPI | `qubrics-management` | Management API | `smx_root_*` | `pip install qubrics-management` | [`packages/python/management`](packages/python/management) | | PyPI | `qubrics-sdk` | Python umbrella package | surface-specific | `pip install qubrics-sdk` | [`packages/python/sdk`](packages/python/sdk) | | PyPI | `qubrics-mcp` | Local MCP plus hosted MCP and A2A servers | OAuth for hosted; surface-specific keys for local | `pip install qubrics-mcp` | [`packages/python/mcp`](packages/python/mcp) | | PyPI | `langchain-qubrics` | LangChain toolkit (agent inbox + sending) | REST OAuth or send + receive `smx_mbx_*` / `smx_agent_*` | `pip install langchain-qubrics` | [`packages/python/langchain`](packages/python/langchain) | | Go | `qubrics.com/go/v4/core` | Shared Go helpers | n/a | `go get qubrics.com/go/v4@v4.0.0` | [`go/core`](go/core) | | Go | `qubrics.com/go/v4/sending` | Sending API | `smx_mbx_*` or owner-approved `smx_agent_*` | `go get qubrics.com/go/v4@v4.0.0` | [`go/sending`](go/sending) | | Go | `qubrics.com/go/v4/mailbox` | Mailbox API | `smx_mbx_*` or `smx_agent_*` | `go get qubrics.com/go/v4@v4.0.0` | [`go/mailbox`](go/mailbox) | | Go | `qubrics.com/go/v4/management` | Management API | `smx_root_*` | `go get qubrics.com/go/v4@v4.0.0` | [`go/management`](go/management) | | Go | `qubrics.com/go/v4/sdk` | Module anchor | n/a | `go get qubrics.com/go/v4@v4.0.0` | [`go/sdk`](go/sdk) | | crates.io | `qubrics` 1.0.0 | Rust umbrella crate | surface-specific | `cargo add qubrics@=1.0.0` | [`rust`](rust) | | Packagist | `qubrics/core` | Shared PHP helpers | n/a | `composer require qubrics/core:^3.0` | [`packages/php/core`](packages/php/core) | | Packagist | `qubrics/sending` | Sending API | `smx_mbx_*` or owner-approved `smx_agent_*` | `composer require qubrics/sending:^3.0` | [`packages/php/sending`](packages/php/sending) | | Packagist | `qubrics/mailbox` | Mailbox API | `smx_mbx_*` or `smx_agent_*` | `composer require qubrics/mailbox:^3.0` | [`packages/php/mailbox`](packages/php/mailbox) | | Packagist | `qubrics/management` | Management API | `smx_root_*` | `composer require qubrics/management:^3.0` | [`packages/php/management`](packages/php/management) | | Packagist | `qubrics/sdk` | PHP umbrella package | surface-specific | `composer require qubrics/sdk:^3.0` | [`packages/php/sdk`](packages/php/sdk) | | RubyGems | `qubrics-core` | Shared Ruby helpers | n/a | `gem install qubrics-core` | [`packages/ruby/core`](packages/ruby/core) | | RubyGems | `qubrics-sending` | Sending API | `smx_mbx_*` or owner-approved `smx_agent_*` | `gem install qubrics-sending` | [`packages/ruby/sending`](packages/ruby/sending) | | RubyGems | `qubrics-mailbox` | Mailbox API | `smx_mbx_*` or `smx_agent_*` | `gem install qubrics-mailbox` | [`packages/ruby/mailbox`](packages/ruby/mailbox) | | RubyGems | `qubrics-management` | Management API | `smx_root_*` | `gem install qubrics-management` | [`packages/ruby/management`](packages/ruby/management) | | RubyGems | `qubrics-sdk` | Ruby umbrella package | surface-specific | `gem install qubrics-sdk` | [`packages/ruby/sdk`](packages/ruby/sdk) | ## Quick start ### Python packages The published Python packages share the `qubrics` namespace. | Distribution | Python import | | --- | --- | | `qubrics-core` | `qubrics.core` | | `qubrics-sending` | `qubrics.sending` | | `qubrics-mailbox` | `qubrics.mailbox` | | `qubrics-management` | `qubrics.management` | | `qubrics-sdk` | `qubrics.sdk` | | `qubrics-mcp` | `qubrics.mcp` | | `langchain-qubrics` | `qubrics.langchain` | Import the Sending client factory with `from qubrics.sending import create_sending_client`. The LangChain class is `qubrics.langchain.QubricsToolkit`. ### Published packages Install the Sending client for your language. ```sh npm install @qubrics/sending pip install qubrics-sending go get qubrics.com/go/v4@v4.0.0 cargo add qubrics@=1.0.0 composer require qubrics/sending:^3.0 gem install qubrics-sending ``` Use send-capable `smx_mbx_*` keys or owner-approved Sending-resource `smx_agent_*` tokens for Sending clients. Use `smx_mbx_*` keys or scoped `smx_agent_*` tokens for Mailbox clients. Use root `smx_root_*` keys for Management clients. Agent tokens remain limited by server-side scopes; pre-claim self-registered agent tokens do not include `email.send`. ## OAuth authentication TypeScript, Python, Go, PHP, Ruby, and Rust surface clients accept a bare REST OAuth access token or a provider that resolves one before each request. Use the explicit token API below; API-key configuration continues to validate key prefixes. | Client | Access-token configuration | | --- | --- | | TypeScript | `accessToken: token` or `accessToken: () => token`; async providers are supported. | | Vercel AI SDK | Pass `accessToken: token` or an async token provider to the default export of `@qubrics/ai-sdk`. Grant `mailbox.read` and `email.send` for one mailbox. | | Python | `access_token=token` or a callable. | | LangChain | `QubricsToolkit(access_token=token)` or a callable. Grant `mailbox.read` and `email.send` for one mailbox. | | Go | `NewWithAccessToken(token)` or `NewWithTokenProvider(provider)`; providers receive the request context. | | PHP | Use a `WithAccessToken` factory with a token or callable. For Sending, use `ClientFactory::createEmailsApiWithAccessToken($token)`. | | Ruby | `access_token: token` or a callable. | | Rust | `new_with_access_token(token)` or `new_with_token_provider(provider)`; providers return a future. | Choose one credential source. Your application owns secure storage and refresh coordination. Request `resource=https://qubrics.com/api`. Each API still checks its required scopes and granted surface. Run `qubrics auth:login my-profile` for browser login and automatic token refresh. Run `qubrics auth:logout my-profile` to revoke the connection. [OAuth setup and lifecycle](https://qubrics.com/docs/developer-tools/oauth). ## Command-line access Install the CLI with Homebrew on macOS. ```sh brew install qubrics/tap/qubrics ``` You can also install it with npm. ```sh npm install -g @qubrics/cli ``` Give the agent a mailbox and save its credentials in the default local profile. ```sh qubrics agent:register my-agent --mailbox-local-part my-agent --default --json ``` Agent registration does not require an existing account or API key. It creates a local profile with a durable, revocable credential for reading and receiving mail. To send, invite the owner with `qubrics agent:invite-owner owner@example.com --profile my-agent`; after the owner accepts and approves sending, Sending API commands exchange and cache a one-hour delegated token automatically. `@qubrics/cli` also provides `sendmux` for one major release. It prints a deprecation line before running the same command. Existing profiles remain available. ## MCP and A2A Connect your MCP client to `https://mcp.qubrics.com/mcp` and complete the browser sign-in on the first connection. See the [hosted MCP setup guide](https://qubrics.com/docs/ai-integrations/mcp). For a stdio-only client, the `@qubrics/mcp` npm bridge is pending publication. Run the published bridge with `npx -y sendmux-mcp` and Node.js 22 or later. To run a local server with API keys, install the Python package and check the Mailbox command. ```sh pip install qubrics-mcp qubrics-mcp-mailbox --help ``` Local MCP supports stdio and HTTP. Hosted MCP uses OAuth. For A2A 1.0 clients, discover the hosted HTTP+JSON service from `https://a2a.qubrics.com/.well-known/agent-card.json`. It exposes the same curated mailbox, management, and sending operations with an OAuth grant bound specifically to `https://a2a.qubrics.com/a2a/v1`. ## Agent framework tools Install the package for your agent's framework. ```sh npm install @qubrics/ai-sdk ai zod pip install langchain-qubrics ``` The default export of `@qubrics/ai-sdk` returns a Vercel AI SDK `ToolSet`. In LangChain, call `QubricsToolkit(api_key=...).get_tools()`. Both use the Qubrics Sending and Mailbox clients. ## Connection checks Authenticated connection checks for all three API surfaces return the current team, credential identity, connection label, permissions and authorised mailboxes. Mailbox checks need no mailbox selector or provisioned storage; Sending checks require `email.send` without sending an email or checking delivery readiness. Existing `mailboxGetMe` behaviour is unchanged. | Surface | TypeScript operation | CLI command | MCP tool | | --- | --- | --- | --- | | Management | `managementGetConnection` | `management:get-connection` | `qubrics_management_get_connection` | | Mailbox | `mailboxGetConnection` | `mailbox:get-connection` | `qubrics_mailbox_get_connection` | | Sending | `sendingGetConnection` | `sending:get-connection` | `qubrics_sending_get_connection` | Use the corresponding client factory and credential. For example, with `QUBRICS_API_KEY` set to a Management key: ```ts import { management } from "@qubrics/sdk"; const client = management.createManagementClient({ apiKey: process.env.QUBRICS_API_KEY! }); const response = await management.managementGetConnection({ client }); console.log(response.data?.data.label); ``` ```sh qubrics management:get-connection --json ``` Each Rust client exposes `get_connection()`, returning `Response`. The Go, Python, PHP and Ruby clients expose the corresponding operation for each surface. ## Attachments and live mailbox events Mailbox attachment metadata now includes a short-lived `download_url`. Fetch that URL promptly with a plain HTTP client; it does not require an `Authorization` header, but it expires after a short TTL. If a download URL expires, re-fetch the message or attachment metadata to receive a fresh URL. To send files, use the attachment option for your client. Keep base64 out of prompts and source strings. - CLI: Add `--attach ./report.pdf` to `qubrics mailbox:send-message` or `qubrics sending:send` alongside the message body. - TypeScript: use `@qubrics/mailbox/node` `sendMailboxMessageWithFiles(...)` or `@qubrics/sending/node` `sendEmailWithFiles(...)`. - Python: use `qubrics.mailbox.send_mailbox_message_with_files(...)` or `qubrics.sending.send_email_with_files(...)`. - MCP: agents can mint a presigned upload URL, `PUT` bytes to it without an API key, then send with the returned `blob_id`. Mailbox direct uploads, presigned uploads, CLI `--attach`, and mailbox SDK file helpers share the mailbox attachment cap: currently `7,500,000` bytes per attachment. Sending API attachment helpers upload file bytes and send attachment references; the generated Sending API limit is max 10 attachments and a 25 MB request body. Small generated attachments can still use inline base64 where the API schema supports them. MCP inline base64 is capped at `32 KiB` decoded; use presigned upload, CLI `--attach`, or SDK file helpers for real files. To follow new mailbox events, use your client's event command or iterator. - TypeScript: `streamMailboxEvents(...)` returns an async iterator over typed mailbox realtime events. - Python: `iter_mailbox_events(...)` yields typed `MailboxRealtimeEvent` models from the generated mailbox client. - CLI: `qubrics mailbox:stream-events --follow` prints one JSON event per line until the stream closes or the process is interrupted. - MCP: use `qubrics_mailbox_wait_for_message` for bounded waits inside agent tool calls, then `qubrics_mailbox_get_attachment` to renew attachment metadata and fetch `download_url`. ## Repository structure Maintainers: use the [protected live E2E matrix](docs/live-e2e-matrix.md) for credential-free planning, explicit identity/send gates, cleanup evidence, and fresh-run audit rules. Static coverage and expected API negatives are not live capability certification. Attachment byte scenarios require trusted retention verification before live execution. | Path | Purpose | | --- | --- | | [`packages/ts`](packages/ts) | TypeScript SDK packages and the `qubrics` CLI. | | [`packages/python`](packages/python) | Python SDK packages and `qubrics-mcp`. | | [`go`](go) | Go module `qubrics.com/go/v4` and subpackages. | | [`rust`](rust) | Source for the `qubrics` crate. | | [`packages/php`](packages/php) | PHP package sources used for Packagist packages and public split repositories. | | [`packages/ruby`](packages/ruby) | RubyGem package sources. | | [`codegen`](codegen) | Generator configuration and templates. | | [`scripts`](scripts) | Generation, verification, publishing, and release helper scripts. | | [`docs`](docs) | Surface-coverage and live E2E audit artefacts. | | [`.github/workflows`](.github/workflows) | CI, canary, live E2E, and release workflows. | ## Versioning and support ### Ruby packages All five Ruby packages use the `Qubrics` module. Install their published versions from RubyGems with the commands in the Packages table. For the umbrella SDK, use `gem install qubrics-sdk`. | Gem | Ruby require | | --- | --- | | `qubrics-core` | `qubrics/core` | | `qubrics-sending` | `qubrics/sending` | | `qubrics-mailbox` | `qubrics/mailbox` | | `qubrics-management` | `qubrics/management` | | `qubrics-sdk` | `qubrics/sdk` | ### Maintain package contracts In a source checkout, maintainers can inspect the generated [MCP package contract](packages/python/mcp/qubrics/mcp/mcp-contract.json) for the actual tool catalogue, schemas, upload workflows, hosted resource, and frozen protocol revisions. It describes this checkout, not the version already available from a package registry. Source hashes and native distribution metadata bind the artifact to its inputs; local transports and upstream API origins are separate from the hosted OAuth resource. With the workspace dependencies installed and Python 3.10 or newer available, run these commands from the repository root: ```sh pnpm generate:mcp pnpm test:release-state pnpm build:mcp ``` Generation refreshes editable Python metadata before discovering tools without upstream requests. The build checks wheel and source-distribution contents, an installed-wheel consumer outside the checkout, and the frozen conformance requirements. `pnpm drift:check` rejects generated changes that have not been staged or committed. Regenerate and review the contract when a release PR changes MCP's native version; do not reuse a contract from the previous version. Prepare each Python release PR from its freshly fetched head with `pnpm generate:python` followed by `pnpm generate:mcp`. Python generation synchronises internal dependency floors and their next-major upper bounds with the release manifest, then derives generated client versions from each native `pyproject.toml`. MCP generation refreshes the contract's package version and metadata digest. Review and commit the generated changes, then run `pnpm drift:check`, `pnpm test:release-state` and `pnpm build:python:dists`. Keep releases sequential and repeat preparation after Release Please refreshes a remaining PR; each candidate uses the sibling versions recorded in its own manifest. Native release validation covers TypeScript, Python, Rust, Ruby, and Go's component/tag convention. Go has no in-module version field. PHP versions belong to split-repository tags, not `composer.version` or release-please; Composer identities and dependencies are checked without treating a local path-repository version as publication evidence. Exact published tags and versions remain release gates. Maintainers: [native publication gates](docs/native-publication.md) bind the supported release-workflow entries and PHP split command to immutable candidates and require fresh, strict live-schema parity before their first write. Low-level Ruby, npm, and Homebrew helpers are not guarded standalone release procedures; manual Snap promotion remains owner-approved policy. ### Verify runtime compatibility from source Maintainers: the [CI workflow](.github/workflows/ci.yml) separates the generation/static build from language runtime checks. A configured cell is a required check, not a claim that an unreleased checkout has passed remotely. Compatibility floors aren't recommendations to deploy upstream-EOL runtimes. | Runtime | Required CI cells | Candidate package boundary | | --- | --- | --- | | Node | 22, 24, 26 on Ubuntu, macOS, Windows | Six explicitly installed tarballs and CLI | | Python | 3.10–3.14 on Ubuntu | Seven wheels with runtime tests; seven sdists with isolated installation | | Go | 1.23.4, 1.26, 1.27 on Ubuntu | External module with an explicit candidate replacement; no toolchain auto-upgrade | | PHP | 8.2–8.5 on Ubuntu | Five individual splits and an all-local umbrella consumer | | Ruby | 3.1, 3.2, 3.3, 3.4.1, 4.0 on Ubuntu | Five locally installed gems; development tooling only on 3.4.1 | | Rust | 1.82.0 and stable/latest on Ubuntu | Independent source locks, verified crate, separately locked floor consumer | After the corresponding source build, run `node scripts/ci-consumers.mjs node`, `python`, `go`, or `ruby` from the repository root to verify installed imports outside the checkout. Python's repository-only MCP contract/packaging tests remain in source checks; the wheel consumer runs runtime tests and installed `load_contract()` without source-path injection. PHP uses `node scripts/check-php-splits.mjs` for the all-local composition check; individual splits can resolve published sibling dependencies and aren't that proof. Linux Node cells additionally run `node scripts/ci-consumers.mjs ai` for the 12 exact AI/Zod pairs recorded in that helper. The AI SDK wrapper requires Zod 3.25.76 or newer and retains AI 5/6/7 coverage, including the historical AI 5.0.0/Zod 4.0.0 intersection. For Rust, run the locked all-target/all-feature and doc tests with `cargo +1.82.0`, then `node scripts/ci-consumers.mjs rust` with stable and 1.82.0 installed (stable needs Clippy). That helper resolves latest dependencies in a temporary copy, tests and verifies `cargo +stable package --locked`, and checks the unpacked crate using `rust/ci/floor-consumer/Cargo.lock`. It never substitutes the library's embedded lock for the consumer lock. [Surface coverage](docs/surface-coverage.md) and [Rust operation decisions](rust/operation-decisions.json) distinguish named methods from partial/raw/unsupported operations. ### Package release boundaries SDK packages track the Qubrics public API contracts. Patch versions can differ between packages when a fix only affects one ecosystem or runtime. Generated clients are built from committed OpenAPI snapshots. Any API contract change must update the snapshots and generated output in the same change. For help, open a [GitHub issue](https://github.com/qubrics/qubrics-sdk/issues) with the package name, version, command or import path, and the request ID from any API error response. ## Contributing Open pull requests against this repository. Keep generated output, source snapshots, and verification artefacts together in the same change. Security issues should be reported through [GitHub Security Advisories](https://github.com/qubrics/qubrics-sdk/security/advisories). ## Licence This repository is available under the [MIT licence](LICENSE).