Skip to content

fix(hub): small MCP crawls wait for their pages, as the tool documents - #160

Open
bartrumb wants to merge 1 commit into
mainfrom
fix/small-crawl-sync-wait
Open

bartrumb wants to merge 1 commit into
mainfrom
fix/small-crawl-sync-wait

Conversation

@bartrumb

Copy link
Copy Markdown
Owner

Since v2.7.1, the MCP crawl tool description (and docs/openapi.json) has said that crawls with limit <= 5 wait up to 25 seconds and return the completed pages, and that async: true opts out. Neither was implemented. executeCrawl dispatched the job and always returned { status: 'queued', crawlId }, and nothing read async. On v2.8.33, a live crawl with limit: 2 came back queued and finished 17 seconds later.

Change

  • After dispatch, a crawl with limit <= 5 and without async: true polls the job until it is completed, failed or cancelled, for up to 25 seconds. Polling starts at 250ms and backs off to 2s. The response is the same body a { crawlId } poll returns, pages included.
  • If the crawl is still running at 25 seconds, the response is the queued one, as before. Larger crawls and async: true are unchanged.
  • The wait is edge glue only: it reads the crawl row from D1 through the existing getCrawlJobStatus. The crawl itself still runs in the Crawl Workflow.

Test plan

  • New test A.5b: an MCP crawl with limit: 2 returns status: 'completed' with its page inline, not a crawlId.
  • A.5 now passes async: true for its limit: 2 case, because it covers the queued dispatch to env.CRAWL.
  • Hub type-check and the full hub suite pass locally (371 core + 77 isolated).

🤖 Generated with Claude Code

The MCP crawl tool's description (and docs/openapi.json) has said since
v2.7.1 that crawls with limit <= 5 wait up to 25 seconds and return the
completed pages, and that async: true opts out. Neither was implemented:
executeCrawl dispatched the job and always returned
{ status: 'queued', crawlId }, and nothing read `async`. A live crawl with
limit 2 on v2.8.33 came back queued and finished 17 seconds later.

After dispatch, a crawl with limit <= SMALL_CRAWL_SYNC_LIMIT (5) and no
async: true now polls the job with waitForSmallCrawl until it is
completed, failed or cancelled, for up to SMALL_CRAWL_SYNC_WAIT_MS (25s),
and returns the same body as a { crawlId } poll, pages included. If the
crawl is still running at the deadline, the response is the queued one as
before. Larger crawls and async: true are unchanged.

A.5 passes async: true for its limit-2 case, since it covers the queued
dispatch path, and A.5b checks that a limit-2 crawl returns its completed
pages inline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Brett Bartrum <17114576+bartrumb@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant