MCP server
Let a bot ask a human through HITLy over Model Context Protocol.
The HITLy MCP server lets a bot pause and ask a person (on the HITLy inbox) for an approval or an answer, then carry on once the human has decided. It speaks Streamable HTTP MCP - async-first: every create returns immediately with state: "pending"; there is no wait or long-poll. A bot can request, read and cancel; it can never decide - decisions come only from a signed-in human in the HITLy inbox.
Endpoint and transport
https://mcp.hitly.net/mcpThe server speaks JSON-RPC 2.0 over Streamable HTTP at /mcp. If you self-host HITLy, run the @hitly/mcp app behind your own reverse proxy and substitute your host (all runtime settings are environment variables: HITLY_MCP_HOST/HITLY_MCP_PORT to listen on, HITLY_API_URL for the HITLy host API, HITLY_MCP_PUBLIC_URL for the public origin of this MCP server).
The server is stateless: it issues no Mcp-Session-Id and keeps no session between calls. Every POST carries the full JSON-RPC body and the Authorization header - there is no per-session handshake to reattach, and a server restart loses nothing. Responses are application/json. Only POST /mcp is accepted: a GET asking for text/event-stream gets 405 (there is no server-initiated SSE stream), which is why MCP clients take a callback or poll get_decision. A plain browser visit (a GET with an HTML Accept and no credentials) is redirected here, to this page. The request body is capped at 1 MiB.
Auth
Every request authenticates with a HITLy project API key in the header:
Authorization: Bearer <your-project-api-key>- Where to create it: open your project in the HITLy web app and copy (or create) an API key under Config in the project's settings - the same key the HTTP plugin uses for ingest. Keys start with
hitly_. - Keep it secret. Anyone with the key can create, read and cancel your project's MCP requests. Do not commit it to a repository or embed it in client-side code; rotate it from the project settings if it leaks.
- Scope. The key is a requester credential: it can call
request_approval,ask_user,get_decision,list_pendingandcancel, and only for requests that same key created - requests created with a key are readable and cancellable only with that key. It cannot decide: there is deliberately no decide tool. - A missing or malformed key gets
401with aWWW-Authenticate: Bearer realm="hitly-mcp"challenge. (Resume tokens,hitly_resume_..., are a different credential and are refused here.) - Each key has a request-rate budget (default 120 requests per minute); exceeding it answers
429with aRetry-Afterheader. The budget is per process by default; setHITLY_MCP_DATABASE_URLto the app's Postgres so every MCP replica counts against one shared budget through the samerate_limit_bucketstable the web app uses (keys are stored only as hashes). Tune withHITLY_MCP_RATE_LIMIT/HITLY_MCP_RATE_LIMIT_WINDOW_MS;HITLY_MCP_RATE_LIMIT=0disables limiting.
Set up a client
Replace <mcp-host> with the host your HITLy MCP server is served on and <your-project-api-key> with your project API key. The endpoint is a Streamable HTTP MCP server; every example authenticates with Authorization: Bearer <your-project-api-key>.
Grok Bot (custom MCP connector)
A Grok Bot agent connects over Streamable HTTP by adding a custom MCP connector that points at the URL and passes the key in the header:
{
"mcpServers": {
"hitly": {
"url": "https://<mcp-host>/mcp",
"headers": { "Authorization": "Bearer <your-project-api-key>" }
}
}
}When the agent calls request_approval it passes callback_url (its own agent webhook, e.g. https://example.com/hooks/hitly) and a cb_auth_token secret (see Callbacks), so it is woken when the human decides.
If the connector plugin exposes a webhook routine for waking the bot, register that URL once instead of handing the bot a secret to pass on every request:
- Create the webhook routine in the Grok connector plugin and copy its URL and the signing secret the platform shows you.
- In HITLy, open Project settings → Callbacks, paste the URL, pick the auth mode the platform shows you (Bearer token, Standard Webhooks, or GitHub X-Hub-Signature-256), paste the secret, and save. The secret is write-only: it is never displayed again, so keep the value the platform showed you. It is stored with the project's credentials — encrypted at rest on HITLy Cloud, and in the credentials column as written on the open-source edition.
- Tell the bot to pass that same URL as
callback_url. Because the URL is registered on the project, HITLy authenticates the delivery from the registration — nocb_auth_tokenneeded.
A callback_url that is not registered still needs cb_auth_token to arrive authenticated, and get_decision still confirms the outcome either way.
Claude Desktop / Claude Code
Claude Desktop config (claude_desktop_config.json), via the mcp-remote stdio bridge:
{
"mcpServers": {
"hitly": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://<mcp-host>/mcp", "--header", "Authorization: Bearer <your-project-api-key>"]
}
}
}Claude Code can register the remote server directly:
claude mcp add --transport http hitly https://<mcp-host>/mcp --header "Authorization: Bearer <your-project-api-key>"Claude Desktop builds that accept remote Streamable HTTP servers natively can use the plain url + headers form shown for Cursor instead.
Cursor
Project-level .cursor/mcp.json (or the global MCP settings):
{
"mcpServers": {
"hitly": {
"url": "https://<mcp-host>/mcp",
"headers": { "Authorization": "Bearer <your-project-api-key>" }
}
}
}Protocol flow
The server speaks JSON-RPC over Streamable HTTP at /mcp. In order:
initialize- POST yourprotocolVersion,capabilitiesandclientInfo; the server answers with its capabilities andinstructions(the rules: pending is never approval, confirm withget_decision).tools/list- returns the tools and their input schemas.tools/call- one POST per call, e.g.{"method":"tools/call","params":{"name":"request_approval","arguments":{…}}}.
Async-first pattern
Creating never blocks:
- Call
request_approvalorask_user- you getrequestIdandstate: "pending"back immediately. - Carry on with other work; do not busy-wait.
- React to the callback if you passed
callback_url, or pollget_decisionpolitely (every 30-60 s, backing off) until thedeadline. - Act only on what
get_decisionconfirms.pending,expiredandcancelledare never approval.
When you omit deadline, the expiry the host stores follows a fixed precedence: the matched rule's SLA first, then the project's default timeout, then the published 24 h default. An explicit deadline beats all of them and is never clamped down to the project's timeout; it must be in the future and at most 30 days out. Expiry is never approval.
Retrying a create with the same idempotencyKey returns the same request (replayed: true) instead of asking the human twice.
Tools
The server exposes exactly five tools: request_approval, ask_user, get_decision, list_pending, cancel. All tools return their result as JSON in structuredContent (mirrored in a text content block); errors come back as { "error": { "code", "message" } } with isError: true.
request_approval and ask_user share these common optional arguments:
| Argument | Type | Description |
|---|---|---|
context | string (≤ 64 000 chars) | Markdown detail shown to the reviewer. |
deadline | string (ISO 8601 date-time) | When the ask expires. An explicit deadline always wins; omitted, the host falls back to the matched rule's SLA, then the project's default timeout, then 24 h. Max 30 days out. |
callback_url | string (https URL) | URL HITLy POSTs the outcome to. If omitted, no callback is sent at all - poll get_decision (see Callbacks). |
cb_auth_token | string (16-512 chars) | Secret HITLy sends back on every callback so only your endpoint accepts it. Never echoed back to you. |
request_approval
Ask a human to Approve, Reject or Ignore an action.
| Argument | Required | Type | Description |
|---|---|---|---|
idempotencyKey | yes | string (8-200 chars, printable ASCII, no spaces) | Stable key for this ask (e.g. hash of bot id, task id, action name and args). Retries return the same request. |
question | yes | string | One sentence on one line, at most 160 characters, ending with ?. |
action | yes | object { name, args } | name: string (1-200 chars). args: object (defaults to {}) - the arguments of the action to be approved. |
risk | no | "low" | "medium" | "high" | Recorded on the request for the reviewer. |
reasonRequired | no | array of "approve" | "reject" | "ignore" | The reviewer must give a reason when acting with these outcomes. |
links | no | array (≤ 20) of { url, label?, mustOpen? } | https links for the reviewer (label ≤ 200 chars); mustOpen gates Approve/Reject until opened. HITLy never fetches them. |
| common optional arguments | no | see above | context, deadline, callback_url, cb_auth_token. |
{ "name": "request_approval", "arguments": {
"idempotencyKey": "refund-1842-40gbp",
"question": "Send the refund of £40 to order 1842?",
"action": { "name": "send-refund", "args": { "orderId": "1842", "amount": 40 } },
"risk": "high",
"context": "Customer reported a delivery failure; policy allows refunds under £50.",
"callback_url": "https://example.com/hooks/hitly",
"cb_auth_token": "<your-callback-token>"
} }Response (immediate):
{ "requestId": "<request-id>", "state": "pending", "replayed": false,
"argsHash": "b64url-sha256-of-args", "deadline": "2026-11-11T09:00:00.000Z",
"callback": true, "reviewUrl": "https://<hitly-host>/inbox/<request-id>" }argsHash is b64url(SHA-256(JCS(action.args))) (RFC 8785 canonicalisation) - the hash of the arguments as originally sent. deadline is the expiry the host stored; callback is true only when you passed callback_url.
ask_user
Ask a question and get a typed answer later.
| Argument | Required | Type | Description |
|---|---|---|---|
idempotencyKey | yes | string (8-200 chars, printable ASCII, no spaces) | As for request_approval. |
prompt | yes | string | The headline the reviewer sees: one sentence on one line, at most 160 characters, ending with ?. |
detail | no | string (≤ 8 000 chars) | Markdown rendered under the headline (must not be blank if sent). |
answerSchema | yes | object { type, options?, bounds? } | The typed answer, described below. |
| common optional arguments | no | see above | context, deadline, callback_url, cb_auth_token. |
answerSchema.type is the spec name text, single, multi or number (the legacy aliases free_text, single_choice, multi_choice are accepted on input and stored as the spec name). single and multi require options (1-20 items, values distinct); the other types take none. Options are plain strings (value = label) or { value, label?, description? }. bounds constrains the answer: min/max/step/unit for number, minLength/maxLength/pattern for text, minItems/maxItems for multi.
Ask one question per ask_user request. In hitl/v0 the reviewer answers exactly one ask, so a form with several fields gets you one answer, not per-field answers - issue one ask_user per field instead. simple_form is refused with an error: ask_user accepts only text, single, multi and number answer schemas, so send a separate ask_user for each field.
{ "name": "ask_user", "arguments": {
"idempotencyKey": "refund-1842-colour",
"prompt": "Which colour should we ship as the replacement?",
"detail": "The customer returned a **blue** mug; we have blue, green and red left.",
"answerSchema": { "type": "single", "options": ["blue", "green", "red"] }
} }Response: the same pending shape minus argsHash (ask_user sends no action arguments): { "requestId": "<request-id>", "state": "pending", "replayed": false, "deadline": "…", "callback": false, "reviewUrl": "https://<hitly-host>/inbox/<request-id>" }.
get_decision
Non-blocking read of a request, as a hitl/response/v0 object.
| Argument | Required | Type | Description |
|---|---|---|---|
requestId | yes | string (1-64 chars, [A-Za-z0-9_-]) | The requestId returned at create. |
{ "name": "get_decision", "arguments": { "requestId": "<request-id>" } }Answered example (an ask_user reply):
{ "spec": "hitl/response/v0", "requestId": "<request-id>", "status": "answered",
"answer": { "kind": "single", "value": "blue" },
"reason": "fine to ship", "decidedBy": { "kind": "human", "id": "usr_…", "display": "A. Reviewer" },
"decidedAt": "2026-11-10T10:02:00.000Z", "argsHash": "b64url-sha256-of-args",
"activity": { "presentedAt": "2026-11-10T09:58:00.000Z", "items": [] } }Fields:
statusis one ofpending,answered,declined,cancelled,expired.- The typed
answeris an object{ kind, value }.kindis the stored answer type - one oftext,single,multi,number(the aliases you may have sent inanswerSchema.typeare normalised on input, sosingle_choicecomes back assingle).valueis the reviewer's reply for that type: a string fortextandsingle, an array of strings formulti, a finite number fornumber. HITLy stores and returns it unmodified - use it verbatim. - The top-level
valuecarries the decision value for approve/reject/respond ("approve","reject", or the reply text). A decided response carries eitheranswer(anask_userreply) or the decision fields (valueetc.) - never both. reason,decidedBy({ kind, id, display? }),decidedAt,argsHashandactivityare present when the host has them.callbackDeliveryreports callback delivery:"none"for requests created withoutcallback_url(no callback was attempted),"failed"when the callback could not be delivered. A successful delivery adds nothing.
editedArgs
If the reviewer amended the action's arguments, get_decision includes editedArgs with the full merged arguments. The stored request and its argsHash stay original - act on editedArgs when present, not your original args. An edit decision that arrives without editedArgs is reported as declined, never as approval (fail closed).
list_pending
List requests created with your key that still await a human.
| Argument | Required | Type | Description |
|---|---|---|---|
projectId | no | string (≤ 64 chars) | Restrict to one project. |
cursor | no | string (≤ 512 chars) | The opaque nextCursor from a previous page. |
{ "name": "list_pending", "arguments": { "projectId": "prj_…" } }Response: { "items": [ { "id": "…", "kind": "question", "question": "…", "createdAt": "…", "deadline": "…" } ], "nextCursor": null } - items carry id, kind, and whichever of question/prompt, createdAt, deadline/expiresAt, status the host stores. Pass nextCursor back as cursor to page through results. A request a human already decided whose resume then failed (failed_resume) is not listed - its outcome and the failed delivery (callbackDelivery: "failed") come back from get_decision. On a host without a key-scoped pending list yet, the tool answers the error not_supported_by_host.
cancel
Withdraw an open request your key created.
| Argument | Required | Type | Description |
|---|---|---|---|
requestId | yes | string (1-64 chars, [A-Za-z0-9_-]) | The requestId returned at create. |
reason | no | string (≤ 500 chars) | Why the request is withdrawn (recorded for the reviewer). |
{ "name": "cancel", "arguments": { "requestId": "<request-id>", "reason": "order refunded by hand" } }Response: { "requestId": "<request-id>", "state": "cancelled" }. Cancelled is never approval. Cancelling a request another key created fails; some hosts do not yet enable requester cancel with an API key and answer unauthorized.
Project status errors
A project can be live, paused or archived (set by an owner in the project settings). Creates and mutations against a non-live project are refused by the host with HTTP 409; MCP tools report them in the standard error envelope { "error": { "code", "message" } } with isError: true:
| Tool | paused project | archived project |
|---|---|---|
request_approval, ask_user | fails - project paused | fails - project archived |
get_decision, list_pending | readable | readable |
cancel | works | fails - project archived |
Over REST the host's exact bodies are { "error": "project paused", "code": "project_paused" } and { "error": "project archived", "code": "project_archived" } (HTTP 409). The MCP layer forwards the host's message verbatim - the tool message is exactly project paused or project archived - and reports the generic client-facing code for the status (invalid_request for 409). Pausing a project stops new asks; reviewers can still decide, and cancel still works on open requests. Archiving additionally refuses cancel and resume retries; stored requests stay readable.
Callbacks
request_approval and ask_user accept two optional fields:
callback_url- an https URL that HITLy POSTs to when the request is decided (or answered). If you do not pass it, HITLy sends no callback at all and you pollget_decisioninstead.cb_auth_token- a secret of 16-512 characters. HITLy sends it back on every callback asauthorization: Bearer <your-callback-token>, so you can verify the delivery is yours and only your endpoint accepts it. It is never echoed back to you. (If the tool reports your host does not supportcb_auth_tokenyet, omit it and useget_decision.)
Registered callbacks (no per-request secret needed). If the URL is registered under Project settings → Callbacks for the project, an operator stores the URL and its shared secret once and picks an auth mode - Bearer token, Standard Webhooks (webhook-id, webhook-timestamp, webhook-signature: v1,<base64 HMAC>), or GitHub X-Hub-Signature-256 (sha256=<hex HMAC of the body>). When callback_url matches a registered URL exactly, HITLy authenticates the delivery from that registration and the request needs no cb_auth_token. The match is exact (scheme, host, port, path and query all significant) and per project; an unregistered URL behaves exactly as before and still needs cb_auth_token to be authenticated. The stored secret is never returned by the API or shown in the UI after saving. See HTTP → Registered callbacks for the receiver-side verification of each scheme.
The callback is only a hint. A callback tells you an outcome may exist. Always confirm with get_decision before acting - it is the source of truth, and callback delivery can fail (the read then reports callbackDelivery: "failed").
What the POST looks like
Headers: content-type: application/json, plus authorization: Bearer <your-callback-token> when you passed one (or when the URL is registered with the Bearer token mode). When webhook signing is enabled for your project, four more headers arrive: x-hitly-timestamp (unix seconds), x-hitly-signature (hex HMAC-SHA256 over "<timestamp>.<raw body>"), x-hitly-event-id (dedupe on this - retries reuse it), and x-hitly-key-id (which signing key signed). Without a signing secret, only x-hitly-event-id is sent. Receivers should reject timestamps more than 5 minutes off. A Standard Webhooks or X-Hub-Signature-256 registration adds its own scheme headers alongside the x-hitly-* set, never instead of it.
The JSON body for a decided approval:
{
"event_id": "evt_…",
"type": "decided",
"request_id": "<request-id>",
"id": "<request-id>",
"occurred_at": "2026-11-10T12:00:00.000Z",
"state": "decided",
"decision": "accept",
"reason": "ok to send",
"argsHash": "…",
"metadata": {},
"decisionDetail": { "outcome": "accept", "reason": "ok to send", "decidedBy": "…" }
}typeandstateare"decided", or"answered"for anask_userreply.decisionis the host decision name:accept,reject,ignore,respond, oredit(a reviewer amendment).- For an answered
ask_user,answeris the reviewer's typed reply as an object{ kind, value }with the stored spec type (e.g.{"kind": "single", "value": "blue"}), exactly as the host stored it. When there is no typed answer theanswerkey is omitted entirely - never sent asanswer: null. - Reviewer amendments arrive as
editedArgs(act on those); a plain text reply arrives asresponse. id,request_id,idempotency_key,metadata,reason,argsHashanddecisionDetailare present when the host has the values.
Delivery semantics: any 2xx counts as acceptance. 5xx, 429, 408 and 425 are retried (a short in-process schedule, then host-side retries over about 24 hours, always reusing the same x-hitly-event-id); other non-2xx answers fail the delivery immediately. Redirects are not followed: a 3xx from your URL fails the delivery. Callback targets must be public https endpoints - private and loopback destinations are refused. A request whose callback ultimately fails shows callbackDelivery: "failed" on get_decision; the decision itself stands.
Example: a Grok Bot agent passes its own agent webhook URL as callback_url (e.g. https://example.com/hooks/hitly) and a secret only it knows as cb_auth_token, then calls get_decision on waking to confirm the outcome. If an operator has registered that same URL under Project settings → Callbacks, the agent omits cb_auth_token and HITLy authenticates the POST from the registration instead - the bot still calls get_decision to confirm.
There is no decide tool
Bots can request, read, and cancel - they cannot decide. Decisions come from a signed-in human in the HITLy web or mobile inbox. pending, expired and cancelled are never approval: confirm with get_decision before acting.
Open the endpoint URL in a browser and you will be redirected here.