Skip to content

feat(mcp): salvage selective tool loading with utility policies#1302

Merged
teknium1 merged 3 commits intomainfrom
hermes/hermes-315847fd
Mar 14, 2026
Merged

feat(mcp): salvage selective tool loading with utility policies#1302
teknium1 merged 3 commits intomainfrom
hermes/hermes-315847fd

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

@teknium1 teknium1 commented Mar 14, 2026

Summary

  • salvage the per-server MCP include/exclude/enabled work from PR feat(mcp): per-server tool filtering via include/exclude and enabled flag #986 by @teyrebaz33
  • make filtering comprehensive by extending policy to Hermes-added MCP utility tools as well
  • register resource/prompt utility tools only when the server actually supports those capabilities
  • store the per-server registered subset so repeated discovery and status reporting stay accurate after filtering
  • avoid creating empty MCP toolsets when config filters everything out

Config behavior

Example:

mcp_servers:
github:
url: https://mcp.github.com
tools:
include: [create_issue, list_issues]
prompts: false
stripe:
url: https://mcp.stripe.com
tools:
exclude: [delete_customer]
resources: false
legacy:
url: https://mcp.legacy.internal
enabled: false

Rules:

  • tools.include whitelists server tools
  • tools.exclude blacklists server tools
  • include takes precedence over exclude
  • tools.resources: false disables list_resources / read_resource
  • tools.prompts: false disables list_prompts / get_prompt
  • utility tools are only registered if the server session exposes the corresponding capability
  • enabled: false skips the server entirely

Contributor credit

This PR salvages the core selective-tool-loading work from #986 onto current main, then extends it to cover the utility-tool caveat and keep discovery/status semantics accurate.

Validation

  • source /home/teknium/.hermes/hermes-agent/.venv/bin/activate && python -m pytest tests/tools/test_mcp_tool.py::TestMCPSelectiveToolLoading -n0 -q
  • source /home/teknium/.hermes/hermes-agent/.venv/bin/activate && python -m pytest tests/tools/test_mcp_tool.py -n0 -q
  • source /home/teknium/.hermes/hermes-agent/.venv/bin/activate && python -m pytest tests/ -n0 -q
teyrebaz33 and others added 3 commits March 14, 2026 06:12
…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.
Extend the salvaged MCP filtering work so utility tools are also governed by policy and server capabilities. Store the registered tool subset per server so rediscovery and status reporting stay accurate after filtering.
Expand the MCP feature docs with filtering and capability-aware registration details, add a practical 'Use MCP with Hermes' tutorial, add a config reference page, and wire the new docs into the sidebar and landing page.
@teknium1 teknium1 merged commit c1cca65 into main Mar 14, 2026
1 check passed
@teknium1 teknium1 deleted the hermes/hermes-315847fd branch March 14, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants