|
1 | 1 | # mcp-gateway.yaml |
2 | 2 |
|
3 | | -**Work in progress — fueled by caffeine and optimism...** |
| 3 | +Configuration files support environment variable injection using the `${VAR:default}` syntax. If the environment variable is not set, the default value will be used. |
4 | 4 |
|
5 | | -👇👇👇👇👇👇 If you would like to help improve this documentation, feel free to contribute. Thank you so much ❤️ |
| 5 | +Common practice is to inject through different `.env`, `.env.development`, `.env.prod` files, or you can directly modify the configuration with a fixed value. |
| 6 | + |
| 7 | +## Basic Configuration |
| 8 | + |
| 9 | +```yaml |
| 10 | +port: ${MCP_GATEWAY_PORT:5235} # Service listening port |
| 11 | +pid: "${MCP_GATEWAY_PID:/var/run/mcp-gateway.pid}" # PID file path |
| 12 | +``` |
| 13 | +
|
| 14 | +> The PID here should be consistent with the PID mentioned below |
| 15 | +
|
| 16 | +## Storage Configuration |
| 17 | +
|
| 18 | +The storage configuration module is mainly used to store gateway proxy configuration information. Currently supports two storage methods: |
| 19 | +- disk: Configurations are stored as files on disk, with each configuration in a separate file, similar to nginx's vhost concept, e.g., `svc-a.yaml`, `svc-b.yaml` |
| 20 | +- db: Store in database, with each configuration as a record. Currently supports three databases: |
| 21 | + - SQLite3 |
| 22 | + - PostgreSQL |
| 23 | + - MySQL |
| 24 | + |
| 25 | +```yaml |
| 26 | +storage: |
| 27 | + type: "${GATEWAY_STORAGE_TYPE:db}" # Storage type: db, disk |
| 28 | + |
| 29 | + # Database configuration (used when type is 'db') |
| 30 | + database: |
| 31 | + type: "${GATEWAY_DB_TYPE:sqlite}" # Database type (sqlite, postgres, mysql) |
| 32 | + host: "${GATEWAY_DB_HOST:localhost}" # Database host address |
| 33 | + port: ${GATEWAY_DB_PORT:5432} # Database port |
| 34 | + user: "${GATEWAY_DB_USER:postgres}" # Database username |
| 35 | + password: "${GATEWAY_DB_PASSWORD:example}" # Database password |
| 36 | + dbname: "${GATEWAY_DB_NAME:./data/mcp-gateway.db}" # Database name or file path |
| 37 | + sslmode: "${GATEWAY_DB_SSL_MODE:disable}" # Database SSL mode |
| 38 | + |
| 39 | + # Disk configuration (used when type is 'disk') |
| 40 | + disk: |
| 41 | + path: "${GATEWAY_STORAGE_DISK_PATH:}" # Data file storage path |
| 42 | +``` |
| 43 | + |
| 44 | +## Notifier Configuration |
| 45 | + |
| 46 | +The notifier configuration module is used to notify `mcp-gateway` of configuration updates and trigger hot reload without restarting the service. |
| 47 | + |
| 48 | +Currently supports four notification methods: |
| 49 | +- signal: Notify through operating system signals, similar to `kill -SIGHUP <pid>` or `nginx -s reload`, can be called via `mcp-gateway reload` command, suitable for single-machine deployment |
| 50 | +- api: Notify through API calls, `mcp-gateway` listens on a separate port and performs hot reload when receiving requests, can be called directly via `curl http://localhost:5235/_reload`, suitable for both single-machine and cluster deployment |
| 51 | +- redis: Notify through Redis pub/sub functionality, suitable for both single-machine and cluster deployment |
| 52 | +- composite: Combined notification, using multiple methods, with `signal` and `api` enabled by default, can be combined with other methods. Suitable for both single-machine and cluster deployment, recommended as the default method |
| 53 | + |
| 54 | +Notification roles: |
| 55 | +- sender: Sender, responsible for sending notifications, `apiserver` can only use this mode |
| 56 | +- receiver: Receiver, responsible for receiving notifications, single-machine `mcp-gateway` is recommended to use only this mode |
| 57 | +- both: Both sender and receiver, cluster-deployed `mcp-gateway` can use this mode |
| 58 | + |
| 59 | +```yaml |
| 60 | +notifier: |
| 61 | + role: "${NOTIFIER_ROLE:receiver}" # Role: 'sender' or 'receiver' |
| 62 | + type: "${NOTIFIER_TYPE:signal}" # Type: 'signal', 'api', 'redis', or 'composite' |
| 63 | +
|
| 64 | + # Signal configuration (used when type is 'signal') |
| 65 | + signal: |
| 66 | + signal: "${NOTIFIER_SIGNAL:SIGHUP}" # Signal to send |
| 67 | + pid: "${NOTIFIER_SIGNAL_PID:/var/run/mcp-gateway.pid}" # PID file path |
| 68 | +
|
| 69 | + # API configuration (used when type is 'api') |
| 70 | + api: |
| 71 | + port: ${NOTIFIER_API_PORT:5235} # API port |
| 72 | + target_url: "${NOTIFIER_API_TARGET_URL:http://localhost:5235/_reload}" # Reload endpoint |
| 73 | +
|
| 74 | + # Redis configuration (used when type is 'redis') |
| 75 | + redis: |
| 76 | + addr: "${NOTIFIER_REDIS_ADDR:localhost:6379}" # Redis address |
| 77 | + password: "${NOTIFIER_REDIS_PASSWORD:UseStrongPasswordIsAGoodPractice}" # Redis password |
| 78 | + db: ${NOTIFIER_REDIS_DB:0} # Redis database number |
| 79 | + topic: "${NOTIFIER_REDIS_TOPIC:mcp-gateway:reload}" # Redis pub/sub topic |
| 80 | +``` |
| 81 | + |
| 82 | +## Session Storage Configuration |
| 83 | + |
| 84 | +Session storage configuration is used to store MCP session information. Currently supports two storage methods: |
| 85 | +- memory: In-memory storage, suitable for single-machine deployment (note: session information will be lost on restart) |
| 86 | +- redis: Redis storage, suitable for both single-machine and cluster deployment |
| 87 | + |
| 88 | +```yaml |
| 89 | +session: |
| 90 | + type: "${SESSION_STORAGE_TYPE:memory}" # Storage type: memory, redis |
| 91 | + redis: |
| 92 | + addr: "${SESSION_REDIS_ADDR:localhost:6379}" # Redis address |
| 93 | + password: "${SESSION_REDIS_PASSWORD:}" # Redis password |
| 94 | + db: ${SESSION_REDIS_DB:0} # Redis database number |
| 95 | + topic: "${SESSION_REDIS_TOPIC:mcp-gateway:session}" # Redis pub/sub topic |
| 96 | +``` |
0 commit comments