Skip to content

Rank MCP service search over a per-organization index - #198

Merged
tnkuehne merged 2 commits into
mainfrom
feat/mcp-service-search
Nov 19, 2026
Merged

tnkuehne merged 2 commits into
mainfrom
feat/mcp-service-search

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

MCP search listed ten route keys at a time across the whole installation and filtered them afterwards. Pages were often empty because most keys belong to other organizations, so a distinctive word such as console needed several calls with cursors. The query also had to appear as one contiguous substring, so multi-word queries rarely matched.

Search now ranks every permitted entrypoint with BM25 over words from the hostname, entrypoint, method and parameter names, summaries, parameter descriptions and remarks. Names come first in each entry's bounded word list, so long remarks cannot push them out. Identifiers are split (searchAnalytics → search analytic) and simple plurals are stemmed. The best matches come first. An exact hostname lists that host's entrypoints, and an empty query lists everything. Paging uses limit (default 10, max 50) and offset, and the response returns { services, remaining, next, complete }; next is the complete input for the following page. This replaces the KV cursor parameter. The tool description tells clients how to page.

Search reads one index object per organization (service-index/<org>.json in the packages bucket) instead of every route, publication and documentation object. A new runtime management endpoint, /.well-known/widefleet/service-index, recomputes one host's entry from the current route and publication and writes it with an ETag condition. Publishers call the endpoint after committing:

  • Cloudflare deployment and removal, as separate Workflow steps after activation and unpublishing. A runtime without the endpoint returns 404, and the step skips.
  • The agent, after commit and including deletion, when the runtime release advertises search: 1 and the job has a host. Runtime-only jobs skip the refresh.

A failed refresh is logged and leaves the committed operation in place, so it cannot mark a serving deployment as failed or stop a removal.

A missing index, or one older than a day, is rebuilt by searches. Route keys carry no organization, so a rebuild reads every route of the installation; each search advances it by at most 200 routes, six at a time, and keeps its progress in the index. During a rebuild, search uses the last complete index updated with the routes scanned so far. Until the rebuild has read every route, the response reports complete: false and the tool description asks clients to search again, because a lost refresh may still hide a service it has not reached.

Refreshes and rebuilds cannot overwrite each other. A rebuild writes only if the index is unchanged since it read it. A refresh applies to the index and to a rebuild in progress, creates an expired index when none exists, and always writes. A search that scanned before a concurrent deployment therefore cannot save a result without the new host.

The index is derived state, not authorization. Search rechecks the current route of every returned host, and describe and call authorize independently. A missed refresh can therefore hide a new service or keep stale text until the next rebuild, but cannot expose one whose access was revoked. docs/architecture.md records the publisher contract.

Validation:

  • Repository build, type, format and lint checks.
  • Ranking unit tests: a distinctive word on the first page of a large catalog, unordered multi-word phrases, split identifiers, plurals and parameter names, method and parameter names beside long remarks, exact hostnames, and paging with next.
  • App-services runtime suite on workerd and on celld 0.6.3-widefleet.1 (38/38). It covers a route removed without a refresh, a refresh dropping a host, a host published during the first scan surviving that scan's write, and first and expired-index rebuilds spanning several searches with complete: false. The concurrent-publication case fails on both runtimes when a refresh skips a missing index.
  • The full Cloudflare suite (247/247) after the CI build steps, including a deployment test that a deployed host is indexed and a removed app is dropped.
  • Agent and core fmt, clippy with denied warnings, and tests on Rust 1.99.

RetriggerView in GreptileConfidence Score: 5/5

The follow-up appears safe to merge; the previous finding is fixed and no new issues were found.

Summary

MCP service search now ranks matches from a per-organization index, with publisher refreshes and bounded rebuilds.

  • MCP search ranks service matches and returns pages with next inputs.
  • Search keeps a saved index for each organization and rebuilds it in batches.
  • Publishers refresh service indexes after committed app changes.

Reviews (3) · Last reviewed commit: "Report MCP search as incomplete during e..." · Reviewed by Greptile

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs 4b8c414 Nov 19 2026, 04:48 PM

Comment thread crates/platform-agent/src/main.rs Resolved
Comment thread packages/app-runtime/src/mcp-search.ts Resolved
@tnkuehne
tnkuehne force-pushed the feat/mcp-service-search branch from 3f1e8e4 to 71cb0f7 Compare November 19, 2026 16:37
MCP search listed ten route keys at a time across the whole installation and
filtered them afterwards, so first pages were often empty and a distinctive
word such as "console" needed several calls. It also required the full query
to appear as one substring.

Search now ranks every permitted entrypoint with BM25 over words from the
hostname, entrypoint and service documentation, then pages with limit/offset
and returns the next input. Names come before prose in each entry's bounded
word list, so long remarks cannot hide method or parameter names.

Search reads one per-organization index in R2 instead of every route,
publication and documentation object. Publishers refresh a host through the
runtime after committing its route and publication: the Cloudflare deployment
and removal workflows, and the agent when the runtime release advertises
search support and the job has a host. A failed refresh is logged and leaves
the committed operation in place.

A missing or day-old index is rebuilt by searches, at most 200 routes per
search, with progress kept in the index. Until the first rebuild completes,
search reports complete: false. Refreshes create a missing index, update a
rebuild in progress and always change the object, so a rebuild that read
older state cannot overwrite them. The index is derived state; search
rechecks returned routes, and describe and call authorize independently.
A daily rebuild serves the previous index, which a lost refresh may have left
without a service. Search now reports complete: false until the rebuild has
read every route, not only during the first one.
@tnkuehne
tnkuehne merged commit 5b7f041 into main Nov 19, 2026
25 of 27 checks passed
@tnkuehne
tnkuehne deleted the feat/mcp-service-search branch November 19, 2026 17:43
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