Hermes Agent: MCP Protocol

Last updated: 2026-08-31

MCP is the USB port for AI tool interconnection — through Model Context Protocol, Hermes Agent can discover and invoke any MCP-compatible tool server, infinitely expanding capability boundaries.

💡 Tip: MCP (Model Context Protocol) is an open protocol proposed by Anthropic that standardizes interconnection between AI applications and tool servers. Hermes natively supports MCP and can connect to any MCP server.

📋 Prerequisites: Lesson 8 Tools and Toolsets, Lesson 15 Plugins

1. What You Will Learn

# Content
MCP protocol concepts and principles
Hermes' MCP integration
MCP server configuration
Tool discovery and invocation
Custom MCP server development

2. Story

(1) Pain Point: Every AI Tool Has a Different Interface

Bob uses 5 AI tools, each with its own API format, authentication method, and tool definitions. Integrating a new tool means developing a new adapter.

(2) Solution: MCP Unified Protocol, Plug and Play

Alice connects Hermes to various tool servers via MCP:

BASH
# One line of config to connect an MCP server
hermes mcp add filesystem --command "npx @anthropic/mcp-filesystem /home/alice"
hermes mcp add github --command "npx @anthropic/mcp-github"

# Hermes automatically discovers all available tools
hermes mcp tools
# Discovered 15 new tools: read_file, write_file, search_files, create_issue...

3. MCP Protocol Concepts

(1) What is MCP?

MCP (Model Context Protocol) is an open protocol that defines the communication standard between AI applications (clients) and tool servers:

100%
graph LR
    A[Hermes Agent<br/>MCP Client] -->|Standard Protocol| B[MCP Server 1<br/>Filesystem]
    A -->|Standard Protocol| C[MCP Server 2<br/>GitHub]
    A -->|Standard Protocol| D[MCP Server 3<br/>Database]
    A -->|Standard Protocol| E[MCP Server N<br/>Custom]

(2) MCP Core Concepts

Concept Description Analogy
MCP Client AI application making requests USB Host
MCP Server Server providing tools USB Device
Tool Specific operation provided by Server Device function
Resource Data source provided by Server Device storage
Prompt Prompt template provided by Server Device preset

(3) MCP vs Traditional API

Dimension Traditional API MCP
Interface format Custom per service Unified standard
Tool discovery Manual documentation Auto-discovery
Authentication Custom implementation Unified approach
Connection method HTTP/SDK stdio/SSE
Ecosystem Siloed Interconnected

4. Hermes' MCP Integration

(1) Configure MCP

YAML
# ~/.hermes/config.yaml
mcp:
  enabled: true
  
  # MCP server list
  servers:
    filesystem:
      command: "npx"
      args: ["@anthropic/mcp-filesystem", "/home/alice/projects"]
      
    github:
      command: "npx"
      args: ["@anthropic/mcp-github"]
      env:
        GITHUB_TOKEN: "${GITHUB_TOKEN}"
        
    database:
      command: "python"
      args: ["-m", "mcp_server_postgres"]
      env:
        DATABASE_URL: "${DATABASE_URL}"
        
    brave-search:
      command: "npx"
      args: ["@anthropic/mcp-brave-search"]
      env:
        BRAVE_API_KEY: "${BRAVE_API_KEY}"

(2) Connection Management

BASH
# Add MCP server
hermes mcp add filesystem --command "npx @anthropic/mcp-filesystem /home/alice"

# List configured servers
hermes mcp list

# Test connection
hermes mcp test filesystem

# View tools provided by server
hermes mcp tools filesystem

# Remove server
hermes mcp remove filesystem

5. Tool Discovery and Invocation

(1) Auto-Discovery

After connecting to an MCP server, Hermes automatically discovers all available tools:

BASH
hermes mcp tools

# Output example:
# ┌─────────────────────┬──────────────┬────────────────────────┐
# │ Tool                │ Server       │ Description            │
# ├─────────────────────┼──────────────┼────────────────────────┤
# │ read_file           │ filesystem   │ Read file contents     │
# │ write_file          │ filesystem   │ Write to file          │
# │ search_files        │ filesystem   │ Search in files        │
# │ create_issue        │ github       │ Create GitHub issue    │
# │ list_prs            │ github       │ List pull requests     │
# │ query               │ database     │ Execute SQL query      │
# │ search              │ brave-search │ Web search             │
# └─────────────────────┴──────────────┴────────────────────────┘

(2) Use in Conversation

BASH
me: Read the contents of README.md
Agent: [MCP: filesystem/read_file]
       # My Project...

me: Create an Issue on GitHub
Agent: [MCP: github/create_issue]
       Title? → "Bug: Login fails on mobile"
       ✅ Issue #42 created

me: Search for the latest AI news
Agent: [MCP: brave-search/search]
       Found 5 results...

(3) Tool Routing

When multiple MCP servers provide similar tools, Hermes auto-routes:

YAML
mcp:
  routing:
    # Prefer MCP tools
    prefer_mcp: true
    
    # Priority for same-named tools
    priority:
      filesystem.read_file: 100     # MCP version preferred
      fs_read: 50                   # Built-in version secondary
      
    # Conflict resolution
    conflict_resolution: "priority"  # priority / server_order / ask_user

6. Custom MCP Server Development

(1) Python MCP Server

PYTHON
# mcp_server_custom.py
from mcp.server import Server, Tool

server = Server("custom-tools")

@server.tool("get_weather")
async def get_weather(city: str) -> dict:
    """Get current weather for a city"""
    # Custom logic
    import httpx
    response = httpx.get(f"https://api.weather.com/{city}")
    return response.json()

@server.tool("send_notification")
async def send_notification(message: str, channel: str = "default") -> dict:
    """Send a notification to a channel"""
    # Custom notification logic
    return {"status": "sent", "channel": channel}

if __name__ == "__main__":
    server.run()

(2) TypeScript MCP Server

TYPESCRIPT
// mcp-server-custom.ts
import { Server, Tool } from "@anthropic/mcp";

const server = new Server("custom-tools");

server.tool("query_database", {
  description: "Query the database",
  parameters: {
    sql: { type: "string", required: true },
    limit: { type: "number", default: 100 }
  },
  async execute({ sql, limit }) {
    // Custom database query
    const results = await db.query(sql, { limit });
    return { rows: results };
  }
});

server.run();

(3) Register Custom Server

BASH
# Register custom MCP server
hermes mcp add custom-tools \
  --command "python mcp_server_custom.py" \
  --working-dir /path/to/server

# Or configure in config.yaml
YAML
mcp:
  servers:
    custom-tools:
      command: "python"
      args: ["mcp_server_custom.py"]
      working_dir: "/path/to/server"
      env:
        API_KEY: "${CUSTOM_API_KEY}"

7. MCP Ecosystem

(1) Official MCP Servers

Server Function Install
filesystem File system operations npx @anthropic/mcp-filesystem
github GitHub operations npx @anthropic/mcp-github
gitlab GitLab operations npx @anthropic/mcp-gitlab
postgres PostgreSQL queries npx @anthropic/mcp-postgres
sqlite SQLite operations npx @anthropic/mcp-sqlite
brave-search Web search npx @anthropic/mcp-brave-search
google-drive Google Drive npx @anthropic/mcp-google-drive
slack Slack operations npx @anthropic/mcp-slack

(2) Community MCP Servers

The community maintains 100+ MCP servers covering:


❓ FAQ

Q What's the difference between MCP and plugins?
A Plugins are Hermes-specific extensions with deep integration. MCP is an open protocol any AI application can use. MCP is more universal, plugins are more deeply integrated.
Q Do MCP servers affect performance?
A MCP servers are independent processes with zero consumption when idle. Invocation uses stdio/SSE communication, typically <50ms latency.
Q How many MCP servers can be connected simultaneously?
A No hard limit. 5-10 servers is perfectly normal in practice. Each server runs as an independent process.
Q Is MCP communication secure?
A stdio mode communication is entirely local. SSE mode supports TLS. Authentication is passed via environment variables, not exposed in the protocol.
Q How to debug MCP connection issues?
A hermes mcp test <server> tests connection, --debug shows communication details.
Q Does MCP support streaming responses?
A Yes. SSE mode supports streaming returns, suitable for long-running tools.

📖 Summary


📝 Exercises

  1. Basic (⭐): Configure an MCP server (e.g., filesystem), verify tool discovery and invocation.
  2. Intermediate (⭐⭐): Configure 3 MCP servers simultaneously, use tools from different servers in conversation.
  3. Advanced (⭐⭐⭐): Develop a custom MCP server wrapping your commonly-used API, register it with Hermes and verify the complete workflow.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏