Skip to content

Commit d1148f7

Browse files
committed
docs: add demo Docker support and configuration files
1 parent 0a9f3a8 commit d1148f7

File tree

7 files changed

+118
-8
lines changed

7 files changed

+118
-8
lines changed

.env.example

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copy this file to .env and fill in your values
2+
3+
# OAuth Provider Credentials
4+
GOOGLE_CLIENT_ID=your-google-client-id
5+
GOOGLE_CLIENT_SECRET=your-google-client-secret
6+
7+
# Optional: GitHub OAuth (if using GitHub instead)
8+
# GITHUB_CLIENT_ID=your-github-client-id
9+
# GITHUB_CLIENT_SECRET=your-github-client-secret
10+
11+
# Session Secret (generate a secure random string)
12+
SESSION_SECRET=change-this-to-a-secure-random-string
13+
14+
# Redis Password (for production, use a secure password)
15+
REDIS_PASSWORD=mypassword

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ data/
341341
!config/*.example.yaml
342342
!config/*.example.yml
343343
!config.example.yaml
344+
!config.docker.yaml
344345
!.github/workflows/*.yml
345346

346347
# =============================================================================

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,23 @@ Services can use these headers for:
235235
236236
## Docker Deployment
237237
238-
### Quick Start with Memory Storage
238+
### Pre-built Image (Recommended)
239+
240+
Use the pre-built Docker image from GitHub Container Registry:
241+
242+
```bash
243+
# Run with memory storage (development)
244+
docker run -p 8080:8080 \
245+
-v $(pwd)/config.yaml:/app/config.yaml \
246+
-e GOOGLE_CLIENT_ID="your-google-client-id" \
247+
-e GOOGLE_CLIENT_SECRET="your-google-client-secret" \
248+
ghcr.io/akshay5995/mcp-oauth-gateway:latest
249+
```
250+
251+
### Build from Source
239252

240253
```bash
241-
# Build image
254+
# Build image locally
242255
docker build -t mcp-oauth-gateway .
243256

244257
# Run with memory storage (development)
@@ -273,7 +286,7 @@ docker run -p 8080:8080 \
273286
-e GOOGLE_CLIENT_ID="your-google-client-id" \
274287
-e GOOGLE_CLIENT_SECRET="your-google-client-secret" \
275288
-e REDIS_PASSWORD="mypassword" \
276-
mcp-oauth-gateway
289+
ghcr.io/akshay5995/mcp-oauth-gateway:latest
277290
```
278291

279292
### Enterprise with Vault Storage
@@ -302,7 +315,7 @@ docker run -p 8080:8080 \
302315
-e GOOGLE_CLIENT_ID="your-google-client-id" \
303316
-e GOOGLE_CLIENT_SECRET="your-google-client-secret" \
304317
-e VAULT_TOKEN="myroot" \
305-
mcp-oauth-gateway
318+
ghcr.io/akshay5995/mcp-oauth-gateway:latest
306319
```
307320

308321
### Docker Compose Example
@@ -312,7 +325,7 @@ docker run -p 8080:8080 \
312325
version: '3.8'
313326
services:
314327
mcp-gateway:
315-
build: .
328+
image: ghcr.io/akshay5995/mcp-oauth-gateway:latest
316329
ports:
317330
- "8080:8080"
318331
volumes:

config.docker.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# MCP OAuth Gateway Configuration for Docker Compose
2+
# This config uses Docker service names for inter-container communication
3+
4+
# Gateway settings
5+
host: "0.0.0.0"
6+
port: 8080
7+
issuer: "http://localhost:8080" # This stays as localhost for external access
8+
session_secret: "${SESSION_SECRET:-change-this-secret-key-in-production}"
9+
debug: false
10+
11+
# Storage backend configuration
12+
storage:
13+
type: "redis" # Using Redis in Docker Compose
14+
15+
redis:
16+
host: redis # Docker service name, not localhost!
17+
port: 6379
18+
password: "${REDIS_PASSWORD:-mypassword}"
19+
db: 0
20+
ssl: false
21+
max_connections: 10
22+
socket_timeout: 5.0
23+
24+
# OAuth providers for user authentication
25+
oauth_providers:
26+
google:
27+
client_id: "${GOOGLE_CLIENT_ID}"
28+
client_secret: "${GOOGLE_CLIENT_SECRET}"
29+
scopes:
30+
- "openid"
31+
- "email"
32+
- "profile"
33+
34+
# MCP services to proxy
35+
mcp_services:
36+
calculator:
37+
name: "Calculator Service"
38+
url: "http://calculator-service:3001/mcp/" # Docker service name!
39+
oauth_provider: "google"
40+
auth_required: true
41+
scopes:
42+
- "read"
43+
- "calculate"
44+
timeout: 30000
45+
46+
# Optional: If you have services running on the host machine
47+
# host_service:
48+
# name: "Host Service"
49+
# url: "http://host.docker.internal:3002/mcp/" # For Mac/Windows
50+
# oauth_provider: "google"
51+
# auth_required: true
52+
# scopes:
53+
# - "read"
54+
# timeout: 30000

demo/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Dockerfile for FastMCP Calculator Demo Service
2+
FROM python:3.11-slim
3+
4+
# Set working directory
5+
WORKDIR /app
6+
7+
# Install dependencies
8+
COPY requirements.txt .
9+
RUN pip install --no-cache-dir -r requirements.txt
10+
11+
# Copy application code
12+
COPY fastmcp_server.py .
13+
14+
# Expose port
15+
EXPOSE 3001
16+
17+
# Run the FastMCP server
18+
CMD ["python", "fastmcp_server.py"]

demo/fastmcp_server.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def get_user_email(ctx: Context) -> str:
3434
3535

3636

37-
mcp = FastMCP(name="CalculatorServer")
37+
# For Docker containers, specify host settings
38+
mcp = FastMCP(name="CalculatorServer", host="0.0.0.0")
3839
mcp.add_middleware(UserAuthMiddleware())
3940

4041

@@ -53,4 +54,11 @@ def multiply(a: int, b: int, ctx: Context) -> int:
5354

5455

5556
if __name__ == "__main__":
56-
mcp.run(transport="http", port=3001, log_level="info")
57+
# For Docker containers, specify host explicitly and use the /mcp/ path
58+
mcp.run(
59+
transport="http",
60+
host="0.0.0.0", # Critical for Docker - bind to all interfaces
61+
port=3001,
62+
path="/mcp/", # FastMCP serves at /mcp/ path by default
63+
log_level="debug"
64+
)

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ services:
77
# MCP OAuth Gateway
88
mcp-gateway:
99
build: .
10+
command: ["--config", "/app/config.yaml"]
1011
ports:
1112
- "8080:8080"
1213
volumes:
13-
- ./config.yaml:/app/config.yaml
14+
- ./config.docker.yaml:/app/config.yaml
1415
environment:
1516
# OAuth Provider (choose one)
1617
- GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}

0 commit comments

Comments
 (0)