Skip to content

feat: add Hermes Agent MCP integration with Windows stdio fix#2797

Open
OmniaZ1 wants to merge 1 commit into
upstash:masterfrom
OmniaZ1:feat-hermes-mcp-integration
Open

feat: add Hermes Agent MCP integration with Windows stdio fix#2797
OmniaZ1 wants to merge 1 commit into
upstash:masterfrom
OmniaZ1:feat-hermes-mcp-integration

Conversation

@OmniaZ1

@OmniaZ1 OmniaZ1 commented Jun 18, 2026

Copy link
Copy Markdown

Context7 MCP integration for Hermes Agent

What does this PR do?

This PR adds full Hermes Agent MCP integration to Context7, enabling one-click setup of Context7 documentation tools for Hermes Agent users.

Features

1. New --hermes flag for setup/remove commands

# Setup Context7 for Hermes Agent
ctx7 setup --hermes --mcp

# Remove Context7 from Hermes Agent
ctx7 remove --hermes --mcp

2. Two transport modes supported

HTTP Mode (recommended):

mcp_servers:
  context7:
    url: https://mcp.context7.com/mcp
    timeout: 120
    connect_timeout: 60
    headers:
      CONTEXT7_API_KEY: your_api_key

Stdio Mode (for offline environments):

mcp_servers:
  context7:
    command: node
    args:
      - -e
      - const p=require("path");const f=require("fs");const c=require("child_process");let x;try{x=require.resolve("@upstash/context7-mcp")}catch(e){...}
    timeout: 120
    connect_timeout: 60
    env:
      CONTEXT7_API_KEY: your_api_key

3. Windows stdio execution fix

Windows npm/npx has issues resolving scoped package bins from npx -y @upstash/context7-mcp. The fix uses an inline node -e script that:

  1. First tries require.resolve() to find the package
  2. Falls back to scanning the npm _npx cache directory
  3. Installs to temp dir as last resort
  4. Directly loads the MCP server via module._load()

This reduces connection time from timeout/failure to ~1 second on Windows.

4. Hermes tool naming convention

Hermes MCP tools follow the mcp_{server}_{tool} naming convention. This PR automatically adapts the Context7 skill and rule content:

  • resolve-library-idmcp_context7_resolve_library_id
  • query-docsmcp_context7_query_docs

5. Full test coverage

  • 22 new unit tests added for Hermes integration
  • All 140 tests passing
  • YAML config read/write tests
  • stdio entry tests
  • Setup/remove command tests

Files Changed

File Changes
packages/cli/package.json Added yaml dependency
packages/cli/src/setup/agents.ts Added hermes agent config with Windows stdio fix
packages/cli/src/setup/mcp-writer.ts Added YAML config reader/writer (readYamlConfig, writeYamlConfig, appendYamlServer, removeYamlServer)
packages/cli/src/setup/templates.ts Added Hermes skill name mapping and rule content
packages/cli/src/commands/setup.ts Added --hermes flag
packages/cli/src/commands/remove.ts Added --hermes flag
packages/cli/src/__tests__/setup.test.ts 22 new Hermes integration tests
packages/cli/src/__tests__/remove.test.ts Hermes remove command tests
pnpm-lock.yaml Updated dependencies

Verification

# Setup
ctx7 setup --hermes --mcp --stdio --api-key test_key

# Verify connection
hermes mcp test context7
# ✓ Connected (1141ms)
# ✓ Tools discovered: 2
#   - resolve-library-id
#   - query-docs

# Remove
ctx7 remove --hermes --mcp

Platform Support

✅ Windows (fully tested, includes Windows-specific npm path fix)
✅ Linux (should work, uses standard node/npm paths)
✅ macOS (should work, uses standard node/npm paths)

Related Issues

  • Fixes Windows npm/npx execution issues with scoped package bins
  • Hermes Agent MCP integration request

Screenshots

Setup output:

✔ Context7 setup complete

  Hermes Agent
    + MCP server configured with API Key
      ~/.hermes/config.yaml
    + Rule installed
      ~/.hermes/rules/context7.md
    + Skill installed
      ~/.hermes/skills/context7-mcp/SKILL.md

Hermes connection test:

  Testing 'context7'...
  Transport: stdio → node
  Auth: none
  ✓ Connected (1141ms)
  ✓ Tools discovered: 2

    resolve-library-id
    query-docs

- Add --hermes flag to setup/remove commands
- Add YAML config writer for Hermes config.yaml
- Implement hermes agent config with HTTP and stdio transports
- Fix Windows npx path issue by using inline node -e script
- Add unit tests for Hermes integration
- Add skill name mapping for Hermes MCP tool naming convention
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant