handinloop-mcp-server
v0.5.0Human-in-the-loop document extraction: submit a doc, get validated fields and an audit trail.
MCP server that lets AI agents — including Claude's scheduler/routines — submit document extraction jobs to HandInLoop's human-in-the-loop platform and get back human-validated results with per-field confidence and a full audit trail. Async by design: submit returns a job_id; the agent polls status and fetches the result when complete. This matches real human turnaround (minutes–hours) and Claude's scheduled routines (submit on one run, collect on the next). Once published to npm, run it without a local checkout:
Summary extracted from the README.
handinloop-mcp-server (POC)
MCP server that lets AI agents — including Claude's scheduler/routines — submit document extraction jobs to HandInLoop's human-in-the-loop platform and get back human-validated results with per-field confidence and a full audit trail.
Async by design: submit returns a job_id; the agent polls status and fetches the result
when complete. This matches real human turnaround (minutes–hours) and Claude's scheduled
routines (submit on one run, collect on the next).
Tools
| Tool | Purpose |
|---|---|
handinloop_list_task_types |
Discover supported document types and their output fields |
handinloop_propose_fields |
Given a document, propose the fields worth extracting — feed them straight into a custom extraction |
handinloop_save_task_type |
Save a field set as a reusable task type — submit against its id later instead of re-sending fields. It can also carry the type's own model instructions (prompt_template) and a sign-off gate |
handinloop_get_task_type |
Read one of your saved task types, including its prompt_template and gate |
handinloop_estimate_cost |
What a batch will cost before you submit it: pages × the task type's rate, with no side effect (#788) |
handinloop_submit_extraction_job |
Submit a document (URL or base64) for a built-in task_type or a custom fields set you describe — extract anything, human-verified |
handinloop_get_job_status |
Poll: queued → in_review → completed / rejected |
handinloop_get_job_result |
Fetch validated fields + line items + audit trail |
Install
Once published to npm, run it without a local checkout:
npx handinloop-mcp-server
Or add it to an MCP client (Claude Desktop / Claude Code):
{
"mcpServers": {
"handinloop": {
"command": "npx",
"args": ["-y", "handinloop-mcp-server"],
"env": { "HANDINLOOP_CLIENT": "mock" }
}
}
}
Set HANDINLOOP_CLIENT=http with HANDINLOOP_API_KEY to talk to the live API (see Backend wiring). The server calls your organisation's region, read from the key's prefix (see Regions).
Quick start from source (mock mode — no backend needed)
npm install
npm run build
node scripts/smoke-test.mjs # runs the full submit → poll → result loop
Mock mode simulates the human lifecycle (5s queue + HANDINLOOP_MOCK_TURNAROUND_SECONDS,
default 20s) and returns realistic invoice/freight-invoice/health-claim results. Jobs are
in-memory and lost on restart.
Claude Desktop / Claude Code config
{
"mcpServers": {
"handinloop": {
"command": "node",
"args": ["/absolute/path/to/handinloop-mcp-server/dist/index.js"],
"env": { "HANDINLOOP_CLIENT": "mock" }
}
}
}
Demo prompt to try: "List the HandInLoop task types, submit https://example.com/invoice.pdf as an invoice job, wait for it to complete, and give me the total with its audit trail."
Regions
Each organisation is served from one region, and its documents never leave it
(ADR-004). The API key says which: hil_sg_… is Singapore, hil_us_… the United
States, and a key with neither prefix is Singapore's. The base URL is chosen in
this order:
HANDINLOOP_API_URL, when set — e.g.https://api.handinloop.com/v1, the Singapore alias an existing allowlist may already name.HANDINLOOP_REGION(sgorus) — refused at start-up if it contradicts the key's region (a key with no prefix is Singapore's).- The key's own region:
https://api.sg.handinloop.com/v1orhttps://api.us.handinloop.com/v1.
A key sent to the other region's host gets 421, and the error names the right host.
Backend wiring (the real work)
Set HANDINLOOP_CLIENT=http and HANDINLOOP_API_KEY. HANDINLOOP_API_URL (base URL
includes /v1) is optional; see Regions. src/httpClient.ts is wired to the live contract in
contract/openapi.yaml:
| Endpoint | Returns |
|---|---|
GET /task-types |
{ task_types: TaskType[] } |
POST /jobs |
JobSummary (accepts SubmitJobRequest) |
GET /jobs/:id |
JobSummary |
GET /jobs/:id/result |
JobResult |
GET /jobs (the account's job list) is bounded and keyset-paginated by
default since contract 0.2.0, with a Deprecation-flagged ?all=true
opt-out withdrawn in 0.3.0 (#893) — a documentation note only: no MCP tool
here calls it (handinloop_list_task_types, handinloop_get_job_status and
handinloop_get_job_result are the only listing/read tools, and none of them
wraps this endpoint), so nothing in src/ changes.
Auth is Authorization: Bearer <key> with a portal-issued API key — the portal's Google
OAuth session flow doesn't apply to machine clients. Keys belong to the organisation, not
to whoever created them (#582): an organisation admin or engineer creates one on the
portal's API keys page, and it keeps working until someone revokes it. A key's scopes
bound which tools answer — the wire protocol is unchanged, the API simply refuses a call
outside them and the tool reports which scope is missing:
| Scope | Tools it admits |
|---|---|
read |
handinloop_list_task_types, handinloop_get_task_type, handinloop_estimate_cost, handinloop_get_job_status, handinloop_get_job_result, handinloop_get_pilot_run |
submit |
handinloop_submit_extraction_job, handinloop_submit_pilot_batch, handinloop_propose_fields |
callback |
a callback_url on a submit (on top of submit) |
submit + read |
the two API writes that answer with report data — freezing a pilot report, sharing a batch report (no MCP tool calls either) |
review |
the review plane, for a reviewer-side agent — never on by default |
workflows |
handinloop_save_task_type (and deleting a task type through the API) — never on by default (#951): a saved type changes what every later job extracts |
A key carries its region in its prefix (hil_sg_…, hil_us_…); sent to another region's
API it is refused with the host to use instead.
Field shapes live in src/types.ts; the MCP tool layer is transport-agnostic and stays
unchanged across mock/http.
Publishing (maintainers)
.github/workflows/publish-mcp.yml publishes on a GitHub Release, to two places:
- npm — via the
NPM_TOKENrepo secret (an npm "Automation" token; no localnpm login). - The official MCP registry (
io.github.lesofi/handinloop-mcp-server) — via GitHub OIDC, which proves ownership of theio.github.lesofi/*namespace with no secret.
The registry links to the npm package via matching identifiers: package.json's mcpName
must equal server.json's name, and the version must match across package.json,
server.json, and the release tag (the workflow enforces this).
To release:
- Bump
versionin bothpackage.jsonandserver.json(e.g.0.1.1→0.1.2) and merge. - Create a GitHub Release tagged
v<version>(e.g.v0.1.2). - The workflow builds,
npm publishes, then publishesserver.jsonto the MCP registry.
POC success criteria
- A scheduled Claude routine submits a real invoice, the client's own team clears any exceptions in the review screen, validated JSON comes back. Measure end-to-end turnaround.
- Five conversations with agent builders using the working demo. The demo exists to make those conversations concrete — not to scale.
Out of scope (resist): billing, SLAs, webhooks, multi-tenant auth, remote HTTP transport, the generic task UI. Any of these gets built only after demand shows up.