Skip to content

feat(mcp): add transport security configuration for remote access#1157

Open
Milofax wants to merge 1 commit intogetzep:mainfrom
Milofax:feat/mcp-transport-security
Open

feat(mcp): add transport security configuration for remote access#1157
Milofax wants to merge 1 commit intogetzep:mainfrom
Milofax:feat/mcp-transport-security

Conversation

@Milofax
Copy link
Contributor

@Milofax Milofax commented Jan 16, 2026

Summary

This PR adds support for configuring transport security settings (allowed hosts and origins) when deploying the MCP server behind a reverse proxy like Nginx, Traefik, or Caddy.

Problem: The MCP server returns "Invalid Host header" (421) errors when accessed via a custom domain because the MCP SDK's DNS rebinding protection only allows localhost by default.

Solution: Make allowed_hosts, allowed_origins, and enable_dns_rebinding_protection configurable via config.yaml.

Changes

  • Add transport security fields to ServerConfig schema (allowed_hosts, allowed_origins, enable_dns_rebinding_protection)
  • Add build_transport_security() helper function that creates TransportSecuritySettings from config
  • Integrate transport security configuration in server initialization via mcp.settings.transport_security
  • Update MCP SDK requirement to >=1.23.0 (required for TransportSecuritySettings support)
  • Add unit tests for transport security configuration
  • Document transport security options in README.md
  • Add commented example in config.yaml

Example Configuration

server:
  transport: http
  host: 0.0.0.0
  port: 8000
  
  # Transport security settings for remote access
  allowed_hosts:
    - "localhost:8000"
    - "graphiti.example.com"
  allowed_origins:
    - "http://localhost:3000"
    - "https://app.example.com"
  enable_dns_rebinding_protection: true  # Default: true

Test plan

  • Unit tests added for build_transport_security() function
  • Unit tests added for ServerConfig schema with new fields
  • Unit tests added for environment variable overrides
  • All existing tests pass (uv run python tests/test_configuration.py)
  • Manual testing with reverse proxy (Traefik)

Related

🤖 Generated with Claude Code

@Milofax
Copy link
Contributor Author

Milofax commented Mar 8, 2026

Friendly ping on this PR — adds transport security configuration for remote MCP access. Important for anyone running Graphiti MCP outside localhost. Happy to address any feedback!

Add support for configuring allowed hosts and origins when deploying
the MCP server behind a reverse proxy. This addresses the DNS rebinding
protection that causes "Invalid Host header" (421) errors when accessing
the server via a custom domain.

Changes:
- Add `allowed_hosts`, `allowed_origins`, and `enable_dns_rebinding_protection`
  fields to ServerConfig schema
- Add `build_transport_security()` helper function that creates
  TransportSecuritySettings from config
- Integrate transport security configuration in server initialization
- Update MCP SDK requirement to >=1.23.0 (TransportSecuritySettings support)
- Add unit tests for transport security configuration
- Document transport security options in README.md
- Add commented example in config.yaml

Fixes DNS rebinding protection issues (CVE-2025-66416) when running
behind Nginx, Traefik, Caddy, or other reverse proxies.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Milofax Milofax force-pushed the feat/mcp-transport-security branch from f482e1e to 5f2acce Compare March 8, 2026 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant