Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,10 @@ GATEWAY_VALIDATION_TIMEOUT=5
# Maximum concurrent health checks per worker (default: 10)
MAX_CONCURRENT_HEALTH_CHECKS=10

# Enable automatic tools/prompts/resources refresh from the mcp servers during health checks (default: false)
# If the tools/prompts/resources in the mcp servers are not updated frequently, it is recommended to keep this disabled to reduce load on the servers
AUTO_REFRESH_SERVERS=false

# File lock name for gateway service leader election
# Used to coordinate multiple gateway instances when running in cluster mode
# Default: "gateway_service_leader.lock"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,7 @@ Automatic management of metrics data to prevent unbounded table growth and maint
| | Set to -1 if deactivation is not needed. | | |
| `GATEWAY_VALIDATION_TIMEOUT` | Gateway URL validation timeout (secs) | `5` | int > 0 |
| `MAX_CONCURRENT_HEALTH_CHECKS` | Max Concurrent health checks | `20` | int > 0 |
| `AUTO_REFRESH_SERVERS` | Auto Refresh tools/prompts/resources | `false` | bool |
| `FILELOCK_NAME` | File lock for leader election | `gateway_service_leader.lock` | string |
| `DEFAULT_ROOTS` | Default root paths for resources | `[]` | JSON array |

Expand Down
6 changes: 6 additions & 0 deletions charts/mcp-stack/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,12 @@
"description": "Unhealthy threshold",
"default": "3"
},
"AUTO_REFRESH_SERVERS": {
"type": "string",
"enum": ["true", "false"],
"description": "Enable automatic tools/prompts/resources refresh from the mcp servers during gateway health checks",
"default": "false"
},
"FILELOCK_NAME": {
"type": "string",
"description": "File lock path",
Expand Down
1 change: 1 addition & 0 deletions charts/mcp-stack/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ mcpContextForge:
GATEWAY_HEALTH_CHECK_TIMEOUT: "5.0" # per-check timeout to bound total time of one gateway health check
UNHEALTHY_THRESHOLD: "3" # failed checks before peer marked unhealthy
GATEWAY_VALIDATION_TIMEOUT: "5" # gateway URL validation timeout (seconds)
AUTO_REFRESH_SERVERS: "false" # automatic tools/prompts/resources refresh from the mcp servers during gateway health checks
FILELOCK_NAME: gateway_healthcheck_init.lock # lock file used at start-up

# ─ MCP Session Pool ─
Expand Down
5 changes: 5 additions & 0 deletions docs/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2342,6 +2342,11 @@
"title": "Gateway Validation Timeout",
"type": "integer"
},
"auto_refresh_servers": {
"default": false,
"title": "Auto Refresh Servers",
"type": "boolean"
},
"gateway_max_redirects": {
"default": 5,
"title": "Gateway Max Redirects",
Expand Down
5 changes: 5 additions & 0 deletions docs/docs/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2363,6 +2363,11 @@
"title": "Gateway Health Check Timeout",
"type": "number"
},
"auto_refresh_servers": {
"default": false,
"title": "Auto Refresh Servers",
"type": "boolean"
},
"unhealthy_threshold": {
"default": 3,
"title": "Unhealthy Threshold",
Expand Down
5 changes: 5 additions & 0 deletions docs/docs/manage/scale.md
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,11 @@ UNHEALTHY_THRESHOLD=3
# Gateway health check timeout (seconds)
GATEWAY_HEALTH_CHECK_TIMEOUT=5.0
# Auto-refresh tools during health checks
# When enabled, tools/resources/prompts are fetched and synced during health checks
AUTO_REFRESH_SERVERS=false
```

### Logging for Performance
Expand Down
4 changes: 4 additions & 0 deletions mcpgateway/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,10 @@ def parse_issuers(cls, v: Any) -> list[str]:
# Max concurrent health checks per worker
max_concurrent_health_checks: int = 10

# Auto-refresh tools/resources/prompts from gateways during health checks
# When enabled, tools/resources/prompts are fetched and synced with DB during health checks
auto_refresh_servers: bool = Field(default=False, description="Enable automatic tool/resource/prompt refresh during gateway health checks")

# Validation Gateway URL
gateway_validation_timeout: int = 5 # seconds
gateway_max_redirects: int = 5
Expand Down
271 changes: 270 additions & 1 deletion mcpgateway/services/gateway_service.py

Large diffs are not rendered by default.

Loading
Loading