Skip to main content
Glama

⚡ perch-agent

Delegate tasks from Claude Code / opencode to Perch AI as an autonomous worker agent.

One MCP server. Your orchestrator keeps the plan — Perch does the work, verifies it, and comes back with evidence.

Node MCP License: MIT Tests Bench

Architecture · Quick Start · Tools · Benchmarks · Troubleshooting


🏗 Architecture

perch-agent architecture

Claude Code (or opencode) stays the orchestrator. This server translates one MCP tool call into the official perch CLI (perch run "<task>" --json) — no unofficial internal APIs, no session-token proxying — and returns a structured result: final answer, thread id, model identity and token usage.

Related MCP server: outsrc

✨ Features

  • 🔁 Async job model — long tasks return a job_id in seconds; poll perch_job_status or cancel with perch_job_cancel (kills the whole process tree).

  • 🧭 Karpathy guidelines baked in — every delegated task is prepended with working discipline: surface assumptions, minimal change, surgical scope, verification with real command output. (guidelines: false to disable.)

  • 📊 Live progress — notifications/progress every 5s while a task runs; renders in Claude Code.

  • 🧵 Thread continuation — pass a previous thread_id and the worker remembers the conversation.

  • 🎯 Model pinning — tier (standard/pro) or pin id (qwen-3.8-max, glm-5.3-flash-starter, …).

  • 🧾 Evidence-first output — assistant_text, model_id, usage, thread_id, exit codes, and human-readable plan-gate errors instead of raw stack traces.

  • 🔒 Local-first — everything runs on your machine; the only network hop is the official CLI → Perch's own API, using your existing login. No keys to manage.

  • 🧪 Battle-tested — unit + E2E suite, plus a real benchmark harness (Exercism polyglot, agentic coding, differential reasoning) included in bench/.

🚀 Quick Start (3 Steps)

Step 1 — Prerequisites

  • Node.js 20+

  • Perch CLI installed and logged in (the MCP reuses this session — no API key):

npm i -g perchai-cli
perch login          # browser sign-in (Google/GitHub)
perch status         # must show "Signed in as …"

Step 2 — Get this repo

git clone https://github.com/DMCconnect/perch-agent-mcp.git
cd perch-agent-mcp
npm install
npm test             # parser self-check

Step 3 — Register with your harness

Claude Code (user scope):

claude mcp add --scope user perch-agent \
  -e PERCH_AGENT_MODEL=qwen-3.8-max \
  -e PERCH_AGENT_EFFORT=high \
  -- node "C:/path/to/perch-agent-mcp/index.js"

claude mcp list      # → perch-agent: ✓ connected

For long delegations also set MCP_TOOL_TIMEOUT=900000 in your environment (Claude Code's default MCP call timeout is short).

opencode (~/.config/opencode/opencode.json):

{
  "mcp": {
    "perch-agent": {
      "type": "local",
      "command": ["node", "C:/path/to/perch-agent-mcp/index.js"],
      "enabled": true,
      "timeout": 1200000
    }
  }
}

Any other MCP client — it's a plain stdio server:

command: node <path>/index.js

Done. In your harness, say: "Use perch-agent to fix the failing tests in ./app".

🛠️ Tools

Tool

What it does

delegate_to_perch

Spawn a Perch worker run. Params: task (required), cwd, mode (ask/agents/plan), model, effort, persona, thread_id, guidelines, permission, wait_seconds (default 120), timeout_seconds (default 1800). Finishes inline, or returns {status:"running", job_id} for async handoff.

perch_job_status

Live status/result of a job: state, elapsed, assistant_text, model_id, usage, errors with hints.

perch_job_cancel

Kill a running job's whole process tree (taskkill /T /F).

perch_status

Free local check: CLI version, sign-in state, live job list.

Result shape (success):

{
  "job_id": "pj-95c583b8",
  "status": "finished",
  "perch_status": "completed",
  "ok": true,
  "thread_id": "cli-cwd-a713c141ff2d4ddb",
  "assistant_text": "…final worker answer…",
  "model_id": "Qwen/Qwen3.8-Max",
  "usage": { "input_tokens": 15761, "output_tokens": 30, "total_tokens": 24495 }
}

🎛️ Environment

Variable

Default

Purpose

PERCH_AGENT_MODEL

standard

Default model pin for every delegation.

PERCH_AGENT_EFFORT

high

Default reasoning effort.

PERCH_AGENT_DEFAULT_CWD

OS temp dir

Fallback cwd when the caller omits one.

PERCH_AGENT_CLI

auto-resolve

Explicit path to the CLI's JS entry (see Troubleshooting #1).

🔥 The free Qwen 3.8 Max pin

Qwen 3.8 Max is free on the Perch Starter plan until Nov 20, 2026 (announcement). To make it the default worker:

PERCH_AGENT_MODEL=qwen-3.8-max   PERCH_AGENT_EFFORT=high

After the promo expires, the CLI rejects the pin with a clear plan error — switch back to standard (or any current Starter pin) with one env change.

🧠 The karpathy preamble

Every delegate_to_perch task ships with this discipline header (the whole point of a worker — it must not wander, and it must prove it finished):

1. Think before coding — state your assumptions explicitly…
2. Simplicity first — the minimum change that solves the problem…
3. Surgical changes — touch only what the task requires…
4. Goal-driven verification — run the tests/builds, quote the real command
   and its output as evidence. Never claim verification without evidence.

Disable per-call with guidelines: false.

📈 Benchmarks

Real runs by this repo's harness against the live Perch service (Starter plan), graded objectively — pytest/exit-codes/answer-checking, never the model's self-report:

Suite

Items

standard (Qwen 3.6-35B)

qwen-3.8-max

Math / logic / JS-reasoning

16

16/16

16/16

Exercism polyglot (pytest-graded)

3 exercises

✅ bowling·rectangles·zebra (84–126s)

✅ all (127–153s)

Agentic coding (build / debug-tests / stateful CLI)

3

✅ 3/3

✅ 3/3 (agentic run 2.5× faster)

Mid-run cancellation

—

✅ clean kill

✅ clean kill

Is the pinned model real? Perch's own accounting reports Qwen/Qwen3.8-Max per turn and the timing fingerprint differs from standard per task type — while short-form reasoning scores are tied. Harness: bench/ · methodology borrowed from aider's polyglot benchmark (Exercism + pytest, self-correction loop).

🧪 Testing

npm test              # parser hardening self-check
npm run e2e           # full MCP E2E: happy path, threads, error surfacing, async+cancel
npm run bench:polyglot  # Exercism exercises, pytest-graded (needs: python + pytest)

The E2E covers: inline completion, thread continuation, plan-gate error surfacing, async job_id handoff, and mid-run cancellation.

🔧 Troubleshooting

Symptom

Cause / fix

spawn EINVAL

Node ≥ 20.12 refuses .cmd shims. This repo already resolves the shim to the real JS entry — if you set PERCH_AGENT_CLI, point it at the .js, not the .cmd.

MCP error -32001: Request timed out

Harness-side timeout. Claude Code: set MCP_TOOL_TIMEOUT=900000. opencode: set "timeout": 1200000 in the MCP config (this README's snippet already does).

perch_surface_required / plan errors

Your plan doesn't cover that surface or model pin. The CLI's plan-gate message is surfaced verbatim in error.

Status says "not signed in" but runs work

Stale access token — perch_status reports it before refresh; actual runs refresh lazily and succeed. Cosmetic.

Worker asks instead of writing files

Don't override permission — the default take_the_wheel is required for autonomous delegation.

Headless claude -p flagged [cyber]

The 5.5-model safeguard classifies project context, not just prompts — aggressive AGENTS.md content trips it for any MCP (verified with an independent control). Run -p from a neutral directory, or use interactive sessions.

🤖 For agents (machine-readable)

  • llms.txt — condensed install + tool contract for LLM agents.

  • Tool schemas are standard MCP (tools/list); this server speaks plain stdio JSON-RPC.

  • Safe to auto-install: no telemetry, no keys, no network beyond the official CLI → Perch.

📄 License

MIT — free to use, modify, and share.

🙏 Credits


Available Tools

4 tools
delegate_to_perchDelegate task to Perch AIA
Destructive

Delegate a task to Perch AI (worker agent) via the official perch CLI. Perch runs autonomously in the given working directory with its own tools (bash, file read/write, skills) on the signed-in Perch plan. Karpathy working guidelines (assumptions, simplicity, surgical scope, evidence-based verification) are prepended to every task by default (guidelines:false to disable). Returns the final answer, thread id, and status. Long-running tasks: pass wait_seconds to bound blocking; if still running you get a job_id — poll perch_job_status.

NameRequiredDescriptionDefault
cwdNoWorking directory Perch operates in (default: temp dir).
modeNoagents = autonomous execution with tools; ask = answer only; plan = plan only.agents
taskYesNatural-language task for Perch to execute autonomously.
modelNoModel tier or pinned model id: "standard", "standard 1m", "pro", "pro 1m", or a pin id like "qwen-3.8-max" (free on Starter until 2026-11-20, effort off..high). Defaults to $PERCH_AGENT_MODEL or "standard".standard
effortNoReasoning effort. Defaults to $PERCH_AGENT_EFFORT or "high". Starter plans cap effort at high; some promo models only accept off..high.high
personaNoPerch persona.
thread_idNoContinue an existing Perch thread (from a previous result's thread_id).
guidelinesNoPrepend the karpathy working guidelines (assumptions, simplicity, surgical scope, evidence-based verification) to the task.
permissionNoPerch permission mode. take_the_wheel = never asks before writes/commands (required for autonomous delegation; auto_review makes the worker stop and ask, ending the turn).take_the_wheel
wait_secondsNoSeconds to block waiting for completion before returning a running job_id.
timeout_secondsNoHard limit; the Perch process tree is killed after this.

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With annotations already declaring destructive/openWorld/non-idempotent, the description still adds substantial context: the worker has its own bash and file read/write tools, runs against the signed-in Perch plan, and permission=take_the_wheel means it never asks before writes or commands. It also discloses the return shape and the job_id escape hatch, which is exactly the kind of behavioral detail annotations cannot carry.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the action and the execution model, then the guidelines flag, then the long-running flow — a sensible order with little filler. Minor redundancy: the guideline contents are listed in both the description and the guidelines parameter's schema text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For an 11-parameter open-world delegating tool with no output schema, the description covers the execution model, permission implications, billing surface, return values, and the async continuation path. Nothing an agent needs in order to call it correctly is missing, and secondary params (model, effort, persona) are fully documented in the schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description earns above that by tying two parameters to an workflow: guidelines toggles the prepended guideline block and wait_seconds bounds blocking before a job_id is returned. That causal link is not spelled out in the schema itself.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ("Delegate a task to Perch AI (worker agent) via the official perch CLI") and immediately characterizes the resource: it runs autonomously in a working directory with its own tools. That framing distinguishes it from the sibling polling/status tools, which the description also names.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives concrete operational guidance: use wait_seconds to bound blocking on long tasks, and poll perch_job_status when a job_id comes back; also explains that guidelines:false disables the prepended guidelines. It stops short of saying when not to delegate (e.g., trivial work better handled inline) or when perch_status beats this tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

perch_job_cancelCancel Perch jobB
DestructiveIdempotent

Kill a running delegated Perch job (process tree).

NameRequiredDescriptionDefault
job_idYes

TDQS

B3/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The annotations already declare destructiveHint=true, idempotentHint=true and readOnlyHint=false, so the risk profile is known. The description adds one genuinely useful behavioral detail beyond them: cancellation kills the whole process tree, not just the job record. It does not say whether the call errors on a completed job or whether it waits for termination, and idempotentHint=true is left unexplained.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single front-loaded sentence with zero filler; the action and target come first and the parenthetical scope detail is placed right where it is needed.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive, no-output-schema tool with an undocumented parameter, the description is thin: no return behavior, no handling of already-finished or nonexistent jobs, no source for job_id, and no note that repeated calls are safe despite idempotentHint=true.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The single parameter has 0% schema description coverage (just a string with minLength 1), so the description carries the full burden and says nothing about job_id. It does not state where a job_id comes from (presumably the delegate_to_perch response) or whether a name or prefix could be passed.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

"Kill a running delegated Perch job" gives a specific verb (kill) and a specific resource (a delegated Perch job), and "(process tree)" scopes what kill means. It is clearly distinguishable from the sibling status/delegate tools, though it never names them explicitly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no explicit when-to-use or when-not-to-use guidance and no mention of alternatives such as checking perch_job_status first. The only guidance is implied by the word "running," which hints the job must be active, but nothing says what happens if it already finished.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

perch_job_statusPerch job statusC
Read-onlyIdempotent

Get status/result of a delegated Perch job by job_id.

NameRequiredDescriptionDefault
job_idYes

TDQS

C2.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, idempotentHint=true, destructiveHint=false and openWorldHint=false, so the safety profile is fully covered by structured data. The description adds modest value by indicating the call returns both status and, once ready, the result, but says nothing about whether results expire, whether polling is required, or what terminal states exist.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single sentence, front-loaded with the verb and resource, with no filler or redundancy. It is efficient, though efficiency here comes partly from under-specification rather than tight editing.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with one required parameter, no output schema and no result-format documentation, the description does far too little: it never describes what a 'status' value looks like, whether the call is safe to poll repeatedly (though annotations imply idempotence), or how it relates to perch_job_cancel. The annotations carry the safety story, but the return semantics remain unexplained.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% and the description only restates the parameter name ('by job_id') without format, provenance, or validation details. Since the sole input is required, the description should clarify where the job_id comes from (presumably delegate_to_perch) and that it is not a job name or index.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific verb+resource pair ('Get status/result of a delegated Perch job') and ties it to a job_id, so the agent knows exactly what the tool returns. It stops short of differentiating itself from the sibling perch_status, leaving the boundary between the two ambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no explicit guidance on when to use this versus perch_status or perch_job_cancel, both of which are plausibly relevant to a non-terminal job. The phrase 'delegated Perch job' hints that it follows delegate_to_perch, but that is inference rather than stated guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

perch_statusPerch CLI & server statusA
Read-onlyIdempotent

Free local check (no model call): perch CLI presence and sign-in state, plus this server's live job list. Call before delegating if unsure the worker is ready.

NameRequiredDescriptionDefault

No parameters

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint, idempotentHint, and non-destructive behavior, so the safety profile is covered. The description adds genuinely new context: the check runs locally and costs no model call, which is the key operational fact for an agent deciding whether to probe first.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two tight clauses: what it returns, then when to call it. The cost note ('no model call') is front-loaded alongside the capability, and no sentence is wasted.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-param, no-output-schema probe, the description covers what is inspected and when to use it. It stops short of describing the result shape or what state means 'not ready' (e.g., whether an unsigned CLI is a hard blocker), which would fully close the loop for an agent gating a delegation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool takes zero parameters, so there is nothing for the description to disambiguate. Baseline 4 applies; the schema is empty and fully consistent with the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States precisely what the tool reports: perch CLI presence, sign-in state, and this server's live job list. That enumeration of returned facts distinguishes it from perch_job_status (single-job) and delegate_to_perch (work dispatch) without needing the schemas.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives an explicit call condition — 'Call before delegating if unsure the worker is ready' — which ties it directly to delegate_to_perch. It does not state when to skip it (e.g., if readiness is already known), so it stops short of full when/when-not guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 4 tool updatesv1.0.0
    • First observeddelegate_to_perch
    • First observedperch_job_cancel
    • First observedperch_job_status
    • First observedperch_status

TDQS

A3.5/5.0

Scored across 4 tools

Disambiguation4/5

Each tool maps to a distinct phase of the delegation lifecycle: delegate, poll a job, cancel a job, and check local CLI readiness. The only mild overlap is between perch_status and perch_job_status, but descriptions make clear one is a per-job query and the other a free local sign-in/health check.

Naming Consistency3/5

All names are snake_case and share a perch_ namespace, but the verb/noun ordering is mixed: delegate_to_perch is verb-first, while perch_job_status and perch_job_cancel are noun-first. It is still readable but not a single predictable pattern.

Tool Count4/5

Four tools is thin but well-matched to a focused delegation wrapper: one action plus the poll/cancel/health trio needed to operate it. Nothing feels redundant or gratuitous.

Completeness4/5

The delegated-job lifecycle is covered end to end: readiness check, launch with optional bounded wait, status polling, and cancellation. Minor gaps like explicit job listing or cleanup are largely absorbed by perch_status reporting the live job list.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables orchestrators to drive Claude Code as a structured software-engineering worker over HTTP, with tools to submit coding tasks, poll for normalized results, resume, review, and cancel jobs.
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    Lets an agent delegate coding tasks and reviews to Claude Code, Codex or Grok Build CLIs running locally in isolated git worktrees, then poll an inbox for the status, question or final answer. Each caller sees only its own threads.
    17 npm
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables Codex or Claude Code to orchestrate persistent Antigravity CLI workers as independent implementers and testers within restricted workspace roots. It supports asynchronous task dispatch, progress polling, result inspection, follow-up messages, and cancellation with bounded, audited local event logging.
    32 npm
    4
    MIT