A Model Context Protocol (MCP) server for Countly Analytics Platform. This server enables AI assistants and MCP clients to interact with Countly's analytics data, manage applications, view dashboards, track events, and perform comprehensive analytics operations.
Countly is an open-source, enterprise-grade product analytics platform. It helps track user behavior, monitor application performance, and gain insights into user engagement. This MCP server provides programmatic access to all major Countly features through a standard protocol interface.
The Model Context Protocol (MCP) is an open protocol that enables seamless integration between AI applications and external data sources. This server implements MCP to allow AI assistants like Claude to interact with your Countly analytics data naturally through conversation.
- Node.js 18+ (for local installation) OR Docker (recommended)
- Countly Server: Access to a Countly instance (cloud or self-hosted)
- Auth Token: Valid Countly authentication token with appropriate permissions
- MCP Protocol Version:
2025-03-26(Streamable HTTP specification) - Compatible Clients:
- VS Code MCP Extension (latest version)
- Claude Desktop (recent versions supporting 2025-03-26 spec)
- Any MCP client implementing the Streamable HTTP transport protocol
⚠️ Note: For SSE type this server usesStreamableHTTPServerTransportwhich implements the modern MCP specification (2025-03-26). Older MCP clients that only support the legacy SSE protocol (2024-11-05) are not compatible. Please ensure your MCP client is up-to-date.
- 133 Tools across 30 categories for comprehensive Countly operations
- Resources for AI context - Access read-only Countly data (app configs, event schemas, analytics overviews)
- Prompts for common tasks - Pre-built templates for crash analysis, engagement reports, and more
- Multiple Transport Options: Supports both stdio (recommended) and HTTP/SSE connections
- Flexible Authentication: Environment variables, HTTP headers, URL parameters, or token files
- Plugin-Aware: Automatically detects and enables tools based on available Countly plugins
- Docker Support: Pre-built Docker images with multi-architecture support (amd64, arm64)
- Anonymous Analytics: Optional usage tracking (disabled by default) to help improve the server
This server implements the full MCP specification with support for:
Execute Countly operations like analytics queries, app management, crash analysis, etc.
Read-only access to Countly data for AI context:
countly://app/{app_id}/config- Application configuration and metadatacountly://app/{app_id}/events- Event definitions and schemascountly://app/{app_id}/overview- Current analytics overview with key metrics
Resources provide AI assistants with context without requiring tool calls, making conversations more efficient.
Pre-built analysis templates exposed as slash commands:
analyze_crash_trends- Analyze crash and error patternsgenerate_engagement_report- Comprehensive user engagement analysiscompare_app_versions- Compare performance between versionsuser_retention_analysis- Analyze retention patterns and cohortsfunnel_optimization- Conversion funnel analysis and suggestionsevent_health_check- Event tracking implementation quality checkidentify_churn_risk- Find users showing decreased engagementperformance_dashboard- Comprehensive performance overview
Prompts guide AI assistants through complex multi-step workflows automatically.
- 🔐 Multiple authentication methods (HTTP headers, environment variables, file-based)
- 📊 Comprehensive Countly API access
- ⚙️ Fine-grained tools configuration with CRUD operation control per category
- 🐳 Docker support with production-ready configuration
- 🔄 Support for both stdio and HTTP transports
- 🏥 Built-in health checks
- 🔒 Secure token handling with cryptographically secure session IDs
- 🌐 Multi-client support with per-client credential passing
- 🚨 Enhanced error handling with detailed API error messages
Before starting, ensure you have:
- Access to a Countly instance (cloud or self-hosted)
- Valid Countly authentication token with appropriate permissions
- Node.js 18+ (for local installation) OR Docker (recommended)
- MCP client supporting protocol version 2025-03-26 (Streamable HTTP)
-
Create a token file:
echo "your-countly-auth-token" > countly_token.txt
-
Create a
.envfile:cp .env.example .env # Edit .env and set your COUNTLY_SERVER_URL -
Run with Docker Compose:
docker-compose up -d
-
Access the server:
- HTTP/SSE mode:
http://localhost:3000/mcp - Health check:
http://localhost:3000/health - Default port: 3000 (configurable)
- HTTP/SSE mode:
docker run -d \
--name countly-mcp-server \
-p 3000:3000 \
-e COUNTLY_SERVER_URL=https://your-countly-instance.com \
-e COUNTLY_AUTH_TOKEN_FILE=/run/secrets/countly_token \
-v $(pwd)/countly_token.txt:/run/secrets/countly_token:ro \
countly-mcp-server-
Install dependencies:
npm install
-
Build the project:
npm run build
-
Configure environment:
cp .env.example .env # Edit .env with your settings -
Run the server:
# HTTP mode npm start # stdio mode (for MCP clients) npm run start:stdio
The server supports multiple authentication methods (in priority order):
-
HTTP Headers (recommended for HTTP/SSE transport)
- Pass via
X-Countly-Server-UrlandX-Countly-Auth-Tokenheaders - Supported by VS Code MCP extension and other HTTP clients
- See VS Code MCP Configuration for details
- Pass via
-
URL Parameters (alternative for HTTP/SSE transport)
- Pass as query string:
?server_url=https://your-server.count.ly&auth_token=your-api-key - Useful for quick testing or tools that don't support custom headers
- Less secure than headers, use headers when possible
- Pass as query string:
-
Tool Arguments
- Passed as
countly_auth_tokenparameter in individual tool calls
- Passed as
-
Environment Variable
- Set
COUNTLY_AUTH_TOKENin environment - Recommended for stdio transport mode
- Set
-
Token File (recommended for production)
- Set
COUNTLY_AUTH_TOKEN_FILEpointing to a file containing the token - Useful with Docker secrets
- Set
| Variable | Required | Default | Description |
|---|---|---|---|
COUNTLY_SERVER_URL |
Yes | https://api.count.ly |
Your Countly server URL |
COUNTLY_AUTH_TOKEN |
No* | - | Authentication token (direct) |
COUNTLY_AUTH_TOKEN_FILE |
No* | - | Path to file containing auth token |
COUNTLY_TIMEOUT |
No | 30000 |
Request timeout in milliseconds |
ENABLE_ANALYTICS |
No | true |
Enable anonymous usage analytics (set to false to opt out) |
COUNTLY_TOOLS_{CATEGORY} |
No | ALL |
Control available tools per category (see below) |
COUNTLY_TOOLS_ALL |
No | ALL |
Default permission for all categories |
*At least one authentication method must be configured
The MCP server includes optional anonymous usage analytics to help improve the product. Analytics are enabled by default and can be disabled via the ENABLE_ANALYTICS=false environment variable.
What is tracked:
- Transport type used (stdio vs HTTP)
- Tool execution metrics (success/failure, duration, tool names)
- Authentication methods used (headers, env, file, args)
- HTTP endpoint access patterns
- Error occurrences (type and message, NO sensitive data)
- Server start/stop events
What is NOT tracked:
- Authentication tokens or credentials
- Server URLs or domains
- User data or analytics content
- Personal information
- IP addresses or client identifiers
Privacy & Device ID: All analytics are aggregated under a single device ID "mcp" to ensure complete anonymity. No server-specific or user-specific information is collected.
To disable:
export ENABLE_ANALYTICS=falseOr in your .env file:
ENABLE_ANALYTICS=false
The server supports fine-grained control over which MCP tools are available and which CRUD operations they can perform. This is useful for security, governance, or creating read-only deployments.
Configure tools by category using environment variables:
# Format: COUNTLY_TOOLS_{CATEGORY}=CRUD
# Where CRUD letters represent: Create, Read, Update, Delete operations
# Examples:
COUNTLY_TOOLS_APPS=CR # Apps: Create and Read only
COUNTLY_TOOLS_DATABASE=R # Database: Read-only access
COUNTLY_TOOLS_CRASHES=CRUD # Crashes: Full access
COUNTLY_TOOLS_ALERTS=NONE # Alerts: Completely disabled
# Set default for all categories:
COUNTLY_TOOLS_ALL=R # Read-only mode for all toolsAvailable Categories:
CORE- Core tools (ping, get_version, get_plugins, jobs_list, job_runs) (5 tools)APPS- Application management (6 tools)ANALYTICS- Analytics data retrieval (7 tools)CRASHES- Crash analytics and management (10 tools)NOTES- Notes management (3 tools)EVENTS- Event configuration (1 tool)ALERTS- Alert management (3 tools)VIEWS- Views analytics (3 tools)DATABASE- Direct database access (6 tools)DASHBOARD_USERS- Dashboard user management (1 tool)APP_USERS- App user management (3 tools)
Total: 42 tools across 11 categories
For complete documentation, examples, and per-tool CRUD mappings, see TOOLS_CONFIGURATION.md.
Pull the image from Docker Hub:
docker pull countly/countly-mcp-server:latestdocker build -t countly-mcp-server .The included docker-compose.yml provides a production-ready setup with:
- Docker secrets for secure token storage
- Health checks
- Resource limits
- Automatic restart
- Proper logging configuration
For orchestrated deployments, use external secrets:
Docker Swarm:
# Create secret
echo "your-token" | docker secret create countly_token -
# Deploy stack
docker stack deploy -c docker-compose.yml countlyKubernetes:
apiVersion: v1
kind: Secret
metadata:
name: countly-token
type: Opaque
stringData:
token: your-countly-auth-token
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: countly-mcp-server
spec:
replicas: 1
selector:
matchLabels:
app: countly-mcp-server
template:
metadata:
labels:
app: countly-mcp-server
spec:
containers:
- name: countly-mcp-server
image: countly-mcp-server:latest
ports:
- containerPort: 3000
env:
- name: COUNTLY_SERVER_URL
value: "https://your-countly-instance.com"
- name: COUNTLY_AUTH_TOKEN_FILE
value: "/run/secrets/countly_token"
volumeMounts:
- name: token
mountPath: /run/secrets
readOnly: true
volumes:
- name: token
secret:
secretName: countly-token
items:
- key: token
path: countly_tokenThe most common use case is with Claude Desktop. Add to your Claude configuration file:
Location:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Using Docker:
{
"mcpServers": {
"countly": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e", "COUNTLY_SERVER_URL=https://your-countly-instance.com",
"-e", "COUNTLY_AUTH_TOKEN=your-token-here",
"countly-mcp-server",
"node", "build/index.js"
]
}
}
}Using local installation:
{
"mcpServers": {
"countly": {
"command": "node",
"args": ["/path/to/countly-mcp-server/build/index.js"],
"env": {
"COUNTLY_SERVER_URL": "https://your-countly-instance.com",
"COUNTLY_AUTH_TOKEN": "your-token-here"
}
}
}
}Using environment variable for token (alternative):
{
"mcpServers": {
"countly": {
"command": "node",
"args": ["/path/to/countly-mcp-server/build/index.js"],
"env": {
"COUNTLY_SERVER_URL": "https://your-countly-instance.com",
"COUNTLY_AUTH_TOKEN": "your-token-here"
}
}
}
}This server is compatible with any MCP client that supports:
- stdio transport (default) - For local/desktop clients (uses environment variables for auth)
- HTTP/SSE transport - For web-based or remote clients (uses HTTP headers for auth)
For HTTP mode, clients should connect to: http://your-server:3000/mcp
The server provides 134 tools across 30 categories for comprehensive Countly integration:
ping- Check if Countly server is healthy and reachableget_version- Check what version of Countly is running on the serverget_plugins- Get list of installed plugins on the serverjobs_list- List all background jobs running on the Countly server with pagination and sortingjob_runs- Get run history and details for a specific background job by name
apps_list- List all applicationsapps_get_by_name- Get app details by nameapps_create- Create new applicationapps_update- Update app settingsapps_delete- Delete applicationapps_reset- Reset app data
get_analytics_data- Analytics data breakdown by predefined methods (locations, carriers, devices, etc.). For multi-segment breakdowns, use drill toolsapp_analytics_summary- General app summary and analytics overviewslipping_users- Identify inactive app userssession_frequency- Session frequency distribution across time buckets (f=0: first session, f=1: 1-24h, f=2: 1 day, through f=11: 30+ days)user_loyalty- User loyalty data showing session count distribution across loyalty buckets (1 session, 2 sessions, 3-5, 6-9, 10-19, 20-49, 50-99, 100-499, 500+)session_durations- Session duration distribution across duration buckets (0-10 sec, 11-30 sec, 31-60 sec, 1-3 min, 3-10 min, 10-30 min, 30-60 min, 1+ hour)
events_create- Define event with metadata and configurationevents_list- List all events and their segments, including internal Countly events with exact database structureget_events_data- Basic events data tool. If event is provided, shows breakdown of that event per time bucket. If event is not provided, shows all events total data for the period. For segmenting events by segments, you will need to use the drill tool.
dashboard_users- List all dashboard users (admin/management users who access the Countly dashboard)
apps_create_user- Create app user (end-user being tracked in your application)apps_delete_user- Delete app user (end-user)export_app_users- Export app user data (end-users)
alerts_create- Create alert configurationalerts_delete- Delete alertalerts_list- List all alerts
notes_list- List all dashboard notesnotes_create- Create notenotes_delete- Delete note
databases_list- List available databasesdatabases_query- Query database collectionsdatabases_document- Get specific documentcollections_aggregate- Run aggregation pipelinescollections_indexes- View collection indexesdatabases_stats- Database statistics
crash_groups_list- List crash groups for an appcrashes_stats_get- Get crash statistics and graphscrashes_get- View crash detailscrashes_resolve- Mark crash as resolveduncrashes_resolve- Mark crash as unresolvedcrashes_hide- Hide crash from viewcrashes_show- Show hidden crashcrashes_comment_add- Add comment to crashcrashes_comment_update- Edit crash commentcrashes_comment_delete- Delete crash comment
queriable_fields_list- Get available properties for segmentationrun_query- Run drill query with filters and time bucketsdrill_bookmarks_list- List saved segmentation queriesdrill_bookmarks_create- Save a segmentation querydrill_bookmarks_delete- Delete a saved query
user_profiles_query- Query users with MongoDB filtersuser_profiles_breakdown- Break down user counts by propertiesuser_profiles_get- Get specific user details by UID
cohorts_list- List all user cohorts with filteringcohorts_data- Get cohort data over a periodcohorts_create- Create behavioral cohort based on user actionscohorts_update- Update cohort configurationcohorts_delete- Delete a cohort
funnels_list- List all conversion funnelsfunnels_data- Get funnel analytics data with filteringfunnels_step_users- Get users who reached a specific stepfunnels_dropoff_users- Get users who dropped off between stepsfunnels_create- Create conversion funnel with event sequencefunnels_update- Update funnel configurationfunnels_delete- Delete a funnel
formulas_run- Run mathematical formulas on metrics (sessions, events, users) with filters and segmentsformulas_list- List all saved formulasformulas_delete- Delete a saved formula
live_users- Get current online user count and new users at this momentlive_metrics- Get breakdown by countries, devices and carriers for users currently onlinelive_last_hour- Get minute-by-minute data for the last hour (60 data points)live_last_day- Get hour-by-hour data for the last day (24 data points)live_last_30_days- Get daily data for the last 30 days (30 data points)live_overall- Get maximum values for online users (peak concurrent usage records)
retention- Get retention data showing consecutive event streaks. Supports three types: Full (strict - breaks on first skip), Classic (Day N - specific days independently), Unbounded (lenient - any return counts)
remote_configs_list- List all remote config parameters and conditionsremote_config_conditions_add- Add user segmentation condition using MongoDB queriesremote_config_conditions_update- Update existing condition criteriaremote_config_conditions_delete- Delete a condition (if not in use)remote_config_parameters_add- Add parameter with default and conditional valuesremote_config_parameters_update- Update parameter values, conditions, or statusremote_config_parameters_delete- Delete a parameter
ab_experiments_list- List all A/B testing experiments with statuses and resultsab_experiments_details- Get detailed experiment info including variants and statistical significanceab_experiments_create- Create new experiment with variants, user targeting, and goalsab_experiments_start- Start experiment to begin collecting dataab_experiments_stop- Stop running experimentab_experiments_delete- Delete experiment and all its data
sdk_logs_list- List incoming data logs sent by SDK to the server for debugging and monitoring
sdk_stats_get- Get statistics about SDKs sending data (names, versions, request types, health checks)sdk_config_get- Get SDK configuration settings controlling SDK behavior and enabled features
consents_stats- Get aggregated consent statistics showing which consents users gave and whenconsents_list- List specific users and their consent statusconsents_history_search- Search consent history records with detailed audit trail
filtering_rules_list- List all blocking rules that filter incoming requestsfiltering_rules_create- Create rule to block requests based on MongoDB conditions (IP, version, device properties)filtering_rules_update- Update existing blocking rule configurationfiltering_rules_delete- Delete a blocking rule
datapoints_stats- Get data points collected per app per datapoint type. Data points measure collected data and are tied to server specs and billing.datapoints_top_apps- Get top apps ranked by data point collection for understanding data usage and billingdatapoints_punch_card- Get hourly data point breakdown punchcard showing server load patterns for capacity planning
server_logs_files_list- List available server log files (only available in non-Docker deployments)server_logs_contents- Get contents of a specific server log file for debugging and monitoring (only available in non-Docker deployments)
email_reports_list- List all email reports configured for an appemail_reports_core_create- Create a core email report with metrics like analytics, events, crashes, and star-ratingemail_reports_dashboard_create- Create a dashboard email report for specific dashboardsemail_reports_update- Update an existing email report configurationemail_reports_preview- Preview an email report to see what it will look like before sendingemail_reports_send- Manually trigger sending an email report immediatelyemail_reports_delete- Delete an email report configuration
dashboards_list- List all available dashboards (with optional schema-only parameter)dashboards_data- Get widgets and data for a specific dashboard with time period filteringdashboards_create- Create a new dashboard with sharing settings, auto-refresh configuration, and themedashboards_update- Update dashboard configuration (name, sharing, refresh rate, theme)dashboards_delete- Delete a dashboard by IDdashboards_widget_add- Add a widget to a dashboard with full configuration (title, feature, widget type, apps, metrics, visualization)dashboards_update_widget- Update widget position and size in the grid layoutdashboards_widget_remove- Remove a widget from a dashboard
times_of_day- Get user behavior patterns in their local time for a specific event. Shows when users are most active throughout the day (by hour) and week (by day). Useful for understanding optimal engagement times and scheduling.
hooks_list- List all webhooks/hooks configured for an app. Shows triggers, effects, and configuration details.hooks_test- Test a hook configuration with mock data before creating it. Useful for validating trigger conditions and effect actions.hooks_create- Create a new webhook/hook with various trigger types (IncomingDataTrigger, APIEndPointTrigger, InternalEventTrigger, ScheduledTrigger) and effects (HTTPEffect, EmailEffect, CustomCodeEffect).hooks_update- Update an existing webhook/hook configuration.hooks_delete- Delete a webhook/hook by its ID.hooks_internal_triggers_get- Get list of available internal Countly events that can be used as triggers for hooks (e.g., /crashes/new, /cohort/enter, /i/apps/create).
All tools support flexible app identification via either app_id or app_name parameter.
The server includes a health check endpoint at /health (HTTP mode only):
curl http://localhost:3000/healthResponse:
{
"status": "healthy",
"timestamp": "2025-10-10T12:00:00.000Z"
}The server provides a .well-known discovery endpoint for automated configuration (HTTP mode only):
curl http://localhost:3000/.well-known/mcp-manifest.jsonThis manifest provides server metadata including:
- Server name, version, and description
- Supported MCP protocol version
- Available endpoints (MCP, health, etc.)
- Supported transports (stdio, HTTP/SSE)
- Server capabilities (tool count, categories, features)
- Authentication methods
- Documentation links
- Repository information
This endpoint can be used by MCP clients for automatic server discovery and capability detection.
When running in HTTP mode, the MCP protocol endpoint is available at:
- Path:
/mcp - Transport: Server-Sent Events (SSE)
- Full URL:
http://localhost:3000/mcp
This endpoint handles all MCP protocol communication using the SSE transport method.
countly-mcp-server/
├── src/
│ └── index.ts # Main server implementation
├── build/ # Compiled JavaScript output
├── docs/ # Additional documentation
├── .env.example # Environment configuration template
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile # Docker image definition
├── DOCKER.md # Detailed Docker deployment guide
└── README.md # This file
npm run devRun automated tests:
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Generate coverage report
npm run test:coverage
# Run tests for CI
npm run test:ciTesting Documentation:
- See docs/TESTING.md for complete testing guide
- See docs/TESTING_SUMMARY.md for testing strategy
Current Coverage:
- Authentication and credential handling
- Tool handlers and parameter validation
- HTTP client configuration
- Transport layer (stdio and HTTP/SSE)
- End-to-end server connectivity
- Error handling
- Never commit tokens to version control
- Use Docker secrets or environment variables for production
- Restrict file permissions on token files (
chmod 600) - Use HTTPS for Countly server connections
- Rotate tokens regularly
- Use read-only mounts for token files in Docker
# Test connectivity
curl https://your-countly-instance.com/o/apps/mine?auth_token=your-token
# Check Docker logs
docker logs countly-mcp-server
# Check container health
docker psVerify your token and ensure it has proper permissions in Countly.
MIT
For issues and questions:
- GitHub Issues: countly/countly-mcp-server
- Countly Community: https://community.count.ly
This project uses GitHub Actions for automated testing and deployment:
- Automated Tests: Run on every pull request and push to main/develop
- Tests across Node.js 18, 20, and 22
- TypeScript compilation verification
- Test coverage reporting
- Build smoke tests
- Docker Publishing: Automated builds on version tags (
v*.*.*)- Multi-architecture support (amd64, arm64)
- Automatic latest tag updates
- Tests must pass before publishing
See .github/AUTOMATED_TESTING.md for details.
Contributions are welcome! Please read our contributing guidelines before submitting PRs.
Development Workflow:
- Fork the repository
- Create a feature branch
- Make your changes and add tests
- Run
npm testlocally - Submit a pull request
- GitHub Actions will automatically run tests
- Address any feedback and ensure tests pass