MCP server for Countly Analytics Platform
npm install countly-mcp-serverA 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.
2025-03-26 (Streamable HTTP specification)> ā ļø Note: For SSE type this server uses StreamableHTTPServerTransport which 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:
countly://app/{app_id}/config - Application configuration and metadatacountly://app/{app_id}/events - Event definitions and schemas countly://app/{app_id}/overview - Current analytics overview with key metricsResources provide AI assistants with context without requiring tool calls, making conversations more efficient.
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 overviewPrompts 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)
1. Create a token file:
``bash`
echo "your-countly-auth-token" > countly_token.txt
2. Create a .env file:
`bash`
cp .env.example .env
# Edit .env and set your COUNTLY_SERVER_URL
3. Run with Docker Compose:
`bash`
docker-compose up -d
4. Access the server:
- HTTP/SSE mode: http://localhost:3000/mcphttp://localhost:3000/health
- Health check:
- Default port: 3000 (configurable)
`bash`
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
1. Install dependencies:
`bash`
npm install
2. Build the project:
`bash`
npm run build
3. Configure environment:
`bash`
cp .env.example .env
# Edit .env with your settings
4. Run the server:
`bash`
# HTTP mode
npm start
# stdio mode (for MCP clients)
npm run start:stdio
The server supports multiple authentication methods (in priority order):
1. HTTP Headers (recommended for HTTP/SSE transport)
- Pass via X-Countly-Server-Url and X-Countly-Auth-Token headers
- Supported by VS Code MCP extension and other HTTP clients
- See VS Code MCP Configuration for details
2. 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
3. Tool Arguments
- Passed as countly_auth_token parameter in individual tool calls
4. Environment Variable
- Set COUNTLY_AUTH_TOKEN in environment
- Recommended for stdio transport mode
5. Token File (recommended for production)
- Set COUNTLY_AUTH_TOKEN_FILE pointing to a file containing the token
- Useful with Docker secrets
| 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:
`bash`
export ENABLE_ANALYTICS=false
Or 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:
`bashFormat: COUNTLY_TOOLS_{CATEGORY}=CRUD
Where CRUD letters represent: Create, Read, Update, Delete operations
Available 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.
Docker Deployment
$3
Pull the image from Docker Hub:
`bash
docker pull countly/countly-mcp-server:latest
`$3
`bash
docker build -t countly-mcp-server .
`$3
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$3
For orchestrated deployments, use external secrets:
Docker Swarm:
`bash
Create secret
echo "your-token" | docker secret create countly_token -Deploy stack
docker stack deploy -c docker-compose.yml countly
`Kubernetes:
`yaml
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_token
`MCP Client Configuration
$3
The 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.jsonUsing Docker:
`json
{
"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:
`json
{
"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):
`json
{
"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"
}
}
}
}
`$3
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/mcpAvailable Tools
The server provides 134 tools across 30 categories for comprehensive Countly integration:
$3
- ping - Check if Countly server is healthy and reachable
- get_version - Check what version of Countly is running on the server
- get_plugins - Get list of installed plugins on the server
- jobs_list - List all background jobs running on the Countly server with pagination and sorting
- job_runs - Get run history and details for a specific background job by name$3
- apps_list - List all applications
- apps_get_by_name - Get app details by name
- apps_create - Create new application
- apps_update - Update app settings
- apps_delete - Delete application
- apps_reset - Reset app data$3
- get_analytics_data - Analytics data breakdown by predefined methods (locations, carriers, devices, etc.). For multi-segment breakdowns, use drill tools
- app_analytics_summary - General app summary and analytics overview
- slipping_users - Identify inactive app users
- session_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)$3
- events_create - Define event with metadata and configuration
- events_list - List all events and their segments, including internal Countly events with exact database structure
- get_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.$3
- dashboard_users - List all dashboard users (admin/management users who access the Countly dashboard)$3
- 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)$3
- alerts_create - Create alert configuration
- alerts_delete - Delete alert
- alerts_list - List all alerts$3
- notes_list - List all dashboard notes
- notes_create - Create note
- notes_delete - Delete note$3
- databases_list - List available databases
- databases_query - Query database collections
- databases_document - Get specific document
- collections_aggregate - Run aggregation pipelines
- collections_indexes - View collection indexes
- databases_stats - Database statistics$3
- crash_groups_list - List crash groups for an app
- crashes_stats_get - Get crash statistics and graphs
- crashes_get - View crash details
- crashes_resolve - Mark crash as resolved
- uncrashes_resolve - Mark crash as unresolved
- crashes_hide - Hide crash from view
- crashes_show - Show hidden crash
- crashes_comment_add - Add comment to crash
- crashes_comment_update - Edit crash comment
- crashes_comment_delete - Delete crash comment$3
- queriable_fields_list - Get available properties for segmentation
- run_query - Run drill query with filters and time buckets
- drill_bookmarks_list - List saved segmentation queries
- drill_bookmarks_create - Save a segmentation query
- drill_bookmarks_delete - Delete a saved query$3
- user_profiles_query - Query users with MongoDB filters
- user_profiles_breakdown - Break down user counts by properties
- user_profiles_get - Get specific user details by UID$3
- cohorts_list - List all user cohorts with filtering
- cohorts_data - Get cohort data over a period
- cohorts_create - Create behavioral cohort based on user actions
- cohorts_update - Update cohort configuration
- cohorts_delete - Delete a cohort$3
- funnels_list - List all conversion funnels
- funnels_data - Get funnel analytics data with filtering
- funnels_step_users - Get users who reached a specific step
- funnels_dropoff_users - Get users who dropped off between steps
- funnels_create - Create conversion funnel with event sequence
- funnels_update - Update funnel configuration
- funnels_delete - Delete a funnel$3
- formulas_run - Run mathematical formulas on metrics (sessions, events, users) with filters and segments
- formulas_list - List all saved formulas
- formulas_delete - Delete a saved formula$3
- live_users - Get current online user count and new users at this moment
- live_metrics - Get breakdown by countries, devices and carriers for users currently online
- live_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)$3
- 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)$3
- remote_configs_list - List all remote config parameters and conditions
- remote_config_conditions_add - Add user segmentation condition using MongoDB queries
- remote_config_conditions_update - Update existing condition criteria
- remote_config_conditions_delete - Delete a condition (if not in use)
- remote_config_parameters_add - Add parameter with default and conditional values
- remote_config_parameters_update - Update parameter values, conditions, or status
- remote_config_parameters_delete - Delete a parameter$3
- ab_experiments_list - List all A/B testing experiments with statuses and results
- ab_experiments_details - Get detailed experiment info including variants and statistical significance
- ab_experiments_create - Create new experiment with variants, user targeting, and goals
- ab_experiments_start - Start experiment to begin collecting data
- ab_experiments_stop - Stop running experiment
- ab_experiments_delete - Delete experiment and all its data$3
- sdk_logs_list - List incoming data logs sent by SDK to the server for debugging and monitoring$3
- 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$3
- consents_stats - Get aggregated consent statistics showing which consents users gave and when
- consents_list - List specific users and their consent status
- consents_history_search - Search consent history records with detailed audit trail$3
- filtering_rules_list - List all blocking rules that filter incoming requests
- filtering_rules_create - Create rule to block requests based on MongoDB conditions (IP, version, device properties)
- filtering_rules_update - Update existing blocking rule configuration
- filtering_rules_delete - Delete a blocking rule$3
- 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 billing
- datapoints_punch_card - Get hourly data point breakdown punchcard showing server load patterns for capacity planning$3
- 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)$3
- email_reports_list - List all email reports configured for an app
- email_reports_core_create - Create a core email report with metrics like analytics, events, crashes, and star-rating
- email_reports_dashboard_create - Create a dashboard email report for specific dashboards
- email_reports_update - Update an existing email report configuration
- email_reports_preview - Preview an email report to see what it will look like before sending
- email_reports_send - Manually trigger sending an email report immediately
- email_reports_delete - Delete an email report configuration$3
- dashboards_list - List all available dashboards (with optional schema-only parameter)
- dashboards_data - Get widgets and data for a specific dashboard with time period filtering
- dashboards_create - Create a new dashboard with sharing settings, auto-refresh configuration, and theme
- dashboards_update - Update dashboard configuration (name, sharing, refresh rate, theme)
- dashboards_delete - Delete a dashboard by ID
- dashboards_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 layout
- dashboards_widget_remove - Remove a widget from a dashboard$3
- 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.$3
- 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.Health Check
The server includes a health check endpoint at
/health (HTTP mode only):`bash
curl http://localhost:3000/health
`Response:
`json
{
"status": "healthy",
"timestamp": "2025-10-10T12:00:00.000Z"
}
`Server Discovery
The server provides a
.well-known discovery endpoint for automated configuration (HTTP mode only):`bash
curl http://localhost:3000/.well-known/mcp-manifest.json
`This 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.
MCP Endpoint
When running in HTTP mode, the MCP protocol endpoint is available at:
- Path:
/mcp
- Transport: Server-Sent Events (SSE)
- Full URL: http://localhost:3000/mcpThis endpoint handles all MCP protocol communication using the SSE transport method.
Project Structure
`
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
`Development
$3
`bash
npm run dev
`Testing
Run automated tests:
`bash
Run all tests
npm testRun tests in watch mode
npm run test:watchGenerate coverage report
npm run test:coverageRun tests for CI
npm run test:ci
`Testing 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
---
1. Never commit tokens to version control
2. Use Docker secrets or environment variables for production
3. Restrict file permissions on token files (
chmod 600)
4. Use HTTPS for Countly server connections
5. Rotate tokens regularly
6. Use read-only mounts for token files in DockerTroubleshooting
$3
`bash
Test connectivity
curl https://your-countly-instance.com/o/apps/mine?auth_token=your-tokenCheck Docker logs
docker logs countly-mcp-serverCheck container health
docker ps
`$3
Verify your token and ensure it has proper permissions in Countly.
License
MIT
Support
For issues and questions:
- GitHub Issues: countly/countly-mcp-server
- Countly Community: https://community.count.ly
CI/CD
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 publishingSee .github/AUTOMATED_TESTING.md for details.
Contributing
Contributions are welcome! Please read our contributing guidelines before submitting PRs.
Development Workflow:
1. Fork the repository
2. Create a feature branch
3. Make your changes and add tests
4. Run
npm test` locally