Native mcp

From seaworld008/Commonly-used-high-value-skills · View interactive version

Native mcp is an AI agent skill from the GitHub repository seaworld008/Commonly-used-high-value-skills. Configure Hermes Agent''s built-in MCP client: server discovery, stdio/HTTP connections, tool registration, authentication, and reconnection diagnostics.

How to use this skill

Skill file

Native MCP Client

Hermes Agent has a built-in MCP client that connects to MCP servers at startup, discovers their tools, and makes them available as first-class tools the agent can call directly. No bridge CLI needed -- tools from MCP servers appear alongside built-in tools like terminal, read_file, etc.

When to Use

Use this whenever you want to:

For ad-hoc, one-off MCP tool calls from the terminal without configuring anything, see the mcporter skill instead.

Prerequisites

If dependencies are missing, use the installed version's documented PM/installation mechanism within the authorized setup scope. Do not bypass it with direct pip installation or an unreviewed upgrade.

Quick Start

Resolve the active Hermes home from $HERMES_HOME (including profiles) before configuration. Under existing setup authorization, use the installed Hermes configuration/MCP operations to maintain mcp_servers; do not hand-edit config.yaml. The YAML below illustrates the settings shape, not a command to write a file.

mcp_servers:
  time:
    command: "uvx"
    args: ["mcp-server-time"]

Apply the installed version's required reload or restart. On startup it will:

  1. Connect to the server
  2. Discover available tools
  3. Register them with the prefix mcp_time_*
  4. Inject them into all platform toolsets

You can then use the tools naturally -- just ask the agent to get the current time.

Configuration Reference

Each entry under mcp_servers is a server name mapped to its config. There are two transport types: stdio (command-based) and HTTP (url-based).

Keep credentials in the active Hermes home's .env or supported secret store, and use the installed version's documented secret-reference mechanism. Empty env/headers maps below omit authentication intentionally: do not replace them with literal secrets in settings or assume an unverified interpolation syntax. Authenticate only after checking the installed mechanism and allowed subprocess variables.

Stdio Transport (command + args)

mcp_servers:
  server_name:
    command: "npx"             # (required) executable to run
    args: ["-y", "pkg-name"]   # (optional) command arguments, default: []
    env: {}                    # approved non-secret subprocess settings only
    timeout: 120               # (optional) per-tool-call timeout in seconds, default: 120
    connect_timeout: 60        # (optional) initial connection timeout in seconds, default: 60

HTTP Transport (url)

mcp_servers:
  server_name:
    url: "https://my-server.example.com/mcp"   # (required) server URL
    headers: {}                                  # secret references configured via installed mechanism
    timeout: 180               # (optional) per-tool-call timeout in seconds, default: 120
    connect_timeout: 60        # (optional) initial connection timeout in seconds, default: 60

All Config Options

| Option | Type | Default | Description |

|-------------------|--------|---------|---------------------------------------------------|

| command | string | -- | Executable to run (stdio transport, required) |

| args | list | [] | Arguments passed to the command |

| env | dict | {} | Extra environment variables for the subprocess |

| url | string | -- | Server URL (HTTP transport, required) |

| headers | dict | {} | HTTP headers sent with every request |

| timeout | int | 120 | Per-tool-call timeout in seconds |

| connect_timeout | int | 60 | Timeout for initial connection and discovery |

Note: A server config must have either command (stdio) or url (HTTP), not both.

How It Works

Startup Discovery

When Hermes Agent starts, discover_mcp_tools() is called during tool initialization:

  1. Reads mcp_servers from the active Hermes home's settings
  2. For each server, spawns a connection in a dedicated background event loop
  3. Initializes the MCP session and calls list_tools() to discover available tools
  4. Registers each tool in the Hermes tool registry

Tool Naming Convention

MCP tools are registered with the naming pattern:

mcp_{server_name}_{tool_name}

Hyphens and dots in names are replaced with underscores for LLM API compatibility.

Examples:

Auto-Injection

After discovery, MCP tools are automatically injected into all hermes-* platform toolsets (CLI, Discord, Telegram, etc.). This means MCP tools are available in every conversation without any additional configuration.

Connection Lifecycle

Idempotency

discover_mcp_tools() is idempotent -- calling it multiple times only connects to servers that aren't already connected. Failed servers are retried on subsequent calls.

Transport Types

Stdio Transport

The most common transport. Hermes launches the MCP server as a subprocess and communicates over stdin/stdout.

mcp_servers:
  filesystem:
    command: "npx"
    args: ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/authorized-project"]

The subprocess inherits a filtered environment (see Security section below) plus any variables you specify in env.

HTTP / StreamableHTTP Transport

For remote or shared MCP servers. Requires the mcp package to include HTTP client support (mcp.client.streamable_http).

mcp_servers:
  remote_api:
    url: "https://mcp.example.com/mcp"
    headers: {}  # configure authentication using the installed secret-reference mechanism

If HTTP support is not available in your installed mcp version, the server will fail with an ImportError and other servers will continue normally.

Security

Environment Variable Filtering

For stdio servers, Hermes does NOT pass your full shell environment to MCP subprocesses. Only safe baseline variables are inherited:

All other environment variables (API keys, tokens, secrets) are excluded unless you explicitly add them via the env config key. This prevents accidental credential leakage to untrusted MCP servers.

mcp_servers:
  github:
    command: "npx"
    args: ["-y", "@modelcontextprotocol/server-github"]
    env: {}  # explicitly authorize the required token reference through installed secret configuration

Credential Stripping in Error Messages

If an MCP tool call fails, any credential-like patterns in the error message are automatically redacted before being shown to the LLM. This covers:

Troubleshooting

"MCP SDK not available -- skipping MCP tool discovery"

Check whether MCP dependencies are missing in the active Hermes environment. Repair them using that installation's documented PM mechanism within setup authorization; do not install into an arbitrary Python environment.

"No MCP servers configured"

Check mcp_servers in the active Hermes home's settings using the installed configuration/MCP operations. Add the requested server only within the current setup scope.

"Failed to connect to MCP server 'X'"

Common causes:

"MCP server 'X' requires HTTP transport but mcp.client.streamable_http is not available"

Verify HTTP support in the active installation. For PM-managed installs, repair the recorded environment through the installed Hermes PM mechanism; do not blindly upgrade mcp through pip.

Tools not appearing

Connection keeps dropping

The client retries up to 5 times with exponential backoff (1s, 2s, 4s, 8s, 16s, capped at 60s). If the server is fundamentally unreachable, it gives up after 5 attempts. Check the server process and network connectivity.

Examples

Time Server (uvx)

mcp_servers:
  time:
    command: "uvx"
    args: ["mcp-server-time"]

Registers tools like mcp_time_get_current_time.

Filesystem Server (npx)

mcp_servers:
  filesystem:
    command: "npx"
    args: ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/authorized-project"]
    timeout: 30

Registers tools like mcp_filesystem_read_file, mcp_filesystem_write_file, mcp_filesystem_list_directory.

Replace /path/to/authorized-project with the user's explicitly allowed project directory. Do not grant a shared temporary root or a broader home directory by default.

GitHub Server with Authentication

mcp_servers:
  github:
    command: "npx"
    args: ["-y", "@modelcontextprotocol/server-github"]
    env: {}  # supply an approved token reference via the installed secret mechanism
    timeout: 60

Registers tools like mcp_github_list_issues, mcp_github_create_pull_request, etc.

Remote HTTP Server

mcp_servers:
  company_api:
    url: "https://mcp.mycompany.com/v1/mcp"
    headers:
      X-Team-Id: "engineering"
    timeout: 180
    connect_timeout: 30

Multiple Servers

mcp_servers:
  time:
    command: "uvx"
    args: ["mcp-server-time"]

  filesystem:
    command: "npx"
    args: ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/authorized-project"]

  github:
    command: "npx"
    args: ["-y", "@modelcontextprotocol/server-github"]
    env: {}  # supply an approved token reference via the installed secret mechanism

  company_api:
    url: "https://mcp.internal.company.com/mcp"
    headers: {}  # supply an approved authorization reference via the installed secret mechanism
    timeout: 300

All tools from all servers are registered and available simultaneously. Each server's tools are prefixed with its name to avoid collisions.

Sampling (Server-Initiated LLM Requests)

Hermes supports MCP's sampling/createMessage capability — MCP servers can request LLM completions through the agent during tool execution. This enables agent-in-the-loop workflows (data analysis, content generation, decision-making).

Sampling is enabled by default. Configure per server:

mcp_servers:
  my_server:
    command: "npx"
    args: ["-y", "my-mcp-server"]
    sampling:
      enabled: true           # default: true
      model: "gemini-3-flash" # model override (optional)
      max_tokens_cap: 4096    # max tokens per request
      timeout: 30             # LLM call timeout (seconds)
      max_rpm: 10             # max requests per minute
      allowed_models: []      # model whitelist (empty = all)
      max_tool_rounds: 5      # tool loop limit (0 = disable)
      log_level: "info"       # audit verbosity

Servers can also include tools in sampling requests for multi-turn tool-augmented workflows. The max_tool_rounds config prevents infinite tool loops. Per-server audit metrics (requests, errors, tokens, tool use count) are tracked via get_mcp_status().

Disable sampling for untrusted servers with sampling: { enabled: false }.

Notes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.