Skip to main content
Glama
update_nginx_mcp.shβ€’2.73 kB
#!/bin/bash # Script to add MCP HTTP/SSE endpoint to nginx configuration set -e echo "πŸ“ Updating nginx configuration for MCP HTTP/SSE..." # Backup current config (on host, not in container) docker exec swissknife-nginx cat /etc/nginx/conf.d/ssl.conf > /tmp/ssl.conf.backup-mcp-$(date +%Y%m%d-%H%M%S) echo "βœ… Backup saved to /tmp/ssl.conf.backup-mcp-$(date +%Y%m%d-%H%M%S)" # Create temporary file with MCP block cat > /tmp/mcp_block.conf << 'EOF' # MCP HTTP/SSE Server - porta 8001 location /mcp/ { set $upstream_runtime 172.19.0.1:8001; proxy_pass http://$upstream_runtime/mcp/; # Basic proxy headers proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # WebSocket and SSE support proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; # SSE specific settings proxy_buffering off; proxy_cache off; proxy_read_timeout 86400; chunked_transfer_encoding off; # CORS headers (for MCP clients) add_header Access-Control-Allow-Origin * always; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always; add_header Access-Control-Allow-Headers "Content-Type, Authorization" always; # Handle preflight if ($request_method = OPTIONS) { return 204; } # Timeout settings proxy_connect_timeout 60s; proxy_send_timeout 300s; proxy_read_timeout 86400s; } EOF # Get current config docker exec swissknife-nginx cat /etc/nginx/conf.d/ssl.conf > /tmp/ssl.conf # Insert MCP block before the closing brace of trustypa server block # Find line with "# OAuth Server - porta 8000" and insert before it awk ' /# OAuth Server - porta 8000/ { while ((getline line < "/tmp/mcp_block.conf") > 0) { print line } close("/tmp/mcp_block.conf") } { print } ' /tmp/ssl.conf > /tmp/ssl_with_mcp.conf # Copy updated config to container docker cp /tmp/ssl_with_mcp.conf swissknife-nginx:/etc/nginx/conf.d/ssl.conf echo "πŸ” Testing nginx configuration..." docker exec swissknife-nginx nginx -t echo "♻️ Reloading nginx..." docker exec swissknife-nginx nginx -s reload echo "βœ… Nginx configuration updated successfully!" echo "" echo "πŸ§ͺ Test MCP endpoints:" echo " curl https://trustypa.brainaihub.tech/mcp/health" echo " curl -N https://trustypa.brainaihub.tech/mcp/sse" # Cleanup rm -f /tmp/mcp_block.conf /tmp/ssl.conf /tmp/ssl_with_mcp.conf

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ilvolodel/iris-legacy'

If you have feedback or need assistance with the MCP directory API, please join our Discord server