Keap MCP Server
A high-performance Model Context Protocol (MCP) server for interacting with Keap CRM data with advanced features including HTTP/2 support, comprehensive diagnostics, and bulk operations.
Features
Core Contact & Tag Management
- Comprehensive Contact Management - List, search, filter, and get detailed contact information
- Advanced Tag Operations - Full tag lifecycle management including creation, querying, and batch operations
- Batch Tag Operations - Apply or remove multiple tags from multiple contacts efficiently
- Custom Field Operations - Search contacts by custom field values and bulk update custom fields
- Complex Logical Filtering - Support for AND, OR, NOT operators with nested conditions
Performance & Optimization
- HTTP/2 Support - Enhanced connection performance with connection pooling
- Intelligent Rate Limiting - Daily request limits with adaptive backoff strategies
- Query Optimization - Intelligent server-side vs client-side filtering with performance analytics
- Performance Monitoring - Real-time query analysis and optimization suggestions
- Persistent Caching - SQLite-based caching to reduce API calls and improve performance
Advanced Features
- Comprehensive Diagnostics - API performance metrics, system monitoring, and health checks
- Enhanced Error Handling - Robust retry logic with exponential backoff for different error types
- Bulk Custom Field Updates - Efficiently set custom field values across multiple contacts
- Advanced Filter Operators - 15+ operators including BETWEEN, IN, SINCE, STARTS_WITH, etc.
- ID List Operations - Utility functions for working with contact and tag ID sets
Architecture
The Keap MCP Server uses a streamlined, high-performance architecture:
- API Client (
src/api/client.py
) - Enhanced Keap API communication with HTTP/2, rate limiting, and diagnostics - MCP Tools (
src/mcp/
) - Comprehensive MCP protocol implementation with optimization - Cache Manager (
src/cache/
) - SQLite-based persistent caching with intelligent invalidation - Optimization Engine (
src/mcp/optimization/
) - Query optimization and performance analytics - Schemas (
src/schemas/
) - Data validation and models - Utils (
src/utils/
) - Shared utilities for contact processing and filtering
MCP Tools
The server exposes 17 comprehensive MCP tools:
Contact Operations
list_contacts
- List contacts with filtering and pagination (now optimized)search_contacts_by_email
- Find contacts by email addresssearch_contacts_by_name
- Find contacts by nameget_contact_details
- Get detailed information about a specific contactquery_contacts_by_custom_field
- Query contacts by custom field value
Tag Operations
get_tags
- Retrieve tags with optional filteringget_tag_details
- Get detailed information about a specific tagget_contacts_with_tag
- Get contacts that have a specific tagcreate_tag
- Create a new tag
Tag Management (Batch Operations)
modify_tags
- Add or remove tags from contactsapply_tags_to_contacts
- Apply multiple tags to multiple contacts using batch operationsremove_tags_from_contacts
- Remove multiple tags from multiple contacts
Custom Field Management
set_custom_field_values
- Bulk update custom field values across multiple contacts
Advanced Query & Performance Operations
query_contacts_optimized
- Advanced contact query with optimization and performance analyticsanalyze_query_performance
- Analyze query performance and optimization potential
System Operations
get_api_diagnostics
- Comprehensive API diagnostics and performance metrics
Utility Operations
intersect_id_lists
- Find the intersection of multiple ID lists
Getting Started
Prerequisites
- Python 3.9 or higher
- Keap API credentials
Installation
- Clone the repository:
- Install dependencies:
- Configure your Keap API credentials:
- The application uses a
.env
file for configuration - The API key has been copied from keapsync, but you can modify it if needed
- The configuration includes:
- The application uses a
Running the Server
Command-line options:
--host
- Host to bind to (default: 127.0.0.1)--port
- Port to listen on (default: 5000)--log-level
- Logging level (default: INFO)--log-file
- Log file path (default: keap_mcp_server.log)--no-console-log
- Disable console logging
Testing & Coverage
The Keap MCP Server includes a comprehensive test suite to ensure reliability and correct operation with full CI/CD pipeline integration.
Quick Testing
Use the Makefile for easy test execution:
CI/CD Integration
The project includes comprehensive automated testing and quality assurance:
- Continuous Integration: Tests run on Python 3.9, 3.10, and 3.11
- Coverage Tracking: Minimum 70% unit test coverage enforced
- Code Quality: Ruff linting and formatting checks
- Security Scanning: Bandit security analysis and Safety dependency checks
- Type Checking: MyPy static type analysis (non-blocking)
- Pre-commit Hooks: Automated code quality checks on commit
- Build Verification: Import and initialization testing
CI Pipeline Jobs
- Lint Code: Ruff linting and formatting validation
- Unit Tests: Full test suite with coverage reporting across Python versions
- Security Scan: Bandit and Safety security analysis
- Type Check: MyPy static type checking
- Build Test: Package import and server initialization verification
- Coverage Report: HTML coverage reports for pull requests
Test Categories
- Unit Tests (
tests/unit/
) - Individual component testing with comprehensive mocking - Integration Tests (
tests/integration/
) - End-to-end functionality verification - Performance Tests (
tests/performance/
) - Load and optimization validation - API Validation - Keap API response format verification
Coverage Requirements
- Current Coverage: 55% integration coverage, varies by component
- API Client: Core functionality tested with comprehensive mocking
- MCP Tools: Integration tests with mock dependencies
- Cache System: Comprehensive persistence and performance testing
- Utilities: Contact processing and filtering functionality tested
- Optimization: Performance analytics and query optimization covered
Running Specific Tests
Using the MCP Server
Example: List Contacts (Now Optimized)
Note: list_contacts
now uses the optimization engine internally for better performance. For detailed performance metrics, use query_contacts_optimized
directly.
Example: Search by Email
Example: Get Tags
Example: Batch Tag Operations
Example: Custom Field Query
Example: Create New Tag
Example: Bulk Custom Field Updates
Or with individual values per contact:
Example: API Diagnostics
Example: ID List Intersection
Performance Features
HTTP/2 Support
The server uses HTTP/2 for enhanced performance with connection pooling and keepalive connections.
Rate Limiting
- Daily request limits (25,000 requests/day by default)
- Intelligent backoff strategies
- Rate limit monitoring and diagnostics
Caching Strategy
- SQLite-based persistent caching
- Intelligent cache invalidation
- TTL-based expiration
- Cache hit/miss tracking
Error Handling
- Exponential backoff for retries
- Different strategies for timeout, network, and HTTP errors
- Comprehensive error tracking and diagnostics
License
This project is licensed under the MIT License - see the LICENSE file for details.
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
A secure MCP wrapper for Anthropic Claude Code that eliminates the need for permission flags while preserving full CLI functionality and working seamlessly with MCP-compatible IDEs.
Related MCP Servers
- AsecurityAlicenseAqualityThis project aims to build a Claude Code MCP server and implement its associated tools (explain\_code, review\_code, fix\_code, edit\_code, test\_code, simulate\_command, your\_own\_query). The server is implemented using Node.js and the MCP SDK. It receives tool requests from clients via Stdio, dynamicallyLast updated -710521JavaScriptMIT License
- -securityAlicense-qualityAn MCP server that implements Claude Code-like functionality, allowing the AI to analyze codebases, modify files, execute commands, and manage projects through direct file system interactions.Last updated -179PythonMIT License
- -securityFlicense-qualityAn MCP tool that synchronizes user preferences, personal details, and code standards across multiple Claude interfaces, allowing users to maintain consistent personalized AI interactions without repeating themselves.Last updated -2TypeScript
- -securityAlicense-qualityA tool that helps easily register Anthropic's Model Context Protocol (MCP) in Claude Desktop and Cursor, providing RAG functionality, Dify integration, and web search capabilities.Last updated -36PythonMIT License