Skip to main content

Python SDK for Nerve email MCP server

Project description

nerve-email

Python SDK for the Nerve email MCP server.

Install

pip install nerve-email

Quick start

from nerve_email import NerveClient

async with NerveClient(base_url="https://nerve.example.com", api_key="nerve_sk_...") as client:
    # Check server health
    if await client.health_check():
        threads = await client.list_threads(inbox_id="inbox_123")
        thread = await client.get_thread(thread_id="thread_456")
        results = await client.search_inbox(inbox_id="inbox_123", query="appointment")

    # Draft and send replies
    draft = await client.draft_reply(thread_id="thread_456", goal="Confirm the appointment")
    await client.send_reply(thread_id="thread_456", body_or_draft_id=draft["draft_id"])

    # Compose new email
    await client.compose_email(
        inbox_id="inbox_123",
        to="patient@example.com",
        subject="Appointment confirmation",
        body="Your appointment is confirmed for Monday at 10am.",
    )

Admin client

For domain and inbox management (control plane):

from nerve_email import NerveAdmin

async with NerveAdmin(base_url="https://nerve.example.com", api_key="admin_key") as admin:
    domain = await admin.add_domain(org_id="org_123", domain="clientclinic.com")
    dns = await admin.get_dns_records(org_id="org_123", domain_id=domain["domain"]["id"])
    await admin.verify_domain(org_id="org_123", domain_id=domain["domain"]["id"])

    inbox = await admin.create_inbox(
        org_id="org_123",
        address="support@clientclinic.com",
        domain_id=domain["domain"]["id"],
    )

Tool definitions

Framework-agnostic tool definitions for LLM function calling:

from nerve_email.tools import get_tool_definitions

# Claude/Anthropic format
tools = get_tool_definitions(format="claude", prefix="email_")

# OpenAI format
tools = get_tool_definitions(format="openai", prefix="email_")

Error handling

from nerve_email import NerveClient, NerveRateLimitError, NerveQuotaError

async with NerveClient(base_url=url, api_key=key) as client:
    try:
        threads = await client.list_threads(inbox_id="inbox_123")
    except NerveRateLimitError as e:
        print(f"Rate limited, retry after {e.retry_after}s")
    except NerveQuotaError:
        print("Quota exceeded")

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nerve_email-0.1.0.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nerve_email-0.1.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file nerve_email-0.1.0.tar.gz.

File metadata

  • Download URL: nerve_email-0.1.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for nerve_email-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7281b20fce4826a7f8c0eb5006b2bd06b85ca4d2025da380542e89282f818178
MD5 fe5c7c76a5a77c9164a80c8b3dfaa32d
BLAKE2b-256 2a39bd03c8c756181c4e79c48336faf2fd8d2d252ea3308bb38aa04c27ce85c8

See more details on using hashes here.

File details

Details for the file nerve_email-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nerve_email-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for nerve_email-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 670827784941f89c54249dbbc00a70d3ab7feeabca1fdba7919d296b55496707
MD5 8c40dbcffd3b79af3f35023393037e0d
BLAKE2b-256 7b70bcf46641e2437f0ba39525018dfa45d1d64487f11f6905f6fcf466f09da9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page