Skip to content

feat(gateway): add tools_include and tools_exclude filters#4023

Open
ecthelion77 wants to merge 1 commit intoIBM:mainfrom
forterro:feat/gateway-tool-filters-upstream
Open

feat(gateway): add tools_include and tools_exclude filters#4023
ecthelion77 wants to merge 1 commit intoIBM:mainfrom
forterro:feat/gateway-tool-filters-upstream

Conversation

@ecthelion77
Copy link
Copy Markdown
Contributor

✨ Feature / Enhancement PR

🔗 Epic / Issue

Closes #4021


🚀 Summary (1-2 sentences)

Add optional tools_include and tools_exclude fields to gateways that filter which tools are imported from a remote MCP server using fnmatch glob patterns.


🧪 Checks

  • make lint passes (ruff + black)
  • make test passes
  • CHANGELOG updated (if user-facing)

📓 Notes

Use case

When connecting to a single MCP backend that exposes many tools (e.g. an ITSM API with 40+ endpoints), it is often useful to split it into multiple gateways with different tool subsets and different auth schemes:

  • Gateway A: all tools except project management (tools_exclude: ["*project*"]) — OAuth auth
  • Gateway B: only project management tools (tools_include: ["*project*"]) — API key auth

Filtering logic

  1. If tools_include is set, only tools whose name matches at least one include pattern are kept
  2. If tools_exclude is set, tools matching any exclude pattern are removed
  3. When both are set, include is applied first, then exclude
  4. Empty/null means no filtering

Patterns use Python fnmatch syntax (*project*, manage-ticket*).

Changes

File Change
db.py tools_include/tools_exclude JSON columns on Gateway
schemas.py Fields on GatewayCreate, GatewayUpdate, GatewayRead
gateway_service.py _apply_tool_filters() + 4 call sites (refresh, register, update, activate)
export_service.py Export support
import_service.py Import support
admin.py Form parsing in create/edit flows
formSubmitHandlers.js Comma→JSON array conversion
gateways.js Edit modal population
admin.html Input fields in create + edit forms
Alembic migration New columns (IF NOT EXISTS guard)

@jonpspri jonpspri added the COULD P3: Nice-to-have features with minimal impact if left out; included if time permits label Apr 9, 2026
@ecthelion77 ecthelion77 force-pushed the feat/gateway-tool-filters-upstream branch from 7875f55 to 5a21aff Compare April 13, 2026 10:28
@ecthelion77
Copy link
Copy Markdown
Contributor Author

Suggested labels: enhancement, python, api

@ecthelion77 ecthelion77 force-pushed the feat/gateway-tool-filters-upstream branch from 5a21aff to b4f5ed9 Compare April 14, 2026 12:46
@ecthelion77 ecthelion77 force-pushed the feat/gateway-tool-filters-upstream branch 3 times, most recently from 2d99163 to 0853473 Compare April 14, 2026 15:45
@gcgoncalves gcgoncalves force-pushed the feat/gateway-tool-filters-upstream branch from 0853473 to c7aa79b Compare April 14, 2026 15:48
@ecthelion77 ecthelion77 force-pushed the feat/gateway-tool-filters-upstream branch from c7aa79b to b524955 Compare April 14, 2026 18:15
Signed-off-by: Olivier Gintrand <olivier.gintrand@forterro.com>
@gcgoncalves gcgoncalves force-pushed the feat/gateway-tool-filters-upstream branch from b524955 to 9e98adc Compare April 15, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

COULD P3: Nice-to-have features with minimal impact if left out; included if time permits

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Gateway tool include/exclude filters (fnmatch glob patterns)

4 participants