Skip to content

Commit e89c8e0

Browse files
authored
Merge pull request #17 from Countly/ar2rsawseen/main
Update docker docs
2 parents c2c5f5e + 9b3a966 commit e89c8e0

File tree

13 files changed

+507
-135
lines changed

13 files changed

+507
-135
lines changed

.env.example

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ COUNTLY_SERVER_URL=https://api.count.ly
2424
# Useful for Docker secrets, Kubernetes secrets, or secure file storage
2525
# COUNTLY_AUTH_TOKEN_FILE=/run/secrets/countly_token
2626

27-
# Note: If neither is set, the token must be provided by the MCP client
28-
# via metadata.countlyAuthToken or as a tool argument
27+
# Note: If neither is set, credentials can be provided:
28+
# - Via HTTP headers (X-Countly-Auth-Token) for HTTP/SSE transport
29+
# - Via tool arguments (countly_auth_token) in individual tool calls
2930

3031

3132
# ==============================================================================
@@ -42,8 +43,8 @@ COUNTLY_TIMEOUT=30000
4243
# AUTHENTICATION PRIORITY
4344
# ==============================================================================
4445
# The server uses the following priority for authentication:
45-
# 1. MCP client metadata (metadata.countlyAuthToken)
46-
# 2. Tool argument (countly_auth_token)
46+
# 1. HTTP headers (X-Countly-Auth-Token) - for HTTP/SSE transport
47+
# 2. Tool argument (countly_auth_token) - per-request override
4748
# 3. Environment variable (COUNTLY_AUTH_TOKEN)
4849
# 4. Token file (COUNTLY_AUTH_TOKEN_FILE)
4950
#
@@ -78,10 +79,10 @@ COUNTLY_TIMEOUT=30000
7879

7980

8081
# ==============================================================================
81-
# MCP CLIENT CONFIGURATION EXAMPLE
82+
# MCP CLIENT CONFIGURATION EXAMPLES
8283
# ==============================================================================
83-
# If using MCP client (e.g., Claude Desktop), configure in your MCP settings:
84-
#
84+
85+
# STDIO Transport (Claude Desktop, local clients):
8586
# {
8687
# "mcpServers": {
8788
# "countly": {
@@ -95,19 +96,17 @@ COUNTLY_TIMEOUT=30000
9596
# }
9697
# }
9798
#
98-
# Or using metadata for per-user authentication:
99-
#
99+
# HTTP/SSE Transport (VS Code, web clients):
100100
# {
101-
# "mcpServers": {
102-
# "countly": {
103-
# "command": "node",
104-
# "args": ["/path/to/countly-mcp-server/build/index.js"],
105-
# "env": {
106-
# "COUNTLY_SERVER_URL": "https://your-countly-instance.com"
107-
# },
108-
# "metadata": {
109-
# "countlyAuthToken": "your-auth-token-here"
101+
# "servers": {
102+
# "countly-docker": {
103+
# "type": "sse",
104+
# "url": "http://localhost:3000/mcp",
105+
# "headers": {
106+
# "X-Countly-Server-Url": "https://your-countly-instance.com",
107+
# "X-Countly-Auth-Token": "your-auth-token-here"
110108
# }
111109
# }
112110
# }
113111
# }
112+

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ jobs:
5050

5151
- name: Run tests
5252
run: npm run test:ci
53+
env:
54+
# Set test credentials for transport integration tests
55+
COUNTLY_SERVER_URL: https://test.count.ly
56+
COUNTLY_AUTH_TOKEN: test-token-for-ci
5357

5458
- name: Upload coverage to Codecov
5559
uses: codecov/codecov-action@v5

DOCKER.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ The fastest way to get started:
2020

2121
```bash
2222
# 1. Clone and navigate to the repository
23-
git clone https://github.com/countly/mcp-server.git
24-
cd mcp-server
23+
git clone https://github.com/countly/countly-mcp-server.git
24+
cd countly-mcp-server
2525

2626
# 2. Run the quick start script
2727
./docker-start.sh
@@ -37,7 +37,7 @@ The script will guide you through:
3737
### Pull from Docker Hub
3838

3939
```bash
40-
docker pull countly/mcp-server:latest
40+
docker pull countly/countly-mcp-server:latest
4141
```
4242

4343
### Run from Docker Hub
@@ -48,7 +48,7 @@ docker run -d \
4848
-p 3000:3000 \
4949
-e COUNTLY_SERVER_URL=https://your-countly-instance.com \
5050
-e COUNTLY_AUTH_TOKEN=your-token-here \
51-
countly/mcp-server:latest
51+
countly/countly-mcp-server:latest
5252
```
5353

5454
## Local Build
@@ -227,7 +227,7 @@ spec:
227227
spec:
228228
containers:
229229
- name: countly-mcp-server
230-
image: countly/mcp-server:latest
230+
image: countly/countly-mcp-server:latest
231231
imagePullPolicy: Always
232232
ports:
233233
- containerPort: 3000
@@ -523,6 +523,6 @@ logging:
523523
524524
## Support
525525
526-
- Issues: [GitHub Issues](https://github.com/countly/mcp-server/issues)
526+
- Issues: [GitHub Issues](https://github.com/countly/countly-mcp-server/issues)
527527
- Community: [Countly Community](https://community.count.ly)
528528
- Documentation: [README.md](./README.md)

Dockerfile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ RUN npm run build
2323
# Stage 2: Production
2424
FROM node:20-alpine
2525

26+
# OCI Labels for metadata and Docker Desktop icon
27+
LABEL org.opencontainers.image.title="Countly MCP Server" \
28+
org.opencontainers.image.description="Model Context Protocol server for Countly Analytics Platform" \
29+
org.opencontainers.image.vendor="Countly" \
30+
org.opencontainers.image.authors="Countly Team" \
31+
org.opencontainers.image.url="https://count.ly" \
32+
org.opencontainers.image.documentation="https://github.com/countly/countly-mcp-server" \
33+
org.opencontainers.image.source="https://github.com/countly/countly-mcp-server" \
34+
org.opencontainers.image.licenses="MIT" \
35+
com.docker.extension.icon="https://cdn.prod.website-files.com/61c1b7c3e2f3805325be4594/63cc3bf4993f0072054270a6_Logo%20-%20Dark%20background.png"
36+
2637
WORKDIR /app
2738

2839
# Install dumb-init for proper signal handling
@@ -65,5 +76,5 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
6576
# Use dumb-init to handle signals properly
6677
ENTRYPOINT ["dumb-init", "--"]
6778

68-
# Default command: run in HTTP mode (can be overridden for stdio mode)
69-
CMD ["node", "build/index.js", "--http"]
79+
# Default command: run in HTTP mode on port 3000 (can be overridden for stdio mode)
80+
CMD ["node", "build/index.js", "--http", "--port", "3000", "--hostname", "0.0.0.0"]

README.md

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,42 @@ Countly is an open-source, enterprise-grade product analytics platform. It helps
1010

1111
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.
1212

13+
## Requirements
14+
15+
### Server Requirements
16+
- **Node.js 18+** (for local installation) OR **Docker** (recommended)
17+
- **Countly Server**: Access to a Countly instance (cloud or self-hosted)
18+
- **Auth Token**: Valid Countly authentication token with appropriate permissions
19+
20+
### Client Requirements
21+
- **MCP Protocol Version**: `2025-03-26` (Streamable HTTP specification)
22+
- **Compatible Clients**:
23+
- VS Code MCP Extension (latest version)
24+
- Claude Desktop (recent versions supporting 2025-03-26 spec)
25+
- Any MCP client implementing the Streamable HTTP transport protocol
26+
27+
> ⚠️ **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.
28+
1329
## Features
1430

15-
- 🔐 Multiple authentication methods (metadata, environment variables, file-based)
31+
- 🔐 Multiple authentication methods (HTTP headers, environment variables, file-based)
1632
- 📊 Comprehensive Countly API access
1733
- �️ Fine-grained tools configuration with CRUD operation control per category
1834
- �🐳 Docker support with production-ready configuration
1935
- 🔄 Support for both stdio and HTTP transports
2036
- 🏥 Built-in health checks
21-
- 🔒 Secure token handling with Docker secrets support
37+
- 🔒 Secure token handling with cryptographically secure session IDs
38+
- 🌐 Multi-client support with per-client credential passing
2239

2340
## Quick Start
2441

2542
### Prerequisites
2643

27-
- **Countly Server**: Access to a Countly instance (cloud or self-hosted)
28-
- **Auth Token**: Valid Countly authentication token with appropriate permissions
29-
- **Node.js 18+** (for local installation) OR **Docker** (recommended)
44+
Before starting, ensure you have:
45+
- Access to a Countly instance (cloud or self-hosted)
46+
- Valid Countly authentication token with appropriate permissions
47+
- Node.js 18+ (for local installation) OR Docker (recommended)
48+
- MCP client supporting protocol version 2025-03-26 (Streamable HTTP)
3049

3150
### Using Docker (Recommended)
3251

@@ -94,17 +113,21 @@ docker run -d \
94113

95114
The server supports multiple authentication methods (in priority order):
96115

97-
1. **MCP Client Metadata** (highest priority)
98-
- Passed via `metadata.countlyAuthToken`
99-
116+
1. **HTTP Headers** (recommended for HTTP/SSE transport)
117+
- Pass via `X-Countly-Server-Url` and `X-Countly-Auth-Token` headers
118+
- Supported by VS Code MCP extension and other HTTP clients
119+
- See [VS Code MCP Configuration](examples/vscode-mcp.md) for details
120+
100121
2. **Tool Arguments**
101-
- Passed as `countly_auth_token` parameter
122+
- Passed as `countly_auth_token` parameter in individual tool calls
102123

103124
3. **Environment Variable**
104125
- Set `COUNTLY_AUTH_TOKEN` in environment
126+
- Recommended for stdio transport mode
105127

106128
4. **Token File** (recommended for production)
107129
- Set `COUNTLY_AUTH_TOKEN_FILE` pointing to a file containing the token
130+
- Useful with Docker secrets
108131

109132
## Configuration
110133

@@ -290,7 +313,7 @@ The most common use case is with Claude Desktop. Add to your Claude configuratio
290313
}
291314
```
292315

293-
**Using metadata for token (more secure):**
316+
**Using environment variable for token (alternative):**
294317

295318
```json
296319
{
@@ -299,10 +322,8 @@ The most common use case is with Claude Desktop. Add to your Claude configuratio
299322
"command": "node",
300323
"args": ["/path/to/countly-mcp-server/build/index.js"],
301324
"env": {
302-
"COUNTLY_SERVER_URL": "https://your-countly-instance.com"
303-
},
304-
"metadata": {
305-
"countlyAuthToken": "your-token-here"
325+
"COUNTLY_SERVER_URL": "https://your-countly-instance.com",
326+
"COUNTLY_AUTH_TOKEN": "your-token-here"
306327
}
307328
}
308329
}
@@ -312,8 +333,8 @@ The most common use case is with Claude Desktop. Add to your Claude configuratio
312333
### Other MCP Clients
313334

314335
This server is compatible with any MCP client that supports:
315-
- **stdio transport** (default) - For local/desktop clients
316-
- **HTTP/SSE transport** - For web-based or remote clients
336+
- **stdio transport** (default) - For local/desktop clients (uses environment variables for auth)
337+
- **HTTP/SSE transport** - For web-based or remote clients (uses HTTP headers for auth)
317338

318339
For HTTP mode, clients should connect to: `http://your-server:3000/mcp`
319340

@@ -457,6 +478,8 @@ npm run test:ci
457478
- Authentication and credential handling
458479
- Tool handlers and parameter validation
459480
- HTTP client configuration
481+
- Transport layer (stdio and HTTP/SSE)
482+
- End-to-end server connectivity
460483
- Error handling
461484

462485
---
@@ -494,7 +517,7 @@ MIT
494517
## Support
495518

496519
For issues and questions:
497-
- GitHub Issues: [countly/mcp-server](https://github.com/countly/mcp-server)
520+
- GitHub Issues: [countly/countly-mcp-server](https://github.com/countly/countly-mcp-server)
498521
- Countly Community: [https://community.count.ly](https://community.count.ly)
499522

500523
## CI/CD

docker-compose.yml

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
1-
version: '3.8'
2-
31
services:
42
countly-mcp-server:
53
build:
64
context: .
75
dockerfile: Dockerfile
86
container_name: countly-mcp-server
97
restart: unless-stopped
10-
11-
# Environment variables
8+
9+
# Environment variables (optional - can be provided by MCP client via HTTP headers)
1210
environment:
13-
- COUNTLY_SERVER_URL=${COUNTLY_SERVER_URL:-https://api.count.ly}
11+
# Countly server URL (optional - can be provided via X-Countly-Server-Url header)
12+
- COUNTLY_SERVER_URL=${COUNTLY_SERVER_URL:-}
13+
# Auth token (optional - can be provided via X-Countly-Auth-Token header)
14+
- COUNTLY_AUTH_TOKEN=${COUNTLY_AUTH_TOKEN:-}
15+
# Request timeout in milliseconds
1416
- COUNTLY_TIMEOUT=${COUNTLY_TIMEOUT:-30000}
15-
# Option 1: Direct token (not recommended for production)
16-
# - COUNTLY_AUTH_TOKEN=${COUNTLY_AUTH_TOKEN}
17-
# Option 2: Token from file (recommended for production)
18-
- COUNTLY_AUTH_TOKEN_FILE=/run/secrets/countly_token
19-
17+
2018
# Ports
2119
ports:
2220
- "3000:3000"
23-
24-
# Docker secrets (recommended for production)
25-
secrets:
26-
- countly_token
27-
21+
22+
# Docker secrets (optional - uncomment for production use)
23+
# secrets:
24+
# - countly_token
25+
2826
# Health check
2927
healthcheck:
30-
test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"]
28+
test: [ "CMD", "node", "-e", "require('http').get('http://localhost:3000/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})" ]
3129
interval: 30s
3230
timeout: 10s
3331
retries: 3
3432
start_period: 5s
35-
33+
3634
# Logging
3735
logging:
3836
driver: "json-file"
3937
options:
4038
max-size: "10m"
4139
max-file: "3"
42-
40+
4341
# Resource limits (adjust as needed)
4442
deploy:
4543
resources:
@@ -50,28 +48,13 @@ services:
5048
cpus: '0.5'
5149
memory: 256M
5250

53-
# Docker secrets configuration
54-
secrets:
55-
countly_token:
56-
# Option 1: Load from file
57-
file: ./countly_token.txt
58-
# Option 2: External secret (for Docker Swarm)
59-
# external: true
51+
# Docker secrets configuration (optional - for production use)
52+
# Uncomment the secrets section in the service above and this section to use secrets
53+
# secrets:
54+
# countly_token:
55+
# file: ./countly_token.txt
6056

61-
# Alternative configuration without secrets (development only)
62-
# Uncomment this and comment out the secrets section above
63-
# ---
64-
# version: '3.8'
65-
# services:
66-
# countly-mcp-server:
67-
# build:
68-
# context: .
69-
# dockerfile: Dockerfile
70-
# container_name: countly-mcp-server
71-
# restart: unless-stopped
72-
# environment:
73-
# - COUNTLY_SERVER_URL=https://api.count.ly
74-
# - COUNTLY_AUTH_TOKEN=your-token-here
75-
# - COUNTLY_TIMEOUT=30000
76-
# ports:
77-
# - "3000:3000"
57+
# For production with Docker Swarm:
58+
# 1. Uncomment the secrets sections above
59+
# 2. Create the secret: echo "your-token" | docker secret create countly_token -
60+
# 3. Change the secret config to: external: true

examples/vscode-mcp.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,17 @@ This example shows how to configure VS Code's MCP support to connect to Countly
5858
"countly": {
5959
"type": "sse",
6060
"url": "http://localhost:3000/mcp",
61-
"metadata": {
62-
"countlyAuthToken": "your-auth-token-here"
61+
"headers": {
62+
"X-Countly-Server-Url": "https://your-countly-instance.com",
63+
"X-Countly-Auth-Token": "your-auth-token-here"
6364
}
6465
}
6566
},
6667
"inputs": []
6768
}
6869
```
6970

70-
**Note**: The client can pass authentication via `metadata.countlyAuthToken`. The server will use this token to authenticate with your Countly instance.
71+
**Note**: The VS Code MCP extension passes credentials via HTTP headers (`X-Countly-Server-Url` and `X-Countly-Auth-Token`). This allows multiple users to connect to the same Docker instance with their own credentials.
7172

7273
**Method 3: Docker Container (stdio)**
7374

0 commit comments

Comments
 (0)