Detailed explanation of mcp-gateway.yaml configuration file
Configuration files support using ${VAR:default}
syntax for environment variable injection. If environment variables are not set, default values will be used.
A common practice is to inject through different .env
, .env.development
, .env.prod
files, though you can also directly modify the configuration to hardcode a value.
The PID here should be consistent with the PIDs mentioned below, used for service management and hot reload functionality.
The storage configuration module is mainly used to store gateway proxy configuration information. Currently supports two storage methods:
Configurations are stored as files on disk, with each configuration as a separate file, similar to nginx vhost
Store in database, each configuration is a record, supports SQLite3, PostgreSQL, MySQL
The notification configuration module is mainly used to let mcp-gateway
detect updates and perform hot reloads without restarting the service when configuration updates occur.
Notify by sending operating system signals, similar to kill -SIGHUP <pid>
or nginx -s reload
Notify by calling an API, mcp-gateway
will listen on an independent port
Notify through redis publish/subscribe functionality, suitable for single machine or cluster deployment
Composite notification, combining multiple methods, signal
and api
are always enabled by default
sender
Responsible for sending notifications, apiserver
can only use this mode
receiver
Responsible for receiving notifications, standalone mcp-gateway
is recommended to use only this mode
both
Both sender and receiver, cluster deployed mcp-gateway
can use this approach
Session storage configuration is used to store session information in MCP. Different storage methods can be chosen based on different deployment scenarios:
Memory storage, suitable for single machine deployment (note: restart will lose session information)
Redis storage, suitable for single machine or cluster deployment, supports persistence
When using memory storage, service restart will cause all session information to be lost. Redis storage is recommended for production environments.
The forward headers configuration allows the MCP Gateway to forward HTTP headers from client requests to downstream services. This feature is useful for authentication, request tracing, and custom header propagation.
Forward headers functionality is disabled by default for backward compatibility. Enable it by setting enabled: true
in the configuration.
Control which headers are forwarded using allow/ignore lists with case-insensitive matching
Forward headers from client requests (tools/list and tools/call) to downstream services
Support forwarding headers passed as tool arguments via configurable parameter names
Choose whether to override existing headers or add to them
The filtering logic follows a priority-based approach:
Priority Check
If allow_headers
is configured (non-empty), it takes priority and ignore_headers
is completely ignored
Allow List Mode
When allow_headers
is set, only headers in this list are forwarded, all others are ignored
Ignore List Mode
When allow_headers
is empty, headers in ignore_headers
list are filtered out, others are forwarded
Case Sensitivity
Header matching respects the case_insensitive
setting for both allow and ignore lists
Result: Only Authorization
, X-API-Key
, and X-Request-ID
headers are forwarded.
Result: All headers except Accept
, Host
, Cookie
, and User-Agent
are forwarded.
Tools can now pass headers via the custom_headers
argument:
All forward headers settings can be configured via environment variables:
When enabling forward headers in production, carefully review which headers should be forwarded to avoid security risks such as exposing sensitive authentication tokens or cookies.
By default, configuration files should be placed in the following locations:
/app/configs/mcp-gateway.yaml
./configs/mcp-gateway.yaml
MCP Gateway supports hot reload configuration, allowing new configurations to be applied without restarting the service:
Configuration Update Detection
When configuration changes occur, reload is triggered through configured notification methods (signal, api, redis)
Configuration Validation
Before reloading, the validity of the new configuration is verified to ensure stable service operation
Smooth Transition
After validation passes, smoothly switch to the new configuration without interrupting ongoing connections
Single Machine Deployment
db
with SQLitecomposite
or signal
memory
or redis
Cluster Deployment
db
with PostgreSQL or MySQLredis
or composite
redis
Production Environment