Integrations
MCP server
Let Claude, Cursor, or VS Code manage Ternwire domains, templates, webhooks, and email through the Model Context Protocol.
On this page
Ternwire's MCP server lets an AI assistant manage a Ternwire account through the Model Context Protocol. Use the hosted server at https://ternwire.com/mcp, where you sign in instead of pasting a key, or run @ternwire/mcp on your own computer with an API key. Both offer the same tools, except that only the local server can read an import file from your computer, and both call the Ternwire /v1 API, so the assistant can do exactly what you allowed and nothing more.
Hosted server
Add https://ternwire.com/mcp to your client as a remote MCP server:
- Claude: open Settings, then Connectors, select Add custom connector and enter the URL.
- ChatGPT: in a workspace with connectors turned on, open Settings, then Connectors, create a connector and enter the URL.
- Claude Code: run
claude mcp add --transport http ternwire https://ternwire.com/mcp. - Cursor: add the server to
.cursor/mcp.jsonor~/.cursor/mcp.json:
{
"mcpServers": {
"ternwire": {
"url": "https://ternwire.com/mcp"
}
}
}The first time the client connects, it opens Ternwire in your browser. Sign in, then choose:
- Workspace: the app works in this workspace only. Only a workspace owner can connect an app, because the app gets the same access as an API key.
- Mode: Live delivers to real inboxes. Test delivers nothing, like a test key.
- Access: Everything, Transactional email (send email and manage templates, webhooks and domains) or Read only. Open the permission list to see the exact scopes.
Select Allow and the browser returns you to the app. The app gets an access token that lasts an hour and renews it by itself. It stays connected until you revoke it under Connected apps on the API keys page, or until it goes unused for 60 days. Requests the app makes appear in the request log under its name.
Clients that cannot sign in can send an API key instead, as Authorization: Bearer em_live_....
A connected app never gets the api_keys:write scope, so it cannot create or revoke API keys: a key it made would keep working after you disconnect the app.
To load fewer tools, add them to the URL, as with TERNWIRE_MCP_TOOLSETS on the local server: https://ternwire.com/mcp?toolsets=email,domains, and &readonly=true for tools that change nothing.
Local server
The local server runs on your computer over stdio and calls the API with an API key you paste into the client's settings. It requires Node.js 20.11 or later.
Install
Install the server in Cursor or VS Code in one click with these buttons, then replace em_live_... with your API key in the server settings:
Or configure your client by hand:
claude mcp add ternwire \
-e TERNWIRE_API_KEY=em_live_... \
-- npx -y @ternwire/mcpCursor reads .cursor/mcp.json in your project or ~/.cursor/mcp.json. VS Code reads .vscode/mcp.json. Claude Desktop uses the same mcpServers format as Cursor.
The server calls https://ternwire.com by default. To point it at a local or staging API, add TERNWIRE_API_ORIGIN, for example "TERNWIRE_API_ORIGIN": "http://localhost:3001".
The key needs the send scope. Domain tools also need a live key, because test keys cannot provision domains. Newsletter tools need the newsletter scopes and a live key.
To create a key for newsletter work, open API keys in the dashboard, choose Live, select Marketing agent and select Create API key. The preset checks every newsletter scope, plus send for templates. Only a workspace owner can create keys. To change scopes, create a new key and revoke the old one.
Choose which tools to load
The server offers about 80 tools, and each one takes room in the assistant's context. Load only the toolsets you need with TERNWIRE_MCP_TOOLSETS, a comma-separated list:
| Toolset | What it covers |
|---|---|
email | Sending email and reading its delivery, templates, webhooks, blocked addresses, tracking settings and metrics |
domains | Sending domains and their DNS records |
receiving | Receiving addresses and the email they received |
newsletters | Audiences, contacts, imports, broadcasts, automations and newsletter settings |
account | The workspace, plan and quota the key acts for, and API keys |
For example, "TERNWIRE_MCP_TOOLSETS": "email,domains" loads only the tools for app email. Leave it out, or set it to all, for every tool. An unknown name stops the server with an error, so a typo never starts it without the tools you asked for.
Set "TERNWIRE_MCP_READ_ONLY": "true" to offer only tools that change nothing, for an assistant that should look but not act.
Structured results, resources and prompts
Each tool that returns an API object declares an output schema, taken from the OpenAPI document, and returns the object as structured content next to the JSON text. Clients that support structured output get typed fields and their descriptions.
The server also offers resources the assistant can read without calling the API:
| Resource | What it holds |
|---|---|
ternwire://reference/errors | Every error code with what to do about it |
ternwire://reference/webhook-events | Every webhook event and the JSON schema of its body |
ternwire://reference/openapi.json | The whole public API as OpenAPI 3.1 |
ternwire://docs/<page> | These docs as Markdown, such as ternwire://docs/test-mode |
And prompts, which clients such as Claude Code show as slash commands: set_up_sending_domain, send_test_email, investigate_delivery, migrate_newsletter_list and send_newsletter. Each one walks the assistant through the task with the right tools and asks you before anything that sends email or cannot be undone.
Tools
| Area | Tools |
|---|---|
| Account | get_account |
| API keys | list_api_keys, create_api_key, revoke_api_key |
| Domains | list_domains, get_domain, create_domain, delete_domain, check_domain, get_domain_dns_setup |
| Templates | list_templates, get_template, create_template, update_template, delete_template, render_template, render_unsaved_template, generate_template, get_template_generation_credits |
| Webhooks | list_webhook_endpoints, create_webhook_endpoint, set_webhook_endpoint_enabled, rotate_webhook_signing_secret, delete_webhook_endpoint, list_webhook_attempts, get_webhook_attempt, replay_webhook_attempt |
| Blocked addresses | list_suppressions, block_address, unblock_address |
| Receiving | list_receiving_addresses, add_receiving_address, set_receiving_forwarding, check_receiving_addresses, remove_receiving_address, list_received_emails, get_received_email |
send_email, get_email, list_emails | |
| Email tracking | get_tracking_settings, update_tracking_settings |
| Metrics | get_metrics |
| Audiences | create_audience, list_audiences, get_audience, update_audience, archive_audience, export_audience |
| Subscriptions | request_subscription, unsubscribe_contact |
| Contacts | upsert_contact, list_contacts, get_contact, delete_contact |
| Contact imports | list_contact_import_sources, upload_contact_import_file, create_contact_import, list_contact_imports, get_contact_import, apply_contact_import, get_contact_import_batch, apply_contact_import_batch |
| Broadcasts | create_broadcast, list_broadcasts, get_broadcast, update_broadcast, preview_broadcast, send_broadcast_test, send_broadcast, unschedule_broadcast, pause_broadcast, resume_broadcast, cancel_broadcast, list_broadcast_recipients, get_broadcast_engagement, get_broadcast_ab_test, pick_broadcast_ab_test_winner |
| Marketing settings | get_marketing_settings, update_marketing_settings |
| Automations | create_automation, list_automations, get_automation, update_automation, activate_automation, pause_automation, archive_automation, get_automation_stats, list_automation_enrollments, send_automation_test, create_contact_event |
Read-only tools set readOnlyHint, and tools that delete or invalidate something set destructiveHint, so your client can ask before those run. send_broadcast, cancel_broadcast and archive_automation are destructive because none can be undone.
Every public API operation has a tool except the attachment upload operations. An upload ends with a raw PUT of the file bytes to a storage URL, which a tool call cannot carry, so send_email takes no attachments. A test in the package fails when a new API operation has no tool.
Behavior worth knowing
send_email requires an idempotencyKey. Use a new key for each email and the same key when retrying a call whose outcome is unknown. The API then returns the original message instead of sending again. A template send takes templateId and values only. Any other send needs a subject.
create_template and update_template write Handlebars templates. render_template and render_unsaved_template show what a template produces with sample values, without sending anything. generate_template writes a draft with AI: it needs the templates:generate scope and a paid plan, uses AI credits, and saves nothing until you call create_template.
create_api_key returns the new key's secret once. The new key can have no more access than the key the server uses, and the assistant should hand the secret to you rather than keep it in the conversation. get_domain_dns_setup returns a link where you approve a domain's DNS records at your DNS provider in one step, when the provider supports it; the assistant gives you the link, because only you can approve it.
Newsletters with an assistant
The server sends the assistant a short newsletter workflow when it connects. The tool descriptions repeat the rules that matter at each step:
request_subscriptionalways sends a confirmation email. The contact stayspendinguntil they click the link, and the assistant cannot confirm anyone itself.upsert_contactandcreate_contact_importnever subscribe anyone. Aconfirmedimport needs consent columns and a policy version, and Ternwire reviews it before it can be applied.- To move a list from another platform, the assistant calls
list_contact_import_sourcesfor how to export it, thenupload_contact_import_filewith the path of the export. The server reads the file itself, so the list never passes through the conversation, and your plan's contact limit sets how large it can be. It reads only CSV, TSV and ZIP files. The assistant shows you the result, and callsapply_contact_import_batchfor each batch once you agree. A large list finishes in the background, so the conversation can end while it applies. Rows the old platform marks as unsubscribed, bounced or complained become opt-outs. - Unsubscribed contacts are never mailed. No tool can resubscribe them. Only the person can, by confirming a new subscription request.
- Every tool that creates or sends takes an
idempotencyKey. The assistant reuses the same key when it retries a call whose outcome is unknown. send_broadcastreturnsidempotency_conflictfor a reused key with a different request, and also when an earlier call already sent or scheduled the broadcast under another key. The assistant then checks the broadcast withget_broadcastinstead of retrying with a new key.- Before
send_broadcast, the assistant previews the broadcast withpreview_broadcast, sends a test copy withsend_broadcast_test, and asks you to approve the send. create_broadcastandupdate_broadcastaccept asegmentthat narrows the audience by contact attributes. Read segments for the operators.create_broadcastandupdate_broadcastacceptlocalizedTemplates, a template per contact locale.upsert_contactandrequest_subscriptionset a contact'slocale, andpreview_broadcastandsend_broadcast_testaccept one. Read several languages for the order in which a template is chosen.- Tracking is off by default. Before
update_marketing_settingsturns on open or click tracking, the assistant asks you to confirm that you have the consent your recipients' laws require.get_broadcast_engagementreturns estimates, because privacy proxies and scanners open mail and follow links. Read open and click tracking. For tracking email sent from your app,update_tracking_settingsasks for the same confirmation, andsend_emailtakestrackingto turn it off for one email. create_broadcastandupdate_broadcastaccept anabTestwith two to four variants.get_broadcast_ab_testreports each variant's rates and the winner, andpick_broadcast_ab_test_winnerends the wait early or names the winner. The assistant asks you before it picks a winner, because the remainder starts sending at once. Read test variants.- Before
activate_automation, the assistant sends a test copy of each email step withsend_automation_testand asks you to approve the activation, because an active automation mails contacts without further review.pause_automationholds enrollments at their current step, andarchive_automationends them. Read automations. create_contact_eventstarts event-triggered automations for one contact. The assistant uses oneidempotencyKeyper real occurrence, so a retry enrolls nobody twice.export_audiencereturns the audience as CSV text.
get_metrics covers a window of at most 90 days and defaults to the last 7. Rates are the share of recipients accepted in the window that are currently delivered, bounced, or complained, so recent windows still include in-flight recipients.
API failures come back as tool errors with the API code, a readable message, and per-field fields, which lets the assistant correct its input and retry. When the API could not be reached, the error names the cause, such as ENOTFOUND, and a hint about what to check. The server itself retries reads, deletes and calls with an idempotencyKey up to twice after a rate limit, a 502, 503 or 504, a timeout, or a connection error.