Skip to content

Commit 83bf6f9

Browse files
authored
feat: add Docker support with HTTP/SSE transport (#50)
* feat: add Docker support with HTTP/SSE transport Add Docker container that exposes the MCP server over HTTP using mcp-proxy. Supports both streamable HTTP (/mcp) and SSE (/sse) transports. Publishes to GHCR on release. * fix: run container as non-root user for security Add mcpuser non-root user following security best practices.
1 parent 9603b67 commit 83bf6f9

3 files changed

Lines changed: 113 additions & 0 deletions

File tree

.github/workflows/cicd.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,45 @@ jobs:
238238
run: |
239239
npm set //npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}
240240
npm publish --registry https://npm.pkg.github.com
241+
242+
release-mcp-docker:
243+
name: Release MCP Server Docker Image
244+
needs: [release]
245+
if: ${{ needs.release.outputs.released }}
246+
runs-on: ubuntu-24.04
247+
permissions:
248+
contents: read
249+
packages: write
250+
defaults:
251+
run:
252+
working-directory: ./mcp/ai-developer-guide-mcp
253+
steps:
254+
- name: Checkout
255+
uses: actions/checkout@v4
256+
257+
- name: Set up Docker Buildx
258+
uses: docker/setup-buildx-action@v3
259+
260+
- name: Log in to GitHub Container Registry
261+
uses: docker/login-action@v3
262+
with:
263+
registry: ghcr.io
264+
username: ${{ github.actor }}
265+
password: ${{ secrets.GITHUB_TOKEN }}
266+
267+
- name: Extract version from tag
268+
id: version
269+
run: |
270+
VERSION=${{ needs.release.outputs.tag }}
271+
echo "version=${VERSION#v}" >> $GITHUB_OUTPUT
272+
273+
- name: Build and push Docker image
274+
uses: docker/build-push-action@v6
275+
with:
276+
context: ./mcp/ai-developer-guide-mcp
277+
push: true
278+
tags: |
279+
ghcr.io/${{ github.repository_owner }}/ai-developer-guide-mcp:${{ steps.version.outputs.version }}
280+
ghcr.io/${{ github.repository_owner }}/ai-developer-guide-mcp:latest
281+
cache-from: type=gha
282+
cache-to: type=gha,mode=max
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FROM node:24-slim AS builder
2+
3+
WORKDIR /app
4+
5+
# Copy package files
6+
COPY package*.json ./
7+
8+
# Install all dependencies (including dev for build)
9+
RUN npm ci
10+
11+
# Copy source and build
12+
COPY . .
13+
RUN npm run build
14+
15+
# Production image
16+
FROM node:24-slim
17+
18+
# Create non-root user
19+
RUN groupadd -r mcpuser && useradd -r -g mcpuser mcpuser
20+
21+
WORKDIR /app
22+
23+
# Copy package files
24+
COPY package*.json ./
25+
26+
# Install only production dependencies
27+
RUN npm ci --omit=dev
28+
29+
# Copy built application from builder
30+
COPY --from=builder /app/dist ./dist
31+
32+
# Install mcp-proxy globally for HTTP/SSE transport
33+
RUN npm install -g mcp-proxy
34+
35+
# Change ownership to non-root user
36+
RUN chown -R mcpuser:mcpuser /app
37+
38+
# Switch to non-root user
39+
USER mcpuser
40+
41+
# Expose HTTP port
42+
EXPOSE 8080
43+
44+
# Use mcp-proxy to expose over HTTP (both /mcp streamable and /sse endpoints)
45+
ENTRYPOINT ["mcp-proxy", "--port", "8080", "--host", "0.0.0.0", "--shell", "node dist/cli.js"]

mcp/ai-developer-guide-mcp/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ A simple MCP server that connects your LLM to the developer guide:
2828
- [Example LLM Interactions](#example-llm-interactions)
2929
- [Configuration](#configuration)
3030
- [API Requirements](#api-requirements)
31+
- [Running in Docker](#running-in-docker)
3132

3233
<!-- vim-markdown-toc -->
3334

@@ -224,3 +225,28 @@ You can configure your MCP server using these parameters:
224225
## API Requirements
225226

226227
The API structure should match the [AI Developer Guide API format](https://dwmkerr.github.io/ai-developer-guide/api.json).
228+
229+
## Running in Docker
230+
231+
You can run the MCP server in Docker to expose it over HTTP:
232+
233+
```bash
234+
# Pull and run from GitHub Container Registry.
235+
docker run -p 8080:8080 ghcr.io/dwmkerr/ai-developer-guide-mcp:latest
236+
237+
# Or build locally.
238+
docker build -t ai-developer-guide-mcp ./ai-developer-guide-mcp
239+
docker run -p 8080:8080 ai-developer-guide-mcp
240+
241+
# Test with MCP inspector (streamable HTTP or SSE endpoints).
242+
npx @modelcontextprotocol/inspector http://localhost:8080/mcp # recommended
243+
npx @modelcontextprotocol/inspector http://localhost:8080/sse # deprecated
244+
```
245+
246+
Optionally configure a custom guide URL:
247+
248+
```bash
249+
docker run -p 8080:8080 \
250+
-e AI_DEVELOPER_GUIDE_URL=https://your-domain.com/your-guide \
251+
ghcr.io/dwmkerr/ai-developer-guide-mcp:latest
252+
```

0 commit comments

Comments
 (0)