mirror of
https://github.com/shadoll/redmine-mcp.git
synced 2026-08-28 03:27:56 +00:00
feat: add MCP_ALLOWED_HOSTS support for reverse proxy configuration
This commit is contained in:
@@ -10,4 +10,5 @@ services:
|
||||
MCP_HOST: 0.0.0.0
|
||||
MCP_PORT: 8000
|
||||
MCP_AUTH_TOKEN: ${MCP_AUTH_TOKEN:-}
|
||||
MCP_ALLOWED_HOSTS: ${MCP_ALLOWED_HOSTS:-}
|
||||
restart: on-failure
|
||||
|
||||
@@ -12,4 +12,7 @@ stringData:
|
||||
{{- if .Values.auth.token }}
|
||||
MCP_AUTH_TOKEN: {{ .Values.auth.token | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.auth.allowedHosts }}
|
||||
MCP_ALLOWED_HOSTS: {{ .Values.auth.allowedHosts | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
@@ -15,6 +15,9 @@ redmine:
|
||||
auth:
|
||||
# Bearer token for HTTP transport (leave empty to disable auth)
|
||||
token: ""
|
||||
# Comma-separated list of additional allowed Host headers (e.g. your public domain)
|
||||
# FastMCP allows only localhost by default — set this when running behind a reverse proxy
|
||||
allowedHosts: ""
|
||||
|
||||
service:
|
||||
type: ClusterIP
|
||||
|
||||
@@ -9,6 +9,8 @@ Environment variables:
|
||||
MCP_HOST — bind host for HTTP transport (default: 0.0.0.0)
|
||||
MCP_PORT — bind port for HTTP transport (default: 8000)
|
||||
MCP_AUTH_TOKEN — Bearer token for HTTP transport auth (optional)
|
||||
MCP_ALLOWED_HOSTS — Comma-separated extra allowed Host headers, e.g. redmine.mcp.example.com
|
||||
(FastMCP only allows localhost by default — required when behind a reverse proxy)
|
||||
"""
|
||||
|
||||
import os
|
||||
@@ -24,6 +26,11 @@ if __name__ == "__main__":
|
||||
port = int(os.environ.get("MCP_PORT", "8000"))
|
||||
token = os.environ.get("MCP_AUTH_TOKEN", "")
|
||||
|
||||
allowed_hosts = os.environ.get("MCP_ALLOWED_HOSTS", "")
|
||||
if allowed_hosts:
|
||||
for h in (h.strip() for h in allowed_hosts.split(",")):
|
||||
mcp.settings.transport_security.allowed_hosts.append(h)
|
||||
|
||||
app = mcp.streamable_http_app()
|
||||
|
||||
if token:
|
||||
|
||||
Reference in New Issue
Block a user