Skip to content

Commit add2e3d

Browse files
authored
Add time server to compose closes #403 (#637)
Signed-off-by: Mihai Criveti <[email protected]>
1 parent ed6a0af commit add2e3d

File tree

1 file changed

+80
-1
lines changed

1 file changed

+80
-1
lines changed

docker-compose.yml

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "3.9" # Supported by both podman-compose and Docker Compose v2+
1+
#version: "3.9" # Supported by both podman-compose and Docker Compose v2+
22

33
###############################################################################
44
# NETWORKS + VOLUMES - declared first so they can be referenced later
@@ -294,8 +294,87 @@ services:
294294
# mysql:
295295
# condition: service_started
296296

297+
297298
###############################################################################
298299
# OPTIONAL MCP SERVERS - drop-in helpers the Gateway can call
300+
###############################################################################
301+
302+
###############################################################################
303+
# Fast Time Server - High-performance time/timezone service for MCP
304+
###############################################################################
305+
fast_time_server:
306+
image: ghcr.io/ibm/fast-time-server:latest
307+
restart: unless-stopped
308+
networks: [mcpnet]
309+
ports:
310+
- "8888:8080" # Map host port 8888 to container port 8080
311+
command: ["-transport=sse", "-listen=0.0.0.0", "-port=8080", "-log-level=info"]
312+
313+
###############################################################################
314+
# Auto-registration service - registers fast_time_server with gateway
315+
###############################################################################
316+
register_fast_time:
317+
image: python:3.11-slim
318+
networks: [mcpnet]
319+
depends_on:
320+
gateway:
321+
condition: service_healthy
322+
fast_time_server:
323+
condition: service_started
324+
environment:
325+
- JWT_SECRET_KEY=my-test-key
326+
# This is a one-shot container that exits after registration
327+
restart: "no"
328+
entrypoint: ["/bin/sh", "-c"]
329+
command:
330+
- |
331+
echo "Installing MCP Context Forge Gateway..."
332+
pip install --quiet mcp-contextforge-gateway
333+
334+
echo "Installing curl..."
335+
apt-get update -qq && apt-get install -y -qq curl
336+
337+
echo "Waiting for services to be ready..."
338+
# Wait for fast_time_server to be ready
339+
for i in {1..30}; do
340+
if curl -s -f http://fast_time_server:8080/health > /dev/null 2>&1; then
341+
echo "✅ fast_time_server is healthy"
342+
break
343+
fi
344+
echo "Waiting for fast_time_server... ($$i/30)"
345+
sleep 2
346+
done
347+
348+
echo "Generating JWT token..."
349+
export MCPGATEWAY_BEARER_TOKEN=$$(python3 -m mcpgateway.utils.create_jwt_token -u admin --secret my-test-key)
350+
351+
echo "Registering fast_time_server with gateway..."
352+
RESPONSE=$$(curl -s -X POST http://gateway:4444/gateways \
353+
-H "Authorization: Bearer $$MCPGATEWAY_BEARER_TOKEN" \
354+
-H "Content-Type: application/json" \
355+
-d '{"name":"fast_time","url":"http://fast_time_server:8080/sse"}')
356+
357+
echo "Registration response: $$RESPONSE"
358+
359+
# Check if registration was successful
360+
if echo "$$RESPONSE" | grep -q '"id"'; then
361+
echo "✅ Successfully registered fast_time_server"
362+
363+
# Optional: Create a virtual server with the time tools
364+
echo "Creating virtual server..."
365+
curl -s -X POST http://gateway:4444/servers \
366+
-H "Authorization: Bearer $$MCPGATEWAY_BEARER_TOKEN" \
367+
-H "Content-Type: application/json" \
368+
-d '{"name":"time_server","description":"Fast time tools","associatedTools":["1","2"]}' || true
369+
370+
echo "✅ Setup complete!"
371+
else
372+
echo "❌ Registration failed"
373+
exit 1
374+
fi
375+
376+
###############################################################################
377+
# OTHER MCP SERVERS - drop-in helpers the Gateway can call (not implemented yet)
299378
# ###############################################################################
300379
# mcp_time:
301380
# image: mcp/time:latest

0 commit comments

Comments
 (0)