Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Hermes Agent MCP Integration

Hermes Agent MCP Integration

MCP (Model Context Protocol) is an open protocol proposed by Anthropic for standardizing the interaction between LLMs and external tools.

Hermes natively supports MCP, allowing it to connect to any MCP-compatible service such as GitHub, databases, file systems, browser stacks, and internal APIs without modifying core code.

This chapter takes a deep look at MCP's two integration methods, tool filtering strategies, security isolation mechanisms, and common troubleshooting.


What is MCP

MCP solves a real problem: with the traditional approach, every new service requires writing adapter code, defining tool schemas, and handling authentication--each service is a one-off effort.

MCP standardizes all of this. Hermes can directly connect to any service implementing the MCP protocol, with no extra development.

Core roles of MCP:



Hermes Agent(MCP 客户端)

    │

    ├── stdio ──→ MCP 服务器 A(本地子进程)

    │                  └── 暴露工具:git_commit, git_push...

    │

    ├── HTTP ───→ MCP 服务器 B(远程服务)

    │                  └── 暴露工具:list_issues, create_issue...

    │

    └── HTTP ───→ MCP 服务器 C(远程 OAuth)

                       └── 暴露工具:search_docs, create_page...

The standard installation already includes MCP support, with no extra steps required. All MCP servers are ~/.hermes/config.yaml configured centrally.

MCP is not a proprietary protocol of Hermes--it is open. Servers written for other MCP-enabled tools (such as Claude Code's MCP servers) can be used directly in Hermes, and vice versa.


Two types of MCP servers

Local stdio server

Runs locally as a subprocess, communicating with Hermes via standard input/output (stdin/stdout).

Communication uses the JSON-RPC protocol, with each message separated by a newline.

Use cases: tools installed locally that need low-latency access to local resources (file systems, Git repositories, local databases).

Example

File path: ~/.hermes/config.yaml

MCP stdio server configuration

mcp_servers

:

 

GitHub server: started via npx

  github

:

    command

:

"npx"

    args

:

[

"-y"

,

"@modelcontextprotocol/server-github"

]

    env

:

      GITHUB_PERSONAL_ACCESS_TOKEN

:

"ghp_..."

 

File system server: restrict the Agent's access scope

  filesystem

:

    command

:

"npx"

    args

:

     -

"-y"

      -

"@modelcontextprotocol/server-filesystem"

      -

"/home/user/projects"

   

Only allow access to this directory

 

Git server: started via uvx

  git

:

    command

:

"uvx"

    args

:

     -

"mcp-server-git"

      -

"--repository"

      -

"/home/user/project"

The lifecycle of stdio servers is managed by Hermes:

Remote HTTP server

Connects directly to remote MCP endpoints via HTTP requests, supporting multiple authentication methods.

Use cases: tools hosted remotely, or MCP interfaces already available within the organization.

Example

File path: ~/.hermes/config.yaml

MCP HTTP server configuration

mcp_servers

:

 

Method 1: static Bearer Token authentication

  internal_api

:

    url

:

"https://mcp.internal.example.com/mcp"

    headers

:

      Authorization

:

"Bearer ${MY_TOKEN}"

   

Supports environment variables

 

Method 2: OAuth 2.1 authentication (Linear, Sentry, Figma, Stripe, etc.)

  linear

:

    url

:

"https://mcp.linear.app/mcp"

    auth

:

oauth

 

Method 3: providers requiring pre-registered OAuth clients

  googledrive

:

    url

:

"https://drivemcp.googleapis.com/mcp/v1"

    auth

:

oauth

    oauth

:

      client_id

:

""

     

Obtain via pre-registration

      client_secret

:

""

Comparison of the two types

Dimension stdio server HTTP server
Run location Local machine (subprocess) Remote (standalone service)
Communication method stdin/stdout + JSON-RPC HTTP request
Lifetime Hermes manages start/stop Independent of Hermes
Latency Extremely low (in-process communication) Depends on network latency
Authentication Environment variable passing Bearer Token / OAuth 2.1
Typical scenario Local Git, file systems, databases GitHub API, Linear, Sentry
Configuration complexity Low (one line of command) Medium (requires configuring URL + authentication)

Nous curated MCP catalog

Hermes includes a built-in MCP catalog reviewed by Nous Research, providing a one-click installation experience.

Browse and install

Open the interactive selector (TUI) to browse all catalog entries:

hermes mcp

Other commands:



# Plain text list (suitable for scripting)

hermes mcp catalog



# Install by name

hermes mcp install n8n

hermes mcp install github

hermes mcp install linear

The interactive selector shows the current status of each entry:



n8n          available              管理和检查 n8n 工作流

linear       enabled                Linear 问题/项目管理(远程 OAuth)

github       installed (disabled)   GitHub 仓库 + PR 工具

filesystem   installed (enabled)    安全的文件系统操作

postgres     available               PostgreSQL 数据库查询

slack        available               Slack 消息和频道管理

Status description:

State Meaning
available Installable, not yet installed
installed (enabled) Installed and enabled, available to the Agent
installed (disabled) Installed but disabled, unavailable to the Agent
enabled Remote OAuth server, authorized and enabled

View the configuration in the Settings menu of the desktop app:

View the configuration in the MCP menu on the left side of the dashboard:

What happens during installation

One-click installation automatically completes three steps:

  1. Configuration guide: prompt for an API Key or guide through the OAuth browser authorization flow
  2. Tool discovery: connect to the server and obtain the full list of tools it exposes
  3. Tool selection: show the tool list for you to check the tools to enable (all selected by default)

The third step (tool selection) is an important security step--you do not need every tool. For example, the GitHub server exposes delete_repo; if you do not need it, you can uncheck it.


Tool filtering: expose only what you need

Every MCP server supports fine-grained tool filtering. This is a key security mechanism for reducing the Agent's attack surface.

include mode (whitelist)

Register only the tools in the list and exclude all others:

Example

File path: ~/.hermes/config.yaml

include whitelist mode--the safest choice

mcp_servers

:

  github

:

    command

:

"npx"

    args

:

[

"-y"

,

"@modelcontextprotocol/server-github"

]

    env

:

      GITHUB_PERSONAL_ACCESS_TOKEN

:

"ghp_..."

    tools

:

      include

:

       - list_issues

        - create_issue

        - update_issue

        - search_code

     

Any tool other than these 4 will not be registered

exclude mode (blacklist)

Exclude the tools in the list and register all others:

Example

File path: ~/.hermes/config.yaml

exclude blacklist mode--exclude high-risk operations

mcp_servers

:

  stripe

:

    url

:

"https://mcp.stripe.com"

    headers

:

      Authorization

:

"Bearer ${STRIPE_KEY}"

    tools

:

      exclude

:

       - delete_customer

        - refund_payment

        - create_live_key

     

Any tool other than these 3 will be registered

Filtering rule priority

Configure Behavior Applicable scenarios
include only Register only the tools in the include list Security first, principle of least privilege
exclude only Register all tools, excluding the exclude list Convenience first, exclude a few high-risk operations
Both set include takes priority, exclude is ignored —
Neither set Register all tools exposed by the server Fully trust this MCP server

Disable resources and prompts

Besides tools, MCP servers may also expose resources and prompts. If not needed, you can disable them:

Example

File path: ~/.hermes/config.yaml

Reference MCP tool sets in platform configuration

platform_toolsets:

  cli:

    - hermes-cli

    - file

    - terminal

    - mcp-github # GitHub MCP tool

    - mcp-linear # Linear MCP tool

  telegram:

    - hermes-gateway

    - mcp-github # Also enable GitHub tools on Telegram

  discord:

    - hermes-gateway

    # Do not enable GitHub tools on Discord (security policy)


MCP environment variable isolation

This is the most overlooked yet most important design in Hermes' MCP security mechanism.

The MCP stdio subprocess receives a filtered environment, passing only the following variables by default:



PATH, HOME, USER, LANG, LC_ALL, TERM, SHELL, TMPDIR

以及所有 XDG_* 变量

All other environment variables (API Key, Token, password) are blocked.

Only variables explicitly declared in the env: block of the MCP server configuration are passed to the subprocess:

Example

    env:

      GITHUB_PERSONAL_ACCESS_TOKEN: "ghp_..." # Only this one variable is passed in

      # Even if you exported GITHUB_TOKEN in the Shell,

      # If not declared here, it will not be passed to the MCP subprocess

Why designed this way? Suppose you stored 10 API Keys in .env (OpenAI, Anthropic, SerpAPI, Telegram Bot Token...). If an MCP server could read all environment variables, a malicious MCP server tool could steal all credentials. Environment variable isolation ensures it can only see the one explicitly declared.

Automatic error message redaction

Error messages from MCP tools are automatically redacted before being returned to the LLM--sensitive information (API Key, Token, password) is replaced with [REDACTED].

This prevents the Agent from accidentally seeing plaintext credentials when analyzing errors.


Manually add an MCP server

Besides one-click installation from the Nous catalog, you can also manually add any MCP-compatible server.

Example

Manually add a stdio server

hermes mcp add my-git-server \

 

--command

"uvx"

\

 

--args

"mcp-server-git,--repository,/home/user/project"

Manually add an HTTP server

hermes mcp add internal-db \

 

--url

"https://mcp.internal.example.com/db"

\

 

--header

"Authorization: Bearer ${DB_TOKEN}"

Test whether the connection works

hermes mcp

test

my-git-server

Configure tool filtering

hermes mcp configure my-git-server

hermes mcp configure This opens the interactive tool selection interface, letting you re-check the tools to enable.


Reload MCP configuration

After modifying the MCP configuration in config.yaml, there is no need to restart the entire Agent:

Example

--- Browse and Install -------------------------------------------

hermes mcp # Interactive catalog selector (TUI)

hermes mcp catalog # Plain-text catalog list

hermes mcp install             # One-click install from the catalog

--- Manual Management ---------------------------------------------

hermes mcp add --command --args <...> # Add a stdio server

hermes mcp add --url                   # Add an HTTP server

hermes mcp remove              # Remove a server configuration

hermes mcp list # List all configured servers

hermes mcp test                # Test server connection

hermes mcp configure           # Re-select enabled tools

--- OAuth Authentication ------------------------------------------

hermes mcp login             # Start OAuth authorization (wait up to 5 minutes)

--- Runtime Operations --------------------------------------------

/reload-mcp # Reload MCP configuration within the session

hermes mcp reload # Reload from the command line


Troubleshooting common problems

Problem Possible cause Solution
MCP tools do not appear Server not enabled or connection failed Run hermes mcp list to check status, hermes mcp test to test the connection
Tool filtering does not take effect Used the tool name after Hermes registration Use the original MCP tool name (with hyphens, e.g. list-issues instead of list_issues)
stdio server crashes frequently Missing dependencies or insufficient permissions Check whether command is in PATH, run it manually to test
OAuth authorization timeout The 30 seconds of /reload-mcp is not enough First hermes mcp login, then /reload-mcp after it completes
Environment variables do not take effect Not explicitly declared in the env: block In mcp_servers.Declare it in .env, do not rely on Shell environment variables
HTTP server connection refused URL unreachable or authentication failed Check the URL and Authorization header, confirm network connectivity