Skip to main content
Glama

herdr-mcp

MCP server that puts the herdr CLI (hc) behind an authenticated HTTP endpoint, so any MCP client on any machine can list terminals, read their screens, type into them, run detached programs, and wait for exit codes.

Two files, zero dependencies: server.mjs (protocol + tools) and oauth.mjs (authorization server). Runs on Node.js 20 or newer.

What it implements

  • Transport: MCP Streamable HTTP, JSON responses only (no SSE stream). Single endpoint POST /mcp.

  • Protocol version: 2026-07-28, advertised on initialize and server/discover.

  • Extension: io.modelcontextprotocol/tasks. herdr_run_task starts a detached program and returns a CreateTaskResult (resultType: "task") instead of a CallToolResult. tasks/get, tasks/cancel, and tasks/update are supported. Task TTL is 1 hour, poll interval 3 seconds.

  • Capability gate: a client that calls herdr_run_task without declaring the tasks extension in params._meta["io.modelcontextprotocol/clientCapabilities"].extensions still gets a normal CallToolResult (never a CreateTaskResult), and tasks/* calls fail with JSON-RPC -32021.

Related MCP server: mcp-auth-proxy

Tools

Tool

Required args

Description

herdr_machines

none

List herdr machines and their state

herdr_ls

none

List terminals on all machines (all: true includes finished)

herdr_read

terminal

Read a terminal screen and history (lines)

herdr_send

terminal, text

Paste text into a terminal and press Enter

herdr_keys

terminal, keys[]

Press named keys (enter, esc, up, ctrl+c)

herdr_interrupt

terminal

Press the stop key in a terminal

herdr_exec

argv[]

Run one program without a terminal, return output and exit code

herdr_run

argv[]

Start a program in a new persistent background terminal

herdr_wait

terminal

Block until a terminal finishes, return exit code and output

herdr_run_task

argv[]

Start a program as a background MCP task

herdr_file_read

path

Read a text file locally or on another machine

A terminal is an address (machine/t7), a terminal id (t7), or a name. Optional args: on (machine), cwd, timeout, name, lines. Arguments are passed to hc as an argv array via execFile — no shell, no string interpolation.

Setup

git clone https://github.com/Pakheria/herdr-mcp
cd herdr-mcp
cp .env.example .env
# edit .env: set OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET, APPROVE_PASSWORD (16+ chars each)
set -a; . ./.env; set +a
node server.mjs

Requires hc on PATH. The server binds 127.0.0.1:8791 — put a reverse proxy or tunnel in front of it to expose TLS; the OAuth issuer and resource URLs are derived from the Host header with the scheme fixed to https, so the metadata is only correct behind a TLS-terminating proxy.

Client configuration (any MCP client that supports remote HTTP servers with OAuth):

{
  "mcpServers": {
    "herdr": {
      "type": "http",
      "url": "https://your-host.example/mcp"
    }
  }
}

OAuth surface

Endpoint

Purpose

GET /.well-known/oauth-protected-resource

Resource metadata (resource, authorization_servers)

GET /.well-known/oauth-authorization-server

Authorization server metadata

POST /register

Dynamic client registration (redirect URIs restricted to the allowlist)

GET/POST /authorize

Consent page, gated by APPROVE_PASSWORD

POST /token

authorization_code (PKCE S256) and refresh_token grants

POST /mcp

MCP endpoint, requires Authorization: Bearer

Flow: unauthenticated POST /mcp returns 401 with WWW-Authenticate: Bearer resource_metadata=".../.well-known/oauth-protected-resource". The client registers, opens /authorize, the owner types the password, the client exchanges the code with its PKCE verifier, and gets a 24h access token plus a 30d sliding refresh token.

Security model

  • Owner-gated consent. No user login system. One password (APPROVE_PASSWORD) decides whether a client gets linked. Rotate it to revoke future linkings.

  • PKCE S256 mandatory. Plain and missing challenges are rejected.

  • Redirect allowlist. Only https://oauth-redirect[-sandbox|-test].googleusercontent.com/[ra]/... is accepted, at registration and at authorize time. This is a fixed constant in oauth.mjs, not a config value; widening it turns the consent page into an open redirect.

  • No plaintext credentials at rest. state.json stores only SHA-256 hashes of client secrets and tokens, written atomically with mode 0600.

  • Timing-safe comparisons for the owner password and client secrets.

  • Loopback bind. 127.0.0.1 only. Body reads are capped at 1 MiB.

  • DCR cap. At most 100 dynamically registered clients.

  • No shell. Every hc invocation is an argv array through execFile, with a 660s hard timeout and a 16 MiB output cap.

What this server does not protect you from

  • herdr_exec and herdr_run are remote code execution by design. Any holder of a valid bearer token can run arbitrary programs as the server's user, on this machine or any machine herdr can reach. Treat an access token as a shell.

  • Token hashes in state.json cannot be reversed, but a stolen state.json still lets an attacker race live tokens; back it up like a credential, or delete it to revoke everything.

  • Tool arguments are logged to stdout, including herdr_send text and herdr_exec argv. Do not send secrets through a terminal you also log.

  • There is no per-client scope or per-tool authorization. Every authenticated client gets every tool.

Report vulnerabilities per SECURITY.md.

License

MIT. See LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      MCP server for SSH and local terminal access. Supports interactive commands, long-running processes, and TUI apps like tmux/zellij
      6
      4
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Bridges stdio-based LLM harnesses to OAuth-protected remote MCP servers via Streamable HTTP, handling PKCE browser login and token refresh automatically.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Exposes a Windows or Linux host terminal to remote MCP clients via Streamable HTTP, enabling command execution, tunnel management, and privileged operations with security features like OAuth and audit logging.
      10 npm
      4
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      A remote Streamable HTTP MCP server that lets web clients like Claude.ai and ChatGPT manage cloud machines with OAuth login — creating, starting, pausing and deleting machines, running commands, reading and writing files, managing snapshots and public ports, and driving an optional Linux desktop via screenshots and input actions. Long-running work can be backgrounded and operations polled, so browser-based clients stay within their timeouts.
      2
      MIT