Skip to content

Rank API methods by name matches first - #315

Merged
tnkuehne merged 1 commit into
mainfrom
feat/search-name-weight
Nov 22, 2026
Merged

tnkuehne merged 1 commit into
mainfrom
feat/search-name-weight

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Why

MCP search ranks methods with BM25 over one bag of stemmed words: the method name, parameter names and descriptions, and the summary count alike. In APIs with many related methods, the method a query names loses to methods that mention its words more often. In the Linear template, issues (the issue list) does not appear on the first page for "issues": issueUnshare, issueShare and issueUnarchive rank first. Two agents testing the template without context each needed a second search to find it.

What changes

  • Name field: ranking is BM25F. The method name and the rest (parameter names and descriptions, summary, service and entrypoint names) are separately length-normalized fields; a word in the name counts three times.
  • Surface forms: name words are also indexed as written where they differ from their stem, and so are query words. "issues" matches the name issues exactly and issueShare only by stem. Queries still match every method by stem, as before.
  • Index format 4: entries keep nameTerms next to terms. Indexes of format 3 are rebuilt; app deployments are not needed.

Neither is specific to an API: no synonyms, verb rules or name-equality bonus.

Measured on generated APIs (top result before → after)

Query Linear Jira (OpenAPI)
issues / list issues issueUnshare / issueToReleases → issues removeIssueTypeFromIssueTypeScheme → createIssues
get issue issueToRelease → unchanged getIssueSecurityLevel → getIssue
create issue issueCreate → unchanged getCreateIssueMetaIssueTypes → createIssue
projects / comments project / commentDelete → projects / comments updateProjectAvatar / deleteCommentProperty → searchProjects / getComments
teams teams → unchanged getPlanOnlyTeam → getTeams

GitHub's GraphQL API, whose lists are fields of repository rather than methods, changes mixed: "comments" now finds addComment and "current user" finds user, while "repositories" ranks enterprise settings such as updateEnterpriseMembersCanCreateRepositoriesSetting above repository.

Verification

  • New search test: a query naming a method ranks it above methods whose documentation mentions its words more often; the singular still finds them all.
  • The comparison above ran the previous and the new ranking code on the generated Linear, Jira and GitHub documentation.
  • pnpm check
  • pnpm exec vitest run apps/control-plane packages
  • RUN_SERVICE_TESTS=1 runtime service tests (workerd and celld), including MCP search

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge.

Summary

Search now gives method names more weight and favors matching plural spellings.

  • MCP search ranks methods with matching names higher.

Reviews (1) · Last reviewed commit: "Rank API methods by name matches first" · Reviewed by Greptile

Search ranked all words of a method alike, and stemmed every word, so a
query for "issues" ranked issueShare and issueArchive, whose documentation
mentions issues often, above the method named issues. Ranking is now BM25F:
the method name and its documentation are separately normalized fields, and
a word in the name counts three times as much. Names also keep their words
as written next to the stems, so a query word that matches a name exactly
ranks it above names that only share the stem. The search index moves to
format 4 and is rebuilt.
@cloudflare-workers-and-pages

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 a2f6e3f Nov 22 2026, 10:32 PM

@tnkuehne
tnkuehne merged commit 794a766 into main Nov 22, 2026
14 of 15 checks passed
@tnkuehne
tnkuehne deleted the feat/search-name-weight branch November 22, 2026 22:35
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