Skip to content

feat(mcp): per-server tool filtering via include/exclude and enabled flag#986

Open
teyrebaz33 wants to merge 1 commit intoNousResearch:mainfrom
teyrebaz33:feat/690-mcp-selective-tool-loading
Open

feat(mcp): per-server tool filtering via include/exclude and enabled flag#986
teyrebaz33 wants to merge 1 commit intoNousResearch:mainfrom
teyrebaz33:feat/690-mcp-selective-tool-loading

Conversation

@teyrebaz33
Copy link
Contributor

Problem

When an MCP server exposes many tools, there is no way to restrict which ones Hermes registers. This causes tool list bloat and can expose dangerous tools (e.g. delete_customer) that the user never intends to use.

Solution

Add optional config keys under each mcp_servers entry:

mcp_servers:
  github:
    url: https://mcp.github.com
    tools:
      include: [create_issue, list_issues]   # whitelist — only these are registered
  stripe:
    url: https://mcp.stripe.com
    tools:
      exclude: [delete_customer]             # blacklist — all except these
  legacy:
    url: https://mcp.legacy.internal
    enabled: false                           # skip server entirely (no connection attempt)

Rules

  • include takes precedence over exclude if both are set
  • Neither key → all tools registered (fully backward-compatible)
  • enabled: false short-circuits before any network call

Changes

  • tools/mcp_tool.py: filter loop in _discover_and_register_server, enabled check in discover_mcp_tools
  • tests/tools/test_mcp_tool.py: TestMCPSelectiveToolLoading — 4 tests (include, exclude, no-filter, enabled=false)

Test results

134 passed, 1 warning in 9.74s

…flag

Add optional config keys under each mcp_servers entry:
- tools.include: whitelist, only listed tools are registered
- tools.exclude: blacklist, all tools except listed are registered
- enabled: false: skip server entirely, no connection attempt

Backward-compatible: no config keys = all tools registered as before.

Tests: TestMCPSelectiveToolLoading (4 tests), 134 passed total.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant