hermes-claude-bridge

hermes-claude-bridge

MCP server that enables Hermes Agent to delegate development tasks to Claude Code CLI, reusing the Claude Code subscription without additional API costs.

Category
访问服务器

README

Hermes-Claude Bridge

CI Release License: MIT

Delegate development tasks from Hermes Agent to Claude Code CLI — zero additional Anthropic API cost.

Status: early development. API may change until v1.0.0.

Why?

  • You already pay for Claude Code (Pro / Team / Enterprise) — reuse that subscription.
  • Hermes handles orchestration, memory, and multi-tool workflows.
  • Claude Code handles deep, multi-file coding tasks.
  • No Anthropic API tokens are consumed for delegated work.

What problem does this solve?

Omni (automagik-dev/omni) showed that Telegram and other channels can talk to Claude Code. This bridge does the same for the Hermes Agent ecosystem, but focused on:

  • No extra API costs — reuse the Claude Code CLI subscription.
  • Persistent contextual sessions — SQLite/PostgreSQL store keeps full conversation history; every new prompt includes prior context.
  • History filtering & compression — cap how many past events are sent, with a compact summary of older messages.
  • MCP server — expose claude_code_delegate as a native MCP tool for Hermes or any MCP client.
  • Real-time events — SSE stream delivers events instantly via asyncio.Condition, no polling.
  • Human-in-the-loop — when Claude asks a question, the bridge pauses and asks the user.
  • Model selection — choose sonnet, opus, haiku, or any full model name.
  • Headless / scriptable — run claude -p --bare from Python/asyncio.
  • Structured results — parse file edits, bash commands, and errors from Claude's output.
  • Hermes-native — register as a tool (claude_code_delegate) inside Hermes skills.

Installation

pip install hermes-claude-bridge

Requires claude CLI installed and authenticated:

claude --version

Quick Start

CLI

# Check if claude is available
hermes-claude health

# Run a single task
hermes-claude run "Refactor auth.py to use dependency injection" -f src/auth.py

# Run from a file
hermes-claude run-file prompt.md

Python API

import asyncio
from hermes_claude_bridge.bridge import HermesClaudeBridge
from hermes_claude_bridge.schemas import ClaudeTask

async def main():
    bridge = HermesClaudeBridge()
    result = await bridge.run_task(ClaudeTask(
        prompt="Add type hints to all functions",
        context_files=["src/main.py"],
    ))
    print(result.model_dump_json(indent=2))

asyncio.run(main())

Setup for Hermes Agent

Option A: MCP server (recommended for tool-gateway style)

Generate the MCP config snippet and merge it into ~/.hermes/config.yaml:

hermes-claude setup --mcp-config >> ~/.hermes/config.yaml

With a default model preset (sonnet, opus or haiku):

hermes-claude setup --mcp-config --model sonnet >> ~/.hermes/config.yaml

On next startup, Hermes discovers the claude_code_delegate tool from the hermes-claude-bridge MCP server.

Option B: Native Hermes plugin

Install the plugin:

hermes-claude setup --hermes-plugin

Then enable it in ~/.hermes/config.yaml:

plugins:
  enabled:
    - hermes-claude-bridge

The plugin can connect to a bridge server automatically when the environment variable HERMES_CLAUDE_BRIDGE_URL is set:

export HERMES_CLAUDE_BRIDGE_URL=http://localhost:8765

Restart Hermes. The tool claude_code_delegate will be available in the hermes-claude-bridge toolset.

Server mode (stateful)

Start the bridge server for persistent sessions and real-time SSE events:

hermes-claude server --port 8765

Then use the Python client from Hermes:

import asyncio
from hermes_claude_bridge.client import BridgeClient

async def main():
    client = BridgeClient("http://localhost:8765")

    # Use mode="interactive" to keep conversation context across prompts.
    # Limit how many past events are included to avoid overflowing context.
    session = await client.create_session(
        working_dir="/path/to/project",
        model="sonnet",
        mode="interactive",
        max_history_events=5,
    )
    result = await client.send_prompt(
        session["session_id"],
        "Refactor auth.py to use dependency injection",
        context_files=["src/auth.py"],
    )
    print(result)

    if result.get("status") == "waiting_user_input":
        question = result["pending_question"]
        # Ask the user, then:
        await client.answer_question(session["session_id"], "Yes, proceed.")

asyncio.run(main())

MCP server

Expose the bridge as a native MCP tool:

hermes-claude mcp-server

Hermes (or any MCP client) can then call claude_code_delegate. For stateless single tasks:

{
  "prompt": "Refactor auth.py",
  "context_files": ["src/auth.py"],
  "model": "sonnet"
}

For persistent sessions, point the tool at a running bridge server:

{
  "prompt": "Refactor auth.py",
  "bridge_url": "http://localhost:8765",
  "mode": "interactive"
}

Hermes Skill

Install the skill into your Hermes profile:

cp -r .skills/hermes-claude-bridge ~/.hermes/skills/

Then register the tool in your agent:

from hermes_claude_bridge.hermes_adapter import ClaudeBridgeTool

tool = ClaudeBridgeTool()
schema = tool.get_schema()  # Register with Hermes
result = await tool.invoke({
    "prompt": "Refactor auth.py",
    "context_files": ["src/auth.py"],
    "model": "sonnet",
    "permission_mode": "acceptEdits",
    "timeout": 300,
})

See .skills/hermes-claude-bridge/SKILL.md for the full skill definition.

Architecture

Hermes Agent
    |
    v
+----------------------------------+
|  BridgeClient or ClaudeBridgeTool|
|  - HTTP client / tool adapter    |
+----------------------------------+
    |
    | SSE / HTTP
    v
+----------------------------------+
|  Hermes-Claude Bridge Server     |
|  - FastAPI + SSE streaming       |
|  - Session Manager (SQLAlchemy)  |
+----------------------------------+
    |
    v
+----------------------------------+
|  HermesClaudeBridge (orchestrator)|
|  - Task execution                |
|  - Health checks                 |
+----------------------------------+
    |
    v
+----------------------------------+
|  ClaudeExecutor (subprocess)     |
|  - claude -p [--bare]            |
|  - Async subprocess + timeout    |
+----------------------------------+
    |
    v
+----------------------------------+
|  OutputParser                    |
|  - Extract file edits            |
|  - Extract bash commands         |
|  - Detect questions              |
+----------------------------------+
    |
    v
  Result (JSON)

Configuration

Environment variables:

Variable Default Description
CLAUDE_EXECUTABLE claude Path to claude CLI
CLAUDE_WORKING_DIR . Default working directory
CLAUDE_TIMEOUT 300 Default timeout in seconds
CLAUDE_BARE true Use --bare mode
CLAUDE_PERMISSIONS acceptEdits Default permission mode
CLAUDE_MODEL None Default Claude model
DATABASE_URL sqlite+aiosqlite:///./hermes_claude_bridge.db Async database URL

Permission Modes

Mode Behavior
acceptEdits Auto-approve file edits; ask for bash/other tools
dontAsk Auto-approve everything (dangerous, use with care)
default Ask for every tool use (not headless)

Development

git clone https://github.com/RodrigoSiliunas/hermes-claude-bridge.git
cd hermes-claude-bridge
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest tests/ -v

Releasing

To create a new release:

# Update version in pyproject.toml and src/hermes_claude_bridge/__init__.py
git add -A
git commit -m "chore(release): bump version to v0.6.0"
git tag v0.6.0
git push origin main --tags

The Release workflow will automatically build the package and create a GitHub Release with release notes.

Testing

pytest tests/ -v

License

MIT.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选