Skip to content

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

Data Flow

  1. At startup (or via runtime hot reload) MCP config is read and mcp_tool connects to external MCP servers.
  2. The list of tools exposed by a server is pulled and each is registered as a ToolEntry via registry.register:365 (namespaced to avoid collisions with built-in tools).
  3. Namespace admission is controlled by register_plugin_override_policy:316.
  4. The main loop gathers schemas, dispatches tool_calls, and backfills results just as for built-in tools.
  5. 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.

Unofficial community learning site. Content based on the MIT-licensed NousResearch/hermes-agent source.