MCP Integration
源码版本v2026.7.20
Responsibility
MCP (Model Context Protocol) is a universal protocol for connecting external tools/data sources. Hermes acts both as an MCP client consuming tools exposed by external MCP servers (bridged into ToolRegistry via mcp_tool) and as an MCP server (mcp_serve.py) exposing its own tools to other agent clients. This lets Hermes pull in third-party capabilities without baking them into the core.
Key Files
tools/mcp_tool.py— MCP client bridge: registers tools from external MCP servers into ToolRegistrymcp_serve.py— Hermes as an MCP server exposing its own tools (repo root)registry.register:365-436— MCP-bridged tools go through the same registration pathregister_plugin_override_policy:316-365— controls namespace admission for MCP/plugin toolsoptional-mcps/ directory— optional MCP server implementations
Data Flow
- At startup (or via runtime hot reload) MCP config is read and
mcp_toolconnects to external MCP servers. - The list of tools exposed by a server is pulled and each is registered as a
ToolEntryviaregistry.register:365(namespaced to avoid collisions with built-in tools). - Namespace admission is controlled by
register_plugin_override_policy:316. - The main loop gathers schemas, dispatches tool_calls, and backfills results just as for built-in tools.
- Reverse direction: Hermes can expose its own tools to other MCP clients via
mcp_serve.py, letting editors/other agents call them.
Summary
MCP is Hermes's "capability bus". mcp_tool lets external tools enter the same tool pool as built-ins; mcp_serve.py lets Hermes itself be called by external clients. Everything goes through ToolRegistry, so the main loop does not care whether a tool is built-in or MCP.