Skip to main content
Glama
Instantly MCP Server

Instantly MCP Server

by bcharleson

Instantly MCP Server (Python)

A lightweight, robust Model Context Protocol (MCP) server for the Instantly.ai V2 API, built with FastMCP.

Features

  • 38 tools across 6 categories (accounts, campaigns, leads, emails, analytics, background_jobs)

  • Dual transport support: HTTP (remote deployment) + stdio (local)

  • Lazy loading: Reduce context window by loading only specific tool categories

  • Multi-tenant support: Per-request API keys for HTTP deployments

  • Comprehensive error handling: Detailed, actionable error messages

  • Rate limiting: Automatic tracking from API response headers

  • Dynamic timeouts: Extended timeouts for search and bulk operations

Related MCP server: SmartLead MCP Server

Quick Start

Installation

# Clone or navigate to the repository
cd instantly-mcp-python

# Install with pip
pip install -e .

# Or install dependencies directly
pip install fastmcp httpx pydantic python-dotenv

Configuration

Set your Instantly API key:

export INSTANTLY_API_KEY="your-api-key-here"

Or create a .env file:

INSTANTLY_API_KEY=your-api-key-here

Running the Server

# Using FastMCP CLI
fastmcp run src/instantly_mcp/server.py --transport http --port 8000

# Using Python directly
python -m instantly_mcp.server --transport http --port 8000

# Or with uvicorn for production
uvicorn instantly_mcp.server:mcp.app --host 0.0.0.0 --port 8000

stdio Mode (Local Development)

# Using FastMCP CLI
fastmcp run src/instantly_mcp/server.py

# Using Python directly
python -m instantly_mcp.server

Tool Categories

Accounts (6 tools)

Tool

Description

list_accounts

List email accounts with filtering

get_account

Get account details and warmup status

create_account

Create account with IMAP/SMTP credentials

update_account

Update account settings

manage_account_state

Pause, resume, warmup control, test vitals

delete_account

⚠️ Permanently delete account

Campaigns (8 tools)

Tool

Description

create_campaign

Create email campaign (two-step process)

list_campaigns

List campaigns with pagination

get_campaign

Get campaign details and sequences

update_campaign

Update campaign settings

activate_campaign

Start campaign sending

pause_campaign

Stop campaign sending

delete_campaign

⚠️ Permanently delete campaign

search_campaigns_by_contact

Find campaigns a contact is enrolled in

Leads (12 tools)

Tool

Description

list_leads

List leads with filtering

get_lead

Get lead details

create_lead

Create single lead

update_lead

Update lead (⚠️ custom_variables replaces all)

list_lead_lists

List lead lists

create_lead_list

Create lead list

update_lead_list

Update lead list

get_verification_stats_for_lead_list

Get email verification stats

add_leads_to_campaign_or_list_bulk

Bulk add up to 1,000 leads

delete_lead

⚠️ Permanently delete lead

delete_lead_list

⚠️ Permanently delete lead list

move_leads_to_campaign_or_list

Move/copy leads between campaigns/lists

Emails (6 tools)

Tool

Description

list_emails

List emails with filtering

get_email

Get email details

reply_to_email

🚨 Send real email reply

count_unread_emails

Count unread inbox emails

verify_email

Verify email deliverability

mark_thread_as_read

Mark email thread as read

Analytics (3 tools)

Tool

Description

get_campaign_analytics

Campaign metrics (opens, clicks, replies)

get_daily_campaign_analytics

Day-by-day performance

get_warmup_analytics

Account warmup metrics

Background Jobs (2 tools)

Tool

Description

list_background_jobs

List async background jobs with pagination

get_background_job

Get details of a specific background job

Lazy Loading (Context Window Optimization)

Reduce context window usage by loading only the categories you need:

# Load only accounts and campaigns (14 tools instead of 38)
export TOOL_CATEGORIES="accounts,campaigns"

# Load only leads and analytics
export TOOL_CATEGORIES="leads,analytics"

Valid categories: accounts, campaigns, leads, emails, analytics, background_jobs

Authentication Methods

The server supports multiple authentication methods for flexibility:

1. URL-based Authentication

Include your API key directly in the URL path:

https://your-server.com/mcp/YOUR_API_KEY

2. Header Authentication

URL: https://your-server.com/mcp
Header: Authorization: YOUR_API_KEY

Note: Bearer token prefix is optional

3. Custom Header

URL: https://your-server.com/mcp
Header: x-instantly-api-key: YOUR_API_KEY

4. Environment Variable

export INSTANTLY_API_KEY="your-api-key-here"

MCP Client Configuration

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

stdio Mode (Local)

{
  "mcpServers": {
    "instantly": {
      "command": "python",
      "args": ["-m", "instantly_mcp.server"],
      "env": {
        "INSTANTLY_API_KEY": "your-api-key-here"
      }
    }
  }
}
{
  "mcpServers": {
    "instantly": {
      "url": "https://your-server.com/mcp/YOUR_API_KEY"
    }
  }
}

HTTP Mode with Header Auth

{
  "mcpServers": {
    "instantly": {
      "url": "https://your-server.com/mcp",
      "transport": "streamable-http",
      "headers": {
        "Authorization": "your-api-key-here"
      }
    }
  }
}

Cursor IDE

Add to ~/.cursor/mcp.json:

With URL Authentication

{
  "mcpServers": {
    "instantly": {
      "url": "https://your-server.com/mcp/YOUR_API_KEY"
    }
  }
}

With Header Authentication

{
  "mcpServers": {
    "instantly": {
      "url": "https://your-server.com/mcp",
      "transport": "streamable-http",
      "headers": {
        "x-instantly-api-key": "your-api-key-here"
      }
    }
  }
}

DigitalOcean App Platform Deployment

App Spec

name: instantly-mcp
services:
  - name: instantly-mcp
    source:
      git:
        branch: main
        repo_clone_url: https://github.com/your-username/instantly-mcp-python.git
    build_command: pip install -e .
    run_command: python -m instantly_mcp.server --transport http --port 8080
    http_port: 8080
    instance_size_slug: basic-xxs
    instance_count: 1
    envs:
      - key: INSTANTLY_API_KEY
        scope: RUN_TIME
        type: SECRET
      - key: PORT
        scope: RUN_TIME
        value: "8080"

Dockerfile (Alternative)

FROM python:3.11-slim

WORKDIR /app

COPY pyproject.toml .
COPY src/ src/

RUN pip install -e .

EXPOSE 8000

CMD ["python", "-m", "instantly_mcp.server", "--transport", "http", "--host", "0.0.0.0", "--port", "8000"]

Multi-Tenant HTTP Mode

For deployments serving multiple users, the server supports per-request API keys:

# Start server without default API key
python -m instantly_mcp.server --transport http --port 8000

# Clients provide API key via header
curl -X POST http://localhost:8000/mcp \
  -H "x-instantly-api-key: user-specific-api-key" \
  -H "Content-Type: application/json" \
  -d '{"method": "tools/list"}'

Error Handling

The server provides detailed, actionable error messages:

{
  "error": {
    "code": "invalid_api_key",
    "message": "Instantly API key is required. Provide via:\n  - INSTANTLY_API_KEY environment variable\n  - api_key parameter\n  - x-instantly-api-key header (HTTP mode)"
  }
}

Rate Limiting

The server automatically tracks rate limits from API response headers:

# Access via get_server_info tool
{
  "rate_limit": {
    "remaining": 95,
    "limit": 100,
    "reset_at": "2024-01-15T12:00:00"
  }
}

Project Structure

instantly-mcp-python/
├── src/
│   └── instantly_mcp/
│       ├── __init__.py          # Package exports
│       ├── server.py            # FastMCP server (~180 lines)
│       ├── client.py            # API client (~200 lines)
│       ├── models/              # Pydantic models
│       │   ├── __init__.py
│       │   ├── common.py        # Pagination
│       │   ├── accounts.py      # Account models
│       │   ├── campaigns.py     # Campaign models
│       │   ├── leads.py         # Lead models
│       │   ├── emails.py        # Email models
│       │   └── analytics.py     # Analytics models
│       └── tools/               # Tool implementations
│           ├── __init__.py      # Lazy loading logic
│           ├── accounts.py      # 6 account tools
│           ├── campaigns.py     # 8 campaign tools
│           ├── leads.py         # 12 lead tools
│           ├── emails.py        # 6 email tools
│           ├── analytics.py     # 3 analytics tools
│           └── background_jobs.py # 2 background job tools
├── pyproject.toml               # Dependencies
├── env.example                  # Environment template
└── README.md                    # This file

Comparison with TypeScript Version

Aspect

TypeScript

Python FastMCP

Lines of Code

~5,000+

~1,500

Tool Registration

Manual handlers

@mcp.tool decorator

Input Validation

Zod schemas

Pydantic (auto)

Error Messages

Manual

Auto from Pydantic

HTTP Server

Custom transport

Built-in

Context Window

Larger schemas

Smaller, cleaner

API Reference

For detailed API documentation, see: Instantly V2 API Docs

License

MIT License

Contributing

Contributions welcome! Please open an issue or PR.

Available Tools

27 tools
activate_campaignA

Activate campaign to start sending.

Prerequisites (all required):

  1. At least one sender account assigned (email_list)

  2. At least one lead added to the campaign

  3. Email sequences configured

  4. Schedule configured

Use get_campaign to verify all prerequisites are met.

Inputs: params (required). Returns: result

add_leads_to_campaign_or_list_bulkA

Bulk add up to 1,000 leads. 10-100x faster than create_lead.

Provide EITHER campaign_id OR list_id (not both).

Each lead requires at minimum an email address. Custom variables must match campaign field definitions.

Use skip_if_in_campaign=true to prevent duplicates (recommended).

Inputs: params (required). Returns: result

create_accountA

Create email account with IMAP/SMTP credentials.

Provider codes:

  • 1: IMAP (generic)

  • 2: Google Workspace

  • 3: Microsoft 365

  • 4: AWS SES

Requires valid IMAP and SMTP credentials for email sending.

Inputs: params (required). Returns: result

create_campaignA

Create email campaign. Two-step process:

Step 1: Call with name/subject/body to discover available sender accounts Step 2: Call again with email_list to assign senders

Personalization variables:

  • {{firstName}}, {{lastName}}, {{companyName}}

  • {{email}}, {{website}}, {{phone}}

  • Any custom variables defined for leads

Use sequence_steps for multi-step follow-up sequences.

IMPORTANT API v2 Structure:

  • Each step must have type="email"

  • Subject/body wrapped in variants array: variants=[{subject, body}]

  • Delay is in DAYS (not minutes)

  • Body should be HTML formatted

Inputs: params (required). Returns: result

create_leadA

Create a single lead with custom variables.

Use skip_if_in_campaign=true to prevent duplicates (recommended).

Custom variables must match field names defined in the campaign. Example: {"industry": "Technology", "company_size": "50-100"}

For bulk imports (10+ leads), use add_leads_to_campaign_or_list_bulk instead.

Inputs: params (required). Returns: result

create_lead_listB

Create a lead list.

Set has_enrichment_task=true to enable automatic lead enrichment. Enrichment adds company info, social profiles, and other data.

Inputs: params (required). Returns: result

delete_accountA
Destructive

🚨 PERMANENTLY delete an email account. CANNOT UNDO!

This action:

  • Removes the account from all campaigns

  • Deletes all account data

  • Cannot be reversed

Confirm with user before executing!

Inputs: params (required). Returns: result

delete_campaignA
Destructive

🚨 PERMANENTLY delete a campaign. CANNOT UNDO!

⚠️ REQUIRES USER CONFIRMATION before executing!

This action:

  • Permanently removes the campaign

  • Deletes all campaign data, sequences, and settings

  • Removes leads from this campaign (leads themselves are NOT deleted)

  • Cannot be reversed

Before calling this tool, you MUST:

  1. Confirm with the user that they want to delete this campaign

  2. Verify the campaign_id is correct

  3. Warn them this action cannot be undone

Inputs: params (required). Returns: result

delete_leadA
Destructive

🗑️ PERMANENTLY delete a lead. CANNOT UNDO!

This action:

  • Removes the lead from all campaigns and lists

  • Deletes all lead data and history

  • Cannot be reversed

Confirm with user before executing!

Inputs: params (required). Returns: result

delete_lead_listA
Destructive

🚨 PERMANENTLY delete a lead list. CANNOT UNDO!

⚠️ REQUIRES USER CONFIRMATION before executing!

This action:

  • Permanently removes the lead list

  • Leads in the list may be orphaned (check your workflow)

  • Cannot be reversed

Before calling this tool, you MUST:

  1. Confirm with the user that they want to delete this list

  2. Verify the list_id is correct

  3. Warn them this action cannot be undone

Inputs: params (required). Returns: result

get_accountA
Read-only

Get account details, warmup status, and campaign eligibility by email.

Returns comprehensive account information including:

  • Connection status and provider info

  • Warmup configuration and progress

  • Daily limits and sending gaps

  • Tracking domain settings

Inputs: params (required). Returns: result

get_campaignA
Read-only

Get campaign details: config, sequences, schedules, sender accounts, tracking, status.

Returns comprehensive campaign information including:

  • Email sequences and their content

  • Schedule configuration

  • Sender account assignments

  • Tracking settings (opens, clicks)

  • Campaign status and statistics

Inputs: params (required). Returns: result

get_leadB
Read-only

Get lead details by ID.

Returns comprehensive lead information including:

  • Contact details (email, name, company, phone)

  • Custom variables

  • Campaign/list membership

  • Sequence status and history

  • Interest status

Inputs: params (required). Returns: result

get_server_infoA
Read-only

Get Instantly MCP server information.

Returns server version, loaded categories, and configuration status. Useful for debugging and verifying server setup.

Inputs: no named parameters. Returns: result

get_verification_stats_for_lead_listB
Read-only

Get email verification statistics for a lead list.

Returns breakdown of verification results:

  • Valid emails

  • Invalid/bounced emails

  • Risky emails

  • Unknown status

Inputs: params (required). Returns: result

list_accountsA
Read-only

List email accounts with cursor-based pagination (100 per page).

PAGINATION: If response contains pagination.next_starting_after, there are MORE results. Call again with starting_after= to get next page. Continue until pagination.next_starting_after is null.

Status codes: 1=Active, 2=Paused, -1/-2/-3=Errors Provider codes: 1=IMAP, 2=Google, 3=Microsoft, 4=AWS

Returns accounts with warmup status and campaign eligibility.

Inputs: params. Returns: result

list_campaignsA
Read-only

List campaigns with cursor-based pagination (100 per page).

PAGINATION: If response contains pagination.next_starting_after, there are MORE results. Call again with starting_after= to get next page. Continue until pagination.next_starting_after is null.

Note: search filters by campaign NAME only, not by status. To filter by status, use campaign_status in get_daily_campaign_analytics.

Returns campaign list with status, lead counts, and performance metrics.

Inputs: params. Returns: result

list_lead_listsA
Read-only

List lead lists with cursor-based pagination (100 per page).

PAGINATION: If response contains pagination.next_starting_after, there are MORE results. Call again with starting_after= to get next page. Continue until pagination.next_starting_after is null.

Lead lists are containers for organizing leads outside of campaigns. Use has_enrichment_task filter to find lists with auto-enrichment enabled.

Inputs: params. Returns: result

list_leadsA
Read-only

List leads with cursor-based pagination (100 per page).

PAGINATION: If response contains pagination.next_starting_after, there are MORE results. Call again with starting_after= to get next page. Continue until pagination.next_starting_after is null.

Filter values:

  • FILTER_VAL_CONTACTED: Leads that have been contacted

  • FILTER_VAL_NOT_CONTACTED: Leads not yet contacted

  • FILTER_VAL_COMPLETED: Leads that completed sequence

  • FILTER_VAL_ACTIVE: Currently active leads

Use distinct_contacts=true to deduplicate by email.

Inputs: params. Returns: result

manage_account_stateA

Manage account state: pause, resume, enable/disable warmup, or test vitals.

Actions:

  • pause: Stop all sending from this account

  • resume: Re-enable sending

  • enable_warmup: Start warmup process

  • disable_warmup: Stop warmup process

  • test_vitals: Test IMAP/SMTP connectivity

Use test_vitals to diagnose connection issues.

Inputs: params (required). Returns: result

move_leads_to_campaign_or_listA

Move or copy leads between campaigns/lists.

Runs as background job for large operations.

Source selection (use one):

  • ids: Specific lead IDs to move

  • search + campaign/list_id: Filter leads by search term

  • filter + campaign/list_id: Filter by status

Destination (use one):

  • to_campaign_id: Target campaign

  • to_list_id: Target list

Set copy_leads=true to copy instead of move.

Inputs: params (required). Returns: result

pause_campaignA

Pause campaign to stop sending.

Effects:

  • Immediately stops all email sending

  • Leads remain in the campaign

  • In-progress sequences are paused

Use activate_campaign to resume sending.

Inputs: params (required). Returns: result

search_campaigns_by_contactA
Read-only

Find all campaigns that a specific contact/lead is part of.

Useful for:

  • Checking if a lead is already in any campaigns

  • Finding duplicate enrollments

  • Auditing lead campaign membership

Returns list of campaigns the contact email is enrolled in.

Inputs: params (required). Returns: result

update_accountA

Update account settings (partial update).

Common updates:

  • first_name, last_name: Display name

  • warmup: Warmup configuration (limit, advanced settings)

  • daily_limit: Max emails per day (1-100)

  • sending_gap: Minutes between emails (0-1440)

  • tracking_domain_name: Custom tracking domain

Only include fields you want to update.

Inputs: params (required). Returns: result

update_campaignA

Update campaign settings (partial update).

Common updates:

  • name: Campaign display name

  • sequences: Email sequence steps

  • email_list: Sender account assignments

  • daily_limit: Max emails per day per account

  • email_gap: Minutes between sends

  • open_tracking, link_tracking: Tracking toggles

Only include fields you want to update.

Inputs: params (required). Returns: result

update_leadA

Update lead (partial update).

⚠️ IMPORTANT: custom_variables REPLACES the entire object! To preserve existing custom variables:

  1. First call get_lead to retrieve current values

  2. Merge your changes with existing values

  3. Pass the complete merged object

Example: If lead has {"industry": "Tech"} and you want to add {"size": "Large"}, you must pass {"industry": "Tech", "size": "Large"} - not just {"size": "Large"}

Inputs: params (required). Returns: result

update_lead_listB

Update lead list name, enrichment settings, or owner.

Inputs: params (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 27 tools

    Disambiguation4/5

    Most tools have distinct purposes targeting specific resources (campaigns, leads, accounts, lists) and actions (create, get, update, delete, list, manage). However, some overlap exists: 'add_leads_to_campaign_or_list_bulk' and 'move_leads_to_campaign_or_list' both handle lead transfers, and 'pause_campaign' vs 'manage_account_state' with pause/resume actions could cause minor confusion, but descriptions clarify their scopes.

    Naming Consistency5/5

    Tool names follow a highly consistent verb_noun pattern throughout, such as 'activate_campaign', 'create_account', 'get_campaign', 'list_leads', 'update_lead', and 'delete_lead_list'. All tools use snake_case uniformly, with verbs like create, get, list, update, delete, pause, search, and manage applied predictably across resources.

    Tool Count3/5

    With 27 tools, the count is borderline high for an email marketing server, potentially overwhelming. While it covers comprehensive operations for campaigns, leads, accounts, and lists, some tools like 'get_server_info' and 'search_campaigns_by_contact' might be consolidated or deemed non-essential, making the set feel slightly heavy but still manageable within the domain scope.

    Completeness5/5

    The tool set provides complete CRUD/lifecycle coverage for the email marketing domain: full create, read, update, delete, and list operations for campaigns, leads, accounts, and lead lists, plus specialized actions like activation, pausing, bulk operations, and analytics. No obvious gaps exist; agents can handle end-to-end workflows from setup to management and analysis without dead ends.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables cold email marketing automation with campaign management, lead tracking, deliverability optimization, and analytics, integrating with 113 tools via zero-config NPX installation.
      1,089 npm
      7
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to interact with the Instantly.ai v2 API to manage campaigns, leads, accounts, replies, blocklist, and webhooks, with tools organized into read, write, and dangerous safety tiers.
      3 npm
      MIT
    • A
      license
      A
      quality
      A
      maintenance
      Enables MCP clients to read Instantly.ai analytics and manage leads, campaigns, Unibox, sender accounts, blocklist, and webhooks, with write actions gated behind confirm prompts and configurable safety policies.
      40
      88 PyPI
      MIT