fix: disable localhost Host protection behind Caddy

Public MCP requests arrive with Host mcp.verae.ai while the process binds
127.0.0.1; the go-sdk default rejected those with 403.
This commit is contained in:
George Lambert 2026-09-29 12:18:06 -04:00
commit 00f5d18364

View file

@ -67,11 +67,14 @@ func New(opts Options) (*Server, error) {
RequireBearer: opts.RequireBearer, RequireBearer: opts.RequireBearer,
} }
mcpServer := tools.NewServer(deps) mcpServer := tools.NewServer(deps)
// Behind Caddy (or any reverse proxy) the bind is loopback while Host is
// the public name (mcp.verae.ai). Disable the SDK's localhost Host check.
stream := mcp.NewStreamableHTTPHandler(func(*http.Request) *mcp.Server { stream := mcp.NewStreamableHTTPHandler(func(*http.Request) *mcp.Server {
return mcpServer return mcpServer
}, &mcp.StreamableHTTPOptions{ }, &mcp.StreamableHTTPOptions{
JSONResponse: opts.JSONResponse, JSONResponse: opts.JSONResponse,
Stateless: opts.Stateless, Stateless: opts.Stateless,
DisableLocalhostProtection: true,
}) })
mux := http.NewServeMux() mux := http.NewServeMux()