Skip to content

Commit 60b7f14

Browse files
authored
Merge pull request #19 from Countly/ar2rsawseen/main
Fix publishing
2 parents 5105f84 + e0758a7 commit 60b7f14

File tree

4 files changed

+235
-136
lines changed

4 files changed

+235
-136
lines changed

.github/workflows/docker-publish.yml

Lines changed: 0 additions & 83 deletions
This file was deleted.

.github/workflows/npm-publish.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
name: Release (npm & Docker)
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version to release (e.g., 1.0.1)'
11+
required: true
12+
type: string
13+
publish-npm:
14+
description: 'Publish to npm'
15+
required: false
16+
type: boolean
17+
default: true
18+
publish-docker:
19+
description: 'Publish to Docker Hub'
20+
required: false
21+
type: boolean
22+
default: true
23+
24+
env:
25+
DOCKER_IMAGE: countly/countly-mcp-server
26+
DOCKERHUB_USERNAME: countly
27+
28+
permissions:
29+
id-token: write # Required for npm OIDC
30+
contents: read
31+
32+
jobs:
33+
test-and-build:
34+
runs-on: ubuntu-latest
35+
name: Test & Build
36+
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v5
40+
41+
- name: Setup Node.js
42+
uses: actions/setup-node@v6
43+
with:
44+
node-version: '20.x'
45+
cache: 'npm'
46+
47+
- name: Install dependencies
48+
run: npm ci
49+
50+
- name: Build project
51+
run: npm run build
52+
53+
- name: Run tests (with transport integration tests)
54+
run: npm run test:ci
55+
env:
56+
COUNTLY_SERVER_URL: https://test.count.ly
57+
COUNTLY_AUTH_TOKEN: test-token-for-ci
58+
59+
- name: Upload build artifacts
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: build
63+
path: build/
64+
retention-days: 1
65+
66+
publish-npm:
67+
runs-on: ubuntu-latest
68+
needs: test-and-build
69+
name: Publish to npm
70+
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.publish-npm)
71+
72+
steps:
73+
- name: Checkout code
74+
uses: actions/checkout@v5
75+
76+
- name: Set up Node.js
77+
uses: actions/setup-node@v6
78+
with:
79+
node-version: '20.x'
80+
registry-url: 'https://registry.npmjs.org/'
81+
cache: 'npm'
82+
83+
- name: Install dependencies
84+
run: npm ci
85+
86+
- name: Download build artifacts
87+
uses: actions/download-artifact@v4
88+
with:
89+
name: build
90+
path: build/
91+
92+
- name: Update package.json version (manual trigger only)
93+
if: github.event_name == 'workflow_dispatch'
94+
run: npm version ${{ inputs.version }} --no-git-tag-version
95+
96+
- name: Publish to npm
97+
run: npm publish --access public
98+
env:
99+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
100+
101+
publish-docker:
102+
runs-on: ubuntu-latest
103+
needs: test-and-build
104+
name: Build & Push Docker Image
105+
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.publish-docker)
106+
107+
steps:
108+
- name: Checkout code
109+
uses: actions/checkout@v5
110+
111+
- name: Set up QEMU
112+
uses: docker/setup-qemu-action@v3
113+
114+
- name: Set up Docker Buildx
115+
uses: docker/setup-buildx-action@v3
116+
117+
- name: Extract version from tag or input
118+
id: meta
119+
run: |
120+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
121+
VERSION="${{ inputs.version }}"
122+
elif [[ "$GITHUB_REF" == refs/tags/v* ]]; then
123+
VERSION=${GITHUB_REF#refs/tags/v}
124+
else
125+
VERSION="dev-${GITHUB_SHA::8}"
126+
fi
127+
echo "version=$VERSION" >> $GITHUB_OUTPUT
128+
echo "Building version: $VERSION"
129+
130+
- name: Log in to Docker Hub
131+
uses: docker/login-action@v3
132+
with:
133+
username: ${{ env.DOCKERHUB_USERNAME }}
134+
password: ${{ secrets.DOCKERHUB_TOKEN }}
135+
136+
- name: Build and push Docker image
137+
uses: docker/build-push-action@v6
138+
with:
139+
context: .
140+
platforms: linux/amd64,linux/arm64
141+
push: true
142+
tags: |
143+
${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}
144+
${{ env.DOCKER_IMAGE }}:latest
145+
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE }}:buildcache
146+
cache-to: type=registry,ref=${{ env.DOCKER_IMAGE }}:buildcache,mode=max
147+
labels: |
148+
org.opencontainers.image.source=${{ github.event.repository.html_url }}
149+
org.opencontainers.image.version=${{ steps.meta.outputs.version }}
150+
org.opencontainers.image.created=${{ github.event.head_commit.timestamp }}
151+
org.opencontainers.image.revision=${{ github.sha }}
152+
153+
- name: Update Docker Hub description
154+
uses: peter-evans/dockerhub-description@v4
155+
with:
156+
username: ${{ env.DOCKERHUB_USERNAME }}
157+
password: ${{ secrets.DOCKERHUB_TOKEN }}
158+
repository: ${{ env.DOCKER_IMAGE }}
159+
readme-filepath: ./DOCKER.md
160+
short-description: "MCP server for Countly Analytics - Access 40+ analytics tools via Model Context Protocol"

CHANGELOG.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [1.0.1] - 2025-11-07
9+
10+
### Added
11+
- **Transport Integration Tests**: Added comprehensive integration tests for both stdio and HTTP/SSE transports (`tests/transport.test.ts`)
12+
- 13 new tests covering initialization, tool listing, health checks, CORS, and SSE streaming
13+
- Tests validate both stdio and HTTP/SSE transport modes work correctly
14+
- **HTTP Header Authentication**: Added support for passing Countly credentials via custom HTTP headers
15+
- `X-Countly-Server-Url` header for specifying server URL
16+
- `X-Countly-Auth-Token` header for authentication token
17+
- Headers are extracted and applied dynamically per request
18+
- **npm Publishing Workflow**: Added GitHub Actions workflow for automated npm package publishing on version tags
19+
20+
### Changed
21+
- **Upgraded Transport Layer**: Migrated from deprecated `SSEServerTransport` to modern `StreamableHTTPServerTransport`
22+
- Uses MCP protocol version 2025-03-26 (Streamable HTTP specification)
23+
- Operates in stateless mode (`sessionIdGenerator: undefined`) for better client compatibility
24+
- Eliminates "legacy SSE" warnings in VS Code and other MCP clients
25+
- **Enhanced Authentication Flexibility**:
26+
- Server URL is now optional in environment variables - can be provided via HTTP headers or client configuration
27+
- Credentials fallback logic: metadata → args → config (from headers) → environment → file
28+
- `getCredentials()` method now checks `this.config.authToken` as fallback (set from HTTP headers)
29+
- **Docker Configuration Improvements**:
30+
- Updated documentation to reflect environment-based configuration
31+
- Enhanced Dockerfile with proper build stages and health checks
32+
- **Documentation Updates**:
33+
- Updated `.env.example` with clearer instructions for HTTP header-based authentication
34+
- Enhanced `README.md` with transport configuration examples
35+
- Updated `DOCKER.md` with secure configuration practices
36+
- Updated VS Code MCP integration example (`examples/vscode-mcp.md`)
37+
38+
### Fixed
39+
- **Security: ReDoS Vulnerability**: Fixed Regular Expression Denial of Service (ReDoS) vulnerability in URL normalization
40+
- Replaced regex `/\/+$/` with iterative `while` loop approach
41+
- Prevents potential DoS attacks via maliciously crafted URLs
42+
- Applied fix in both `src/index.ts` and `src/lib/config.ts`
43+
- **Test Suite Improvements**:
44+
- Updated authentication tests to reflect new priority order
45+
- Fixed test expectations for optional server URL configuration
46+
- Updated error messages in tests to match new authentication flow
47+
48+
### Security
49+
- **ReDoS Mitigation**: Fixed Regular Expression Denial of Service vulnerability in URL normalization (CodeQL alert)
50+
51+
## [1.0.0] - 2025-10-29
52+
53+
Initial release of Countly MCP Server.
54+
55+
### Features
56+
- Model Context Protocol (MCP) server for Countly analytics platform
57+
- Support for stdio and HTTP/SSE transport layers
58+
- Comprehensive Countly API integration:
59+
- Analytics data retrieval (sessions, users, locations, events, etc.)
60+
- Crash analytics
61+
- App management
62+
- Dashboard users management
63+
- Alerts configuration
64+
- Notes management
65+
- Views analytics
66+
- Database operations
67+
- Event management
68+
- App user management
69+
- Environment-based configuration
70+
- Docker support with multi-architecture builds
71+
- Comprehensive test suite
72+
- GitHub Actions CI/CD integration
73+
74+
[1.0.1]: https://github.com/Countly/countly-mcp-server/compare/v1.0.0...v1.0.1
75+
[1.0.0]: https://github.com/Countly/countly-mcp-server/releases/tag/v1.0.0

0 commit comments

Comments
 (0)