Labsco
bcharleson logo

Instantly

β˜… 24

from bcharleson

Manage email campaigns and leads using the Instantly.ai v2 API.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedAccount requiredNeeds API keys

Instantly MCP Server (Python)

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

<!-- mcp-name: io.github.instantly-ai/instantly-mcp -->

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

Tool Categories

Accounts (6 tools)

ToolDescription
list_accountsList email accounts with filtering
get_accountGet account details and warmup status
create_accountCreate account with IMAP/SMTP credentials
update_accountUpdate account settings
manage_account_statePause, resume, warmup control, test vitals
delete_account⚠️ Permanently delete account

Campaigns (8 tools)

ToolDescription
create_campaignCreate email campaign (two-step process)
list_campaignsList campaigns with pagination
get_campaignGet campaign details and sequences
update_campaignUpdate campaign settings
activate_campaignStart campaign sending
pause_campaignStop campaign sending
delete_campaign⚠️ Permanently delete campaign
search_campaigns_by_contactFind campaigns a contact is enrolled in

Leads (12 tools)

ToolDescription
list_leadsList leads with filtering
get_leadGet lead details
create_leadCreate single lead
update_leadUpdate lead (⚠️ custom_variables replaces all)
list_lead_listsList lead lists
create_lead_listCreate lead list
update_lead_listUpdate lead list
get_verification_stats_for_lead_listGet email verification stats
add_leads_to_campaign_or_list_bulkBulk add up to 1,000 leads
delete_lead⚠️ Permanently delete lead
delete_lead_list⚠️ Permanently delete lead list
move_leads_to_campaign_or_listMove/copy leads between campaigns/lists

Emails (6 tools)

ToolDescription
list_emailsList emails with filtering
get_emailGet email details
reply_to_email🚨 Send real email reply
count_unread_emailsCount unread inbox emails
verify_emailVerify email deliverability
mark_thread_as_readMark email thread as read

Analytics (3 tools)

ToolDescription
get_campaign_analyticsCampaign metrics (opens, clicks, replies)
get_daily_campaign_analyticsDay-by-day performance
get_warmup_analyticsAccount warmup metrics

Background Jobs (2 tools)

ToolDescription
list_background_jobsList async background jobs with pagination
get_background_jobGet details of a specific background job

Lazy Loading (Context Window Optimization)

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

Copy & paste β€” that's it
# 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:

Copy & paste β€” that's it
https://your-server.com/mcp/YOUR_API_KEY

2. Header Authentication

Copy & paste β€” that's it
URL: https://your-server.com/mcp
Header: Authorization: YOUR_API_KEY

Note: Bearer token prefix is optional

3. Custom Header

Copy & paste β€” that's it
URL: https://your-server.com/mcp
Header: x-instantly-api-key: YOUR_API_KEY

4. Environment Variable

Copy & paste β€” that's it
export INSTANTLY_API_KEY="your-api-key-here"

Multi-Tenant HTTP Mode

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

Copy & paste β€” that's it
# 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:

Copy & paste β€” that's it
{
  "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:

Copy & paste β€” that's it
# Access via get_server_info tool
{
  "rate_limit": {
    "remaining": 95,
    "limit": 100,
    "reset_at": "2024-01-15T12:00:00"
  }
}

Project Structure

Copy & paste β€” that's it
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

AspectTypeScriptPython FastMCP
Lines of Code~5,000+~1,500
Tool RegistrationManual handlers@mcp.tool decorator
Input ValidationZod schemasPydantic (auto)
Error MessagesManualAuto from Pydantic
HTTP ServerCustom transportBuilt-in
Context WindowLarger schemasSmaller, cleaner

API Reference

For detailed API documentation, see: Instantly V2 API Docs

License

MIT License

Contributing

Contributions welcome! Please open an issue or PR.