relay-commerce/Klaviyo-MCP-Server
If you are the rightful owner of Klaviyo-MCP-Server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Klaviyo MCP Server is a comprehensive Model Context Protocol server that provides full access to Klaviyo's API functionality, enabling AI assistants to interact with Klaviyo's APIs through a variety of tools.
Klaviyo MCP Server
A comprehensive Model Context Protocol (MCP) server that provides complete access to Klaviyo's API functionality. This server enables AI assistants like Claude to interact with all major Klaviyo APIs through 34+ tools covering profiles, campaigns, flows, lists, segments, events, and more.
๐ Features
Complete API Coverage
- Profiles API (4 tools) - Create, read, update, search customer profiles
- Lists API (4 tools) - Manage lists and list memberships
- Campaigns API (4 tools) - Create, manage, and send email campaigns
- Segments API (3 tools) - Create and query dynamic customer segments
- Events API (3 tools) - Track and retrieve customer events
- Flows API (3 tools) - Manage automated email flows
- Metrics API (2 tools) - Access performance metrics
- Templates API (2 tools) - Manage email templates
- Catalogs API (3 tools) - Manage product catalogs and variants
- Coupons API (2 tools) - Create and manage discount coupons
- Reporting API (2 tools) - Query campaign and flow analytics
- Accounts API (2 tools) - Access account information
Key Features
- โ 34 tools covering all major Klaviyo API endpoints
- โ Secure authentication using Klaviyo private API keys
- โ Comprehensive error handling for network, HTTP, and API errors
- โ Rate limiting protection with timeout and retry logic
- โ Input validation for all parameters and JSON data
- โ Consistent interface - all tools follow the same patterns
- โ JSON:API format support with filtering, pagination, and sorting
- โ Complete documentation with usage examples
๐ Prerequisites
- Python 3.10 or higher
- Klaviyo account with API access
- Klaviyo Private API Key (Get yours here)
๐ ๏ธ Installation
Quick Setup
-
Clone the repository:
git clone https://github.com/relay-commerce/Klaviyo-MCP-Server.git cd Klaviyo-MCP-Server
-
Run the setup script:
chmod +x klaviyo_setup.sh ./klaviyo_setup.sh
-
Get your Klaviyo API key:
- Go to Klaviyo API Keys
- Create a new private API key with appropriate scopes
Manual Setup
-
Create virtual environment:
python3 -m venv klaviyo_mcp_env source klaviyo_mcp_env/bin/activate
-
Install dependencies:
pip install -r klaviyo_requirements.txt
๐งช Testing
Test the server to ensure everything is working:
source klaviyo_mcp_env/bin/activate
python test_klaviyo_server.py
You should see output confirming all 34 tools are available:
โ
SUCCESS: All expected tools are available!
Test completed. Total tools available: 34
๐ง Usage
With Claude Desktop
Add the server to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"klaviyo": {
"command": "python",
"args": ["/absolute/path/to/klaviyo_mcp_server.py"]
}
}
}
With MCP CLI
# List available tools
mcp-cli tool list --server klaviyo
# Call a specific tool
mcp-cli tool call get_profiles --server klaviyo --input '{"api_key": "your-api-key"}'
๐ API Examples
Create a Customer Profile
create_profile(
api_key="your-api-key",
profile_data='{"email": "customer@example.com", "first_name": "John", "last_name": "Doe"}'
)
Get All Campaigns
get_campaigns(
api_key="your-api-key",
filter_expr="equals(status,'draft')",
page_size=50
)
Track a Custom Event
create_event(
api_key="your-api-key",
event_data='{"metric": {"name": "Placed Order"}, "profile": {"email": "customer@example.com"}, "properties": {"value": 99.99, "item_count": 2}}'
)
Create a Customer Segment
create_segment(
api_key="your-api-key",
segment_data='{"name": "High Value Customers", "definition": {"condition_groups": [{"conditions": [{"field": "properties.total_spent", "operator": "greater-than", "value": 1000}]}]}}'
)
Send a Campaign
send_campaign(
api_key="your-api-key",
campaign_id="campaign-id-here"
)
๐ Authentication
The server uses Klaviyo Private API Keys for authentication. Each tool requires an api_key
parameter:
- Never hardcode API keys in your code
- Pass API keys as parameters to each tool call
- Ensure your API key has the necessary scopes for the operations you want to perform
Required API Scopes
Make sure your Klaviyo API key has these scopes:
profiles:read
,profiles:write
lists:read
,lists:write
campaigns:read
,campaigns:write
segments:read
,segments:write
events:read
,events:write
flows:read
,flows:write
metrics:read
templates:read
,templates:write
catalogs:read
,catalogs:write
coupons:read
,coupons:write
๐ Available Tools
Profiles API (4 tools)
get_profiles()
- List all profiles with filtering, pagination, and sortingcreate_profile()
- Create new customer profilesget_profile()
- Get specific profile by IDupdate_profile()
- Update existing profile data
Lists API (4 tools)
get_lists()
- List all lists in accountcreate_list()
- Create new listsget_list_profiles()
- Get profiles in a specific listadd_profiles_to_list()
- Add profiles to lists
Campaigns API (4 tools)
get_campaigns()
- List all campaignscreate_campaign()
- Create new email campaignsget_campaign()
- Get specific campaign detailssend_campaign()
- Send campaigns immediately
Segments API (3 tools)
get_segments()
- List all segmentscreate_segment()
- Create new dynamic segmentsget_segment_profiles()
- Get profiles in segments
Events API (3 tools)
get_events()
- List events with filtering and sortingcreate_event()
- Track new customer eventsget_event()
- Get specific event details
Flows API (3 tools)
get_flows()
- List all automated flowsget_flow()
- Get specific flow detailsupdate_flow_status()
- Update flow status (draft/live/stopped/archived)
Other APIs
Metrics API (2 tools)
get_metrics()
- List all available metricsget_metric()
- Get specific metric details
Templates API (2 tools)
get_templates()
- List all email templatescreate_template()
- Create new email templates
Catalogs API (3 tools)
get_catalog_items()
- List catalog itemscreate_catalog_item()
- Create new catalog itemsget_catalog_variants()
- List catalog variants
Coupons API (2 tools)
get_coupons()
- List all couponscreate_coupon()
- Create new coupons
Reporting API (2 tools)
query_campaign_values()
- Get campaign performance metricsquery_flow_values()
- Get flow performance metrics
Accounts API (2 tools)
get_accounts()
- Get account informationget_account()
- Get specific account details
โก Rate Limits
Klaviyo has the following rate limits:
- Burst: 75 requests per second
- Steady: 700 requests per minute
The server includes built-in protection with timeout handling and proper error messages for rate limit scenarios.
๐ก๏ธ Security
- โ API keys are passed as parameters (never hardcoded)
- โ All requests use HTTPS
- โ Proper error handling prevents sensitive data exposure
- โ Input validation for all parameters
- โ No secrets stored in code or logs
๐ง Technical Details
- API Base URL:
https://a.klaviyo.com/api
- API Revision:
2025-04-15
- Protocol: JSON:API format
- Authentication: Klaviyo-API-Key header
- Python Version: 3.10+
- MCP Version: 1.0.0+
๐ File Structure
Klaviyo-MCP-Server/
โโโ klaviyo_mcp_server.py # Main MCP server implementation
โโโ klaviyo_requirements.txt # Python dependencies
โโโ klaviyo_setup.sh # Setup script
โโโ klaviyo_documentation.md # Detailed documentation
โโโ test_klaviyo_server.py # Test script
โโโ README.md # This file
๐ค Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the file for details.
๐ Support
- Issues: GitHub Issues
- Klaviyo API Docs: Klaviyo Developer Portal
- MCP Documentation: Model Context Protocol
๐ Why This MCP Server?
This is the most comprehensive Klaviyo MCP integration available, providing:
- โ Complete API coverage - All major Klaviyo endpoints
- โ Production ready - Proper error handling and security
- โ Easy to use - Consistent interface across all tools
- โ Well documented - Clear examples and setup instructions
- โ Actively maintained - Regular updates and improvements
Perfect for businesses wanting to integrate Klaviyo functionality into AI-powered workflows, customer service automation, marketing automation, and data analysis tasks.
Made with โค๏ธ for the Klaviyo and MCP communities