# SDKs, CLI and MCP

> Two SDKs do the same things: `@zurchin/sdk` for TypeScript and JavaScript (Node 20 or later, and any runtime with Web Crypto and fetch) and `zurchin` for Python 3.10 or later. Both are Apache-2.0. On top of them, `zurchin` the command line and `zurchin-mcp` the MCP server. This page lists every function, command and tool.

Source: https://zurchin.com/docs/sdks

## Install

TypeScript:

```bash
npm install @zurchin/sdk
```

Python:

```bash
pip install zurchin
```

CLI:

```bash
npm install -g @zurchin/cli
```

MCP:

```bash
claude mcp add zurchin -- npx -y @zurchin/mcp
```

Source: [zurchin/pidgeon-js](https://github.com/zurchin/pidgeon-js) (the SDK, the CLI and the MCP server) and [zurchin/pidgeon-python](https://github.com/zurchin/pidgeon-python). The Python SDK depends on `cryptography` and `httpx`; the TypeScript one on `web-bot-auth` and `jose`.

> **Note:** Version 2 (SDKs and CLI) and MCP 1.0 are for this API. Code written for 1.x spoke the old email API at `/api/v1`, which stops seven days after the move; it keeps working on 1.68.0 until then ([Moving from the old API](https://zurchin.com/docs/old-api.md)).

## The API client

| TypeScript | Python | Does |
| --- | --- | --- |
| `new Zurchin({ apiKey \| getToken, baseUrl?, fetch? })` | `Zurchin(api_key, base_url=…, client=None, timeout=10.0)` | The API client: an API key or an OAuth access token. Keep it on a server. Its groups are below. |
| `verifyWebhook(secret, rawBody, header)` | `verify_webhook(secret, raw_body, header)` | Check a [webhook](https://zurchin.com/docs/webhooks.md#verify). |

Errors: `PidgeonError` with `status`, `code` and `message` in both.

## The API, by group

The client’s calls are grouped by what they act on. TypeScript takes an object of camelCase options, Python keyword arguments. Email’s groups are on the client in TypeScript (`zurchin.threads`) and under `email` in Python (`zurchin.email.threads`; the 2.0 groups stay on the client too). Lists that page answer `{ data, has_more, next_cursor }`.

| Group | Calls | Endpoints |
| --- | --- | --- |
| `inboxes` | `list`, `get`, `create`, `remove` | [`/v1/email/inboxes`](https://zurchin.com/docs/email.md) |
| `messages` | `send(inboxId, message)` (with `attachmentIds`), `list`, `get` (`body: clean`), `markSeen` / `update(seen=)`, `await` / `wait` (wait for mail), `search(q, { inboxId })` or `search({ q, inboxId })` / `email.search` | [Send mail](https://zurchin.com/docs/sending.md), [Reading mail](https://zurchin.com/docs/email.md#reading) |
| `threads` | `list`, `get`, `update` (file, star, hand to a person), `remove`, `addLabel`, `removeLabel` | [Conversations](https://zurchin.com/docs/email.md#conversations) |
| `labels` | `list`, `create`, `update`, `remove` | [Labels](https://zurchin.com/docs/email.md#labels) |
| `attachments` | `upload` (straight to storage over 4 MB; Python `upload_large`), `get` (a five-minute link) | [Attachments](https://zurchin.com/docs/email.md#attachments) |
| `contacts` | `list`, `get`, `update`, `remove` | [Contacts](https://zurchin.com/docs/email.md#contacts) |
| `calendar` | `list`, `get`, `create`, `update`, `remove` (Python `email.calendar.events`) | [The calendar](https://zurchin.com/docs/email.md#calendar) |
| `domains` | `list`, `get`, `enableMail`, `disableMail`, `check` | [Your own domain](https://zurchin.com/docs/email.md#domains) |
| `appPasswords` / `email.app_passwords` | `list`, `create`, `revoke` | [Mail apps](https://zurchin.com/docs/email.md#mail-apps) |
| Also | `storage()`, `testInbound()` / `email.test_inbound()`, `inboxes.holdSuspicious` / `inboxes.update(hold_suspicious=True)` | [Storage](https://zurchin.com/docs/email.md#storage), [Test keys](https://zurchin.com/docs/email.md#test-mode) |
| `drafts` | `create`, `get`, `update`, `remove`, `send` (now or at a time), `requestApproval` / `request_approval` | [Send mail](https://zurchin.com/docs/sending.md) |
| `rules` | `list`, `create`, `remove` | `/v1/email/rules` |
| `suppressions` | `list`, `add`, `remove` | `/v1/email/suppressions` |
| `events` | `list` | `/v1/events` |
| `pods` | `list`, `create`, `remove` | [`/v1/pods`](https://zurchin.com/docs/api-keys.md#pods) |
| `webhooks` | `list`, `create`, `remove` | [Webhooks](https://zurchin.com/docs/webhooks.md#endpoints) |

Anything else: `request(method, path, …)`, the call every group is made of.

TypeScript:

```ts
const inbox = await zurchin.inboxes.create({ name: 'bookings' });
await zurchin.messages.send(inbox.id, {
  to: ['ana@example.com'],
  subject: 'Table for two',
  text: 'Friday at 8?',
});
```

Python:

```python
inbox = zurchin.inboxes.create("bookings")
zurchin.messages.send(inbox["id"], to=["ana@example.com"],
                      subject="Table for two", text="Friday at 8?")
```

## On your machine (TypeScript)

`@zurchin/sdk/node`, for Node only, is what the CLI and the MCP server share. Files live in `ZURCHIN_CONFIG_DIR`, else `~/.config/pidgeon`, readable by you only.

| Function | Does |
| --- | --- |
| `signIn({ scope?, baseUrl? })` | Sign in with the browser through Zurchin’s OAuth server (PKCE, a loopback redirect) and keep the session, refreshed from then on. |
| `signOut(baseUrl)` | End the session at Zurchin and forget it. |
| `clientFromEnvironment()` | The API client: `ZURCHIN_API_KEY` if set, else the session. |

## The CLI

`zurchin` (`npm install -g @zurchin/cli`). `--json` prints the API’s own answer; `ZURCHIN_API_KEY` wins over a session.

```bash
zurchin login [--scope admin|send|draft|read]
zurchin inboxes list | create <name> [--domain <domain>] [--pod <pod-id>] | remove <inbox-id>
zurchin send <inbox-id> --to ana@example.com --subject "Hi" --text "…"
zurchin drafts create <inbox-id> … | show | send [--at <time>] | approval | remove <draft-id>
zurchin mail list <inbox-id> | read <message-id> [--original] | wait <inbox-id> [--since …]
zurchin search <words> [--inbox <inbox-id>]
zurchin threads list [--folder archive] | show <id> | file <id> --folder <f> | hand-over <id>
zurchin app-passwords create <inbox-id> <name> | list <inbox-id> | revoke <id>
zurchin webhooks list | create <url> --event message.received | remove <id>
zurchin events [--type <type>]
zurchin pods list | create <name> | remove <pod-id>
zurchin api GET /v1/email/rules

# A list prints a page; when there is more, its last line is the next page's --cursor.
zurchin inboxes list --limit 20 --cursor <cursor>
```

## Claude Agent SDK

Connect the hosted MCP server in `query()`’s options, with an API key in the header.

TypeScript:

```ts
import { query } from '@anthropic-ai/claude-agent-sdk';

for await (const message of query({
  prompt: 'Make an inbox called bookings and email ops@example.com from it.',
  options: {
    mcpServers: {
      zurchin: {
        type: 'http',
        url: 'https://zurchin.com/mcp',
        headers: { Authorization: `Bearer ${process.env.ZURCHIN_API_KEY}` },
      },
    },
    allowedTools: ['mcp__zurchin__*'],
  },
})) {
  if (message.type === 'result' && message.subtype === 'success') console.log(message.result);
}
```

Python:

```python
import os
from claude_agent_sdk import ClaudeAgentOptions

options = ClaudeAgentOptions(
    mcp_servers={
        "zurchin": {
            "type": "http",
            "url": "https://zurchin.com/mcp",
            "headers": {"Authorization": f"Bearer {os.environ['ZURCHIN_API_KEY']}"},
        }
    },
    allowed_tools=["mcp__zurchin__*"],
)
```

## OpenAI Agents SDK

Connect the hosted MCP server over Streamable HTTP, with an API key in the header.

```python
import asyncio, os
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp

async def main():
    async with MCPServerStreamableHttp(
        name="zurchin",
        params={
            "url": "https://zurchin.com/mcp",
            "headers": {"Authorization": f"Bearer {os.environ['ZURCHIN_API_KEY']}"},
        },
    ) as zurchin:
        agent = Agent(name="Scout", mcp_servers=[zurchin])
        result = await Runner.run(agent, "Any new mail? Answer what needs an answer.")
        print(result.final_output)

asyncio.run(main())
```

## Vercel AI SDK

`@zurchin/ai-sdk` gives a model Zurchin’s tools: inboxes, sending, waiting for mail, drafts and approval. Actions that can’t be undone wait for a person.

Install:

```bash
npm install @zurchin/ai-sdk ai
```

TypeScript:

```ts
import { generateText, isStepCount } from 'ai';
import { pidgeonToolApproval, pidgeonTools } from '@zurchin/ai-sdk';

const tools = pidgeonTools(); // ZURCHIN_API_KEY
const { text } = await generateText({
  model: 'anthropic/claude-sonnet-5.5',
  tools,
  toolApproval: pidgeonToolApproval(tools),
  stopWhen: isStepCount(10),
  prompt: 'Make an inbox called bookings, email ops@example.com from it and wait for the answer.',
});
```

## LangChain

`langchain-zurchin` gives LangChain and LangGraph agents Zurchin’s tools: their own inbox, sending, replying, reading conversations and waiting for mail. Python 3.11 or later.

Install:

```bash
pip install langchain-zurchin
```

Python:

```python
from langchain.agents import create_agent
from langchain_zurchin import PidgeonToolkit

tools = PidgeonToolkit().get_tools()  # ZURCHIN_API_KEY
agent = create_agent("anthropic:claude-opus-5-5", tools=tools)
agent.invoke({"messages": [{"role": "user", "content": "Any new mail? Answer what needs an answer."}]})
```

## LlamaIndex

`llama-index-tools-zurchin` is a tool spec for LlamaIndex agents, with the same tools as LangChain’s. Python 3.11 or later.

Install:

```bash
pip install llama-index-tools-zurchin
```

Python:

```python
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.anthropic import Anthropic
from llama_index.tools.zurchin import PidgeonToolSpec

tools = PidgeonToolSpec().to_tool_list()  # ZURCHIN_API_KEY
agent = FunctionAgent(tools=tools, llm=Anthropic(model="claude-opus-5-5"))
response = await agent.run("Any new mail? Answer what needs an answer.")
```

## n8n

Two nodes. **Zurchin Trigger** starts a workflow when mail arrives, or when a message is held or a draft waits for a person. **Zurchin** sends, replies, waits for mail, makes drafts and inboxes, and works as a tool for n8n’s AI Agent node.

On n8n Cloud, search for Zurchin in the nodes panel. Self-hosted, an owner or admin installs `@zurchin/n8n-nodes-zurchin` under **Settings → Community Nodes → Install**. Then add the credential under **Credentials → New → Zurchin API**, with a key from [zurchin.com/keys](https://zurchin.com/keys).

## The MCP server

Two ways, the same tools. **Hosted**, at `https://zurchin.com/mcp`: nothing to install; your MCP client signs you in with Zurchin’s OAuth server the first time (it finds it from the server’s 401), or send an API key as `Authorization: Bearer pgn_…`. **Local**, `@zurchin/mcp` over stdio.

Hosted:

```bash
claude mcp add --transport http zurchin https://zurchin.com/mcp
```

Local:

```bash
claude mcp add zurchin -- npx -y @zurchin/mcp
```

Other clients:

```json
{ "mcpServers": { "zurchin": { "url": "https://zurchin.com/mcp" } } }
```

| For | Hosted | Local |
| --- | --- | --- |
| Email | `list_inboxes`, `get_inbox`, `hold_suspicious_mail`, `create_inbox`, `remove_inbox`, `list_messages`, `get_message`, `await_message`, `search_messages`, `update_message`, `send_message`, `reply_to_message`, `list_threads`, `get_thread`, `update_thread`, `list_labels`, `create_label`, `update_label`, `delete_label`, `apply_label`, `remove_label`, `read_attachment`, `find_contact`, `get_contact`, `update_contact`, `delete_contact`, `get_agenda`, `get_calendar_event`, `create_calendar_event`, `update_calendar_event`, `delete_calendar_event`, `create_draft`, `get_draft`, `update_draft`, `delete_draft`, `send_draft`, `request_approval`, `list_rules`, `add_rule`, `remove_rule`, `list_suppressions`, `add_suppression`, `remove_suppression`, `get_storage`, `list_domains`, `get_domain`, `enable_domain_mail`, `check_domain` | The same |
| The account | `list_events`, `list_pods`, `create_pod`, `rename_pod`, `move_to_pod`, `remove_pod`, `list_webhooks`, `add_webhook`, `remove_webhook` | `sign_in`, `sign_out`, `status`, `list_events`, `list_pods`, `create_pod`, `rename_pod`, `move_to_pod`, `remove_pod`, `list_webhooks`, `add_webhook`, `remove_webhook` |

Each tool is one [API](https://zurchin.com/docs/api.md) call (a few, such as `reply_to_message`, are two) made with your token, so it needs the same access: a `read` key or sign-in reads, and setting inboxes up takes `admin`. Mail tools read the Firewall’s cleaned text unless passed `body: "original"`; tool names kept from the old MCP server (`await_message`, `list_threads`, …) mean what they meant. `forward_message` is gone: passing on text a key read to someone outside its conversation is what [canary tokens](https://zurchin.com/docs/email.md#canary-tokens) refuse. `send_message`, `reply_to_message`, `create_draft` and `update_draft` take `attachment_ids`: files uploaded with an SDK or the API, since no tool uploads.
