You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(gateway): add tools_include and tools_exclude filters
Add fnmatch glob-based tool filtering to gateways. When a gateway is
refreshed, registered, updated or activated, the discovered tools are
filtered against optional include/exclude patterns:
- tools_include: whitelist – only tools matching at least one pattern
are kept
- tools_exclude: blacklist – tools matching any pattern are removed
- When both are set, include is applied first, then exclude
This enables splitting a single MCP backend into multiple gateways with
different tool subsets (e.g. one gateway for ticket tools, another for
project tools) without requiring upstream server changes.
Changes:
- db.py: tools_include/tools_exclude JSON columns on Gateway model
- schemas.py: fields on GatewayCreate, GatewayUpdate, GatewayRead
- gateway_service.py: _apply_tool_filters() helper + 4 call sites
- export_service.py / import_service.py: export/import support
- admin.py: form parsing for create and edit flows
- admin_ui JS: comma-separated input → JSON array conversion
- templates/admin.html: input fields in create and edit forms
- Alembic migration for the new columns
Signed-off-by: Olivier Gintrand <olivier.gintrand@forterro.com>
@@ -3042,6 +3046,10 @@ class GatewayUpdate(BaseModelWithConfigDict):
3042
3046
# Gateway mode configuration
3043
3047
gateway_mode: Optional[str] =Field(None, description="Gateway mode: 'cache' (database caching, default) or 'direct_proxy' (pass-through mode with no caching)", pattern="^(cache|direct_proxy)$")
3044
3048
3049
+
# Tool filtering: fnmatch glob patterns to include/exclude tools during refresh
3050
+
tools_include: Optional[List[str]] =Field(None, description="Glob patterns to whitelist tools (only matching tools are imported)")
3051
+
tools_exclude: Optional[List[str]] =Field(None, description="Glob patterns to blacklist tools (matching tools are excluded)")
3052
+
3045
3053
# CA certificate configuration for custom TLS trust
3046
3054
ca_certificate: Optional[str] =Field(None, description="Custom CA certificate for TLS verification")
3047
3055
ca_certificate_sig: Optional[str] =Field(None, description="Signature of the custom CA certificate")
@@ -3411,6 +3419,10 @@ class GatewayRead(BaseModelWithConfigDict):
3411
3419
# Gateway mode configuration
3412
3420
gateway_mode: str=Field(default="cache", description="Gateway mode: 'cache' (database caching, default) or 'direct_proxy' (pass-through mode with no caching)")
3413
3421
3422
+
# Tool filtering: fnmatch glob patterns to include/exclude tools during refresh
3423
+
tools_include: Optional[List[str]] =Field(None, description="Glob patterns to whitelist tools (only matching tools are imported)")
3424
+
tools_exclude: Optional[List[str]] =Field(None, description="Glob patterns to blacklist tools (matching tools are excluded)")
0 commit comments