Skip to Content
HeyBug docs
MCP

Long-running calls

A test run can take longer than an MCP client is willing to wait for one tool call.

A test run can take longer than an MCP client is willing to wait for one tool call. So the remote server stops waiting after 50 seconds and returns the run id. The run keeps going on the server. You then poll for the result with heybug_get_run.

This guide covers the 50 second limit, the status values you will see, and the polling pattern. For setup, see MCP.

What it is for

Use this when an assistant starts a run and needs the result, but the run may take a few minutes:

  • heybug_run starts a test run of a URL and waits for it.
  • heybug_plan waits for a test plan to be proposed.
  • heybug_generate_and_run applies a pending plan and waits for its results.
  • heybug_get_run reads a run and can wait on it, for up to 45 seconds per call.

Each call that waits returns one of two things: the finished result, or the id to poll.

The 50 second limit

The limit applies to the remote server at /api/mcp. A tool call that is still going at 50 seconds returns what is known so far and says that the work continues. It is not an error.

Over local stdio (heybug mcp), heybug_run waits up to 15 minutes. After that it returns with "Still running after 15 minutes; stopped waiting." Poll the same way.

Status values

KindStatusMeaning
Runqueued, runningStill going. Poll again.
RunpassedEvery test passed.
RunfailedAt least one test failed. Read the failing step.
RunerrorAn infrastructure problem, not a test verdict. Start a new run.
RuncanceledStopped before it finished. The results are incomplete.
Quick runexploring, runningStill going. Poll again.
Quick rundoneFinished. Check the pass and fail counts.
Quick runfailedCould not complete. Read the error text.

Failing cases from heybug_get_run include the failing step, Expected, Actual and a web link to the case.

Polling pattern

  1. Start the run. Call heybug_run with url. Leave wait at its default, or send "wait": false to get the id straight away.
  2. Keep the id. If the reply says "Stopped waiting after 50s" or "Still running", take the id it names. It is the run id.
  3. Poll. Call heybug_get_run with runId and wait set to 45. The call returns when the run finishes or after 45 seconds, so it stays under the 50 second limit.
  4. Repeat step 3 while the status is queued or running.
  5. Stop when the status is passed, failed, error or canceled. Read the failures, or start a new run for error.

Example

Start the run on the remote server:

curl -s https://opentest.nagara.cloud/api/mcp \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"heybug_run","arguments":{"url":"https://staging.crate.so"}}}'

After 50 seconds the reply might say (the id here is an example):

Stopped waiting after 50s; the work continues on the server. Call heybug_get_run with id "run_123" to get the result.

Poll with that id:

curl -s https://opentest.nagara.cloud/api/mcp \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"heybug_get_run","arguments":{"runId":"run_123","wait":45}}}'

While the run is going, the reply ends with "Still running; call heybug_get_run again with wait." When it finishes, the reply names the verdict, the counts, and a link to /p/{project}/runs/{run} in the web app.

To list the latest runs of a project when you lost the id, call heybug_list_runs with projectId.

When it fails

  • "Stopped waiting" or "Still running". This is not a failure. Poll with the id.
  • "Lost contact while waiting for the run". The connection dropped. The run continues, so poll again with the same id.
  • "runId is required". Pass the runId from the reply. heybug_get_run needs it.
  • The id starts with exp_. That id belongs to an exploration, not a run, so heybug_get_run will not find it. Open the Details: link in the reply instead.
  • Status error. An infrastructure problem. Start a new run with heybug_run.
  • 401 or 403. The key or the Origin header is wrong. See MCP troubleshooting.
  • A tool is missing. Restart the client and compare with GET /api/mcp/tools.

On this page