Integration spec · For AI build-agent vendors (Holden Mercer, Cursor, Claude Code)

Wire your agent into Merjax.

Drop-in compatible with GitHub REST v3. One base-URL swap reuses your existing GitHub integration. Copy the block below and paste it to your engineering team — everything they need to ship is in there.

HM × Merjax integration spec

═══════════════════════════════════════════════════════════════════════════════
HOLDEN MERCER × MERJAX INTEGRATION SPEC
What HM needs to change on its side to support Merjax-hosted repos
Merjax API v1.1 — all endpoints below are LIVE (rolled out 2026-05-20)
═══════════════════════════════════════════════════════════════════════════════

TL;DR
─────────────────────────────────────────────────────────────────────────────
Your earlier read of Merjax's API was based on v1, which lacked
/contents, /git/*, and /actions/workflows/:filename/dispatches. Those
gaps are now closed. Shapes match GitHub REST v3 exactly — a base-URL
swap reuses most of your existing GitHub integration. The "clone +
push" workaround you architected still works (path A below); the
native dispatch flow (path B) is now also available if you want it.

Required changes on HM's side
─────────────────────────────────────────────────────────────────────────────

1. ADD MERJAX AS A DESTINATION
   Surface Merjax alongside GitHub in your repo picker. Detect with:

     ["merjax.com","www.merjax.com","gluecron.com","www.gluecron.com"].includes(hostname)
       || hostname === <your MERJAX_HOST>    // self-hosted instances

2. SWAP THE BASE URL
   GitHub:    https://api.github.com
   Merjax:  https://merjax.com/api/v2
              (or https://<MERJAX_HOST>/api/v2 for self-hosted)

3. SWAP THE AUTH TOKEN PREFIX — header name stays
   GitHub:    Authorization: Bearer ghp_…
   Merjax:  Authorization: Bearer glc_…        (PAT, scope=repo)
              Or OAuth:      Bearer glct_…       (admin scope NOT issuable)
              Or App install:Bearer ghi_…

4. CHANGE NOTHING ELSE IN YOUR REQUEST/RESPONSE PARSING
   - Same field names (snake_case)
   - Same status codes
   - Same base64 content encoding
   - Same git-objects API surface

Endpoints HM will call
─────────────────────────────────────────────────────────────────────────────

READ FILES
  GET    /api/v2/repos/:owner/:repo/contents/:path?ref=<branch_or_sha>
         → { type, name, path, size, sha, encoding:"base64", content,
             html_url, download_url }

ATOMIC MULTI-FILE WRITE (preferred for agent turns)
  POST   /api/v2/repos/:owner/:repo/git/blobs
         body: { content, encoding: "utf-8" | "base64" }
         → { sha, url, size }

  POST   /api/v2/repos/:owner/:repo/git/trees
         body: { base_tree?, tree: [{ path, mode:"100644",
                                       type:"blob", sha|null }] }
         → { sha, url, tree[] }
         (sha:null in a tree entry = delete that path from base_tree)

  POST   /api/v2/repos/:owner/:repo/git/commits
         body: { message, tree, parents: [<head_sha>] }
         → { sha, tree, message, parents, author, html_url }

  GET    /api/v2/repos/:owner/:repo/git/refs/heads/:branch
         → { ref, object: { sha, type:"commit" } }

  PATCH  /api/v2/repos/:owner/:repo/git/refs/heads/:branch
         body: { sha: <new_commit>, force?: false }
         → { ref, object }   (422 if not fast-forward and force=false)

OPEN A PULL REQUEST
  POST   /api/v2/repos/:owner/:repo/pulls
         body: { title, body, base, head }
         → { id, number, title, state, html_url, ... }

DISPATCH A NATIVE BUILD ON MERJAX ACTIONS  (optional — path B)
  POST   /api/v2/repos/:owner/:repo/actions/workflows/:filename/dispatches
         body: { ref:"main", inputs?: { prompt, model, … } }
         → 204 No Content

  GET    /api/v2/repos/:owner/:repo/actions/workflows/:filename/runs
         ?branch=&head_sha=&per_page=30&page=1
         → { total_count, workflow_runs:[...] }

  GET    /api/v2/repos/:owner/:repo/actions/runs/:run_id
         → { id, name, head_branch, head_sha, status, conclusion,
             event, created_at, updated_at, run_started_at, html_url }

  GET    /api/v2/repos/:owner/:repo/actions/runs/:run_id/logs
         → application/zip (one .log file per job)

  POST   /api/v2/repos/:owner/:repo/actions/runs/:run_id/cancel
         → 202 Accepted   (409 if already terminal)

  POST   /api/v2/repos/:owner/:repo/actions/runs/:run_id/prioritize
         → 202 Accepted   (409 unless queued; claimed ahead of the queue)

  GET    /api/v2/repos/:owner/:repo/actions/runs/:run_id/pending_deployments
         → [{ environment:{id,name,url}, reviewers:[...], current_user_can_approve }]

  POST   /api/v2/repos/:owner/:repo/actions/runs/:run_id/pending_deployments
         { state: "approved"|"rejected", environments?:[...], comment? }
         → { decided, resumed, pending }   (403 unless a reviewer)

User-side workflow file  (one-time setup per repo, for path B)
─────────────────────────────────────────────────────────────────────────────

If HM dispatches via path B, the user's repo needs a YAML committed to
.merjax/workflows/holden-mercer.yml. Recommend this template:

  name: Holden Mercer build agent
  on:
    workflow_dispatch:
      inputs:
        prompt:
          description: What the agent should build / fix
          required: true
          type: string
        model:
          description: Anthropic model to use
          required: false
          default: claude-haiku-4-5
          type: string
  jobs:
    agent:
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v4
        - name: Run HM agent
          env:
            ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
            HM_PROMPT:         ${{ inputs.prompt }}
            HM_MODEL:          ${{ inputs.model }}
          run: npx @holden-mercer/agent run

Two integration paths — pick one (or offer both in HM's UI)
─────────────────────────────────────────────────────────────────────────────

PATH A — Your-backend mode  (matches your original v1 workaround)
   1. Clone the repo using a credential helper (NOT URL-embedded token):
      git -c credential.helper=… clone https://merjax.com/:owner/:repo.git
   2. Run the tool-use loop on HM's backend against local files
   3. Push the result via the git-objects API (one atomic commit):
      POST /git/blobs → /git/trees → /git/commits → PATCH /git/refs/heads
   4. POST /pulls to open the PR
   Pros: full control, you own compute. Cons: you bear all build minutes.

PATH B — Merjax-native mode  (uses our runner)
   1. POST /actions/workflows/holden-mercer.yml/dispatches with inputs
   2. Your agent code runs inside Merjax Actions on the user's repo
   3. The runner pushes commits + opens the PR itself
   Pros: zero infra on your side, lower egress. Cons: Merjax concurrency
   + timeout limits apply per tier.

Both paths supported. Most vendors ship A first, add B later as an opt-in.

Webhook callback  (optional but recommended)
─────────────────────────────────────────────────────────────────────────────
Subscribe to pull_request + workflow_run events at
  /:owner/:repo/settings/webhooks
HMAC signature header:  X-Merjax-Signature: sha256=<hex>
Delivery:               at-least-once with exponential backoff
                        (30s, 2m, 10m, 1h, 6h — max 6 attempts then
                        dead-letter)
Dedupe with:            X-Merjax-Delivery: <uuid>

Compatibility checklist  (matches GitHub REST v3 by design)
─────────────────────────────────────────────────────────────────────────────
[x] Same endpoint shapes
[x] Same field names (snake_case)
[x] Same base64 content encoding
[x] Same status codes
[x] Same git plumbing API (blobs / trees / commits / refs)
[x] Same workflow_dispatch shape
[x] HMAC-SHA256 webhook signatures
[x] PKCE OAuth (RFC 7636)
[x] Pagination via ?limit, ?offset (default 30, max 100)

Differences to flag in HM's client code
─────────────────────────────────────────────────────────────────────────────
- Token prefix:    glc_ (PAT) / glct_ (OAuth) / ghi_ (app install)
- Pagination:      ?limit not ?per_page  (recommend limit)
- OAuth scopes:    namespaced — read:repo / write:repo  (admin NOT issuable)
- Webhook header:  X-Merjax-Signature  not  X-Hub-Signature-256

Estimated work on HM's side
─────────────────────────────────────────────────────────────────────────────
- UI change (add Merjax destination)          ~2-4 hrs
- API client base-URL/token swap                ~2-3 hrs
- Webhook handler for X-Merjax-Signature      ~1 hr
- Path B dispatch integration  (optional)       ~4-6 hrs
TOTAL minimum (paths A only):  ~5-8 hrs
TOTAL with path B as well:     ~10-15 hrs

Support
─────────────────────────────────────────────────────────────────────────────
Live spec:   https://merjax.com/docs/build-agent-integration  (this page)
Status:      https://merjax.com/admin/health
Issues:      https://merjax.com/ccantynz/Gluecron.com/issues
Contact:     ccantynz on merjax.com
═══════════════════════════════════════════════════════════════════════════════
Share this page directly: https://merjax.com/docs/build-agent-integration

MCP tools — every Merjax action callable from any AI agent

═══════════════════════════════════════════════════════════════════════════════
MERJAX MCP TOOL SURFACE  (50+ tools, model-context-protocol/2025-06-18)
═══════════════════════════════════════════════════════════════════════════════

Transport:  POST /mcp           — JSON-RPC 2.0 (single or batch)
            GET  /mcp           — discovery handshake
Auth:       same as REST v2     — Bearer glc_… (PAT) or session cookie
            agent tokens (agt_…) routed via agent-multiplayer

Call shape:
  {
    "jsonrpc": "2.0", "id": 1,
    "method": "tools/call",
    "params": { "name": "<tool_name>", "arguments": { … } }
  }

Sign-in:    initialize and tools/call need credentials; without them the
            answer is 401 with a WWW-Authenticate challenge (OAuth).
            tools/list is readable by anyone.
Failures:   a tool that refuses answers HTTP 200 with
            result.isError = true and the reason in result.content[0].text.
            A JSON-RPC "error" means the request itself was malformed or the
            tool name is unknown.

─── READ TOOLS (public repositories) ────────────────────────────────────────
merjax_repo_search                Search public repos by keyword
merjax_repo_read_file             Read a file at a ref
merjax_repo_list_issues           List open issues on a repo
merjax_repo_explain_codebase      Cached AI 'explain this codebase' markdown
merjax_repo_health                Health score + breakdown for a repo

─── REPOS (write — requires 'repo' or 'admin') ──────────────────────────────
merjax_fork_repo                  Fork a repo to the caller's namespace
merjax_delete_repo                Delete a repo — soft, restorable for 90 days (owner or site admin)
merjax_update_repo                Description / visibility / default branch
merjax_search_repos               Full search (sort, limit, filters)
merjax_clone_url                  Authed HTTPS clone URL + helper hint
merjax_create_deploy_token        Short-lived repo-scoped clone token, by
                                    one-time exchange (no secret in the
                                    transcript; read-only default, 2 h / max 24 h)

─── ISSUES (write — requires 'repo') ────────────────────────────────────────
merjax_create_issue               Open a new issue
merjax_comment_issue              Add a comment
merjax_close_issue                Close an open issue (idempotent)
merjax_reopen_issue               Reopen a closed issue
merjax_label_issue                Attach labels to an issue or PR (type: pull_request; priority needs admin)
merjax_unlabel_issue              Detach a single label from an issue or PR
merjax_assign_issue               Assign or unassign users (real assignees, max 10)
merjax_search_issues              Title/body keyword search per repo

─── PULL REQUESTS (write — requires 'repo') ─────────────────────────────────
merjax_create_pr                  Open a PR
merjax_open_draft_pr              Open a draft PR
merjax_set_pr_draft               Mark a PR ready for review / back to draft
merjax_get_pr                     Fetch full PR record
merjax_list_prs                   List PRs by state
merjax_search_prs                 Keyword search on title/body
merjax_list_pr_comments           Read a PR's comments, review threads and reviews in order
merjax_comment_pr                 Add a PR comment
merjax_request_changes            Record a 'changes requested' review (holds the merge)
merjax_approve_pr                 Approve a PR (counts toward required approvals)
merjax_merge_pr                   Merge a PR (enforces every gate + risk score)
merjax_close_pr                   Close without merging (idempotent)
merjax_generate_pr_description    AI commit-message-style description
merjax_update_pr_branch           Merge base into head server-side;
                                    conflicts listed, nothing changed
merjax_update_pr                  Edit title / body / base / draft (author or write)
merjax_set_auto_merge             Arm / disarm per-PR auto-merge (gated chain)
merjax_get_pr_checks              Checks at the head: conclusion, required, log URL
merjax_get_branch_protection      Protection rule + required checks for a branch
merjax_set_branch_protection      Set protection / required checks (admin)
merjax_set_merge_train            Merge-train batch size 1-16 (admin)

─── FILES & GIT PLUMBING (write — requires 'repo') ──────────────────────────
merjax_read_file                  GET /contents wrapper
merjax_write_file                 PUT /contents wrapper (utf8 or base64)
merjax_delete_file                DELETE /contents wrapper
merjax_list_tree                  GET /tree wrapper (recursive supported)
merjax_get_commit                 GET /commits/:sha wrapper
merjax_create_branch              Create a new branch ref at a sha
merjax_atomic_multi_file_commit   blob/tree/commit/ref-update in one call
                                    — the killer agent tool
merjax_apply_patch                Commit a git diff / format-patch (no
                                    whole-file uploads; CAS + push gates)

─── AI WORKFLOWS (Merjax-native — requires 'repo') ──────────────────────────
merjax_ship_spec                  Drop .merjax/specs/*.md status:ready
merjax_voice_to_pr                Transcript → spec or issue (auto-classified)
merjax_refactor_across_repos      Plan + execute a multi-repo refactor
merjax_explain_repo               Cached 'explain this repo' markdown
merjax_chat_with_repo             Start a chat + send the first message
merjax_chat_continue              Send another message in a chat
merjax_generate_tests             AI tests for a PR (follow-up-pr / append)
merjax_generate_commit_message    Conventional / plain commit message for a diff
merjax_generate_release_notes     Section-bucketed notes between two tags
merjax_propose_migration          Dep-upgrade PR via migration-assistant
merjax_propose_doc_update         Doc-drift scan + PR opens

─── CI / DEPLOYS (write — requires 'repo') ──────────────────────────────────
merjax_trigger_workflow           workflow_dispatch
merjax_get_workflow_run           Run status + metadata
merjax_get_workflow_logs          Per-step status + failedSteps +
                                    testFailures (marked flaky / known /
                                    new); step / tail_lines filters
merjax_rerun_failed_jobs          Re-run a failed / cancelled run at the same commit
merjax_list_flaky_tests           Flaky tests: forensic repro, owner, expiry
merjax_explain_failure            Failure class + seen-before matches +
                                    the fix that worked last time
merjax_cancel_workflow_run        Cancel queued/running run
merjax_prioritize_workflow_run    Queued run jumps the CI queue
merjax_review_deployment          Approve/reject jobs waiting on an environment
merjax_create_runner_registration_token  One-time token to register a CI runner
merjax_list_runners               An owner's CI runners + online state
merjax_revoke_runner              Stop dispatching to a CI runner
merjax_get_preview_url            Branch-preview URL + status
merjax_provision_pr_sandbox       Re-provision a PR sandbox

─── AGENTS (multiplayer surface — admin to mint, repo to lease) ─────────────
merjax_create_agent_session       Mint agent token (returned ONCE) (admin)
merjax_acquire_lease              Grab an exclusive target lease
merjax_release_lease              Release a held lease
merjax_get_agent_budget           spent / cap / remaining cents

─── SEMANTIC ────────────────────────────────────────────────────────────────
merjax_semantic_search            Vector-index query (Voyage or hash)
merjax_search_code                Literal/regex git grep — works on every repo, indexed or not
                                    (path / glob / files_only / ignore_case)
merjax_find_symbol                findDefinitions wrapper

─── INSIGHTS ────────────────────────────────────────────────────────────────
merjax_pr_status_summary          State + risk + trio verdict for a PR
merjax_ci_queue_status            Queue level, ETA, repo share + what to do
merjax_repo_health                (also under READ; included here for parity)
merjax_ai_cost_summary            Spend rollup (user / repo / agent)

═══════════════════════════════════════════════════════════════════════════════
JSON-RPC 2.0 endpoint: POST https://merjax.com/mcp — send { method: "tools/list" } to enumerate at runtime.
Looking for the full Merjax platform spec? See /help and /admin/integrations for env-var setup.