Skip to content

docs: rank the page titled with the query first in MCP search - #1787

Merged
chhoumann merged 1 commit into
masterfrom
docs/mcp-title-ranking
Sep 22, 2026
Merged

chhoumann merged 1 commit into
masterfrom
docs/mcp-title-ranking

Conversation

@chhoumann

@chhoumann chhoumann commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

search_quickadd_docs ranked QuickAddAPI above Suggester System for "suggester" (12 vs 11 points). The API reference mentions suggesters in its headings, description and body, which added up to more than Suggester System's title match. The same pattern affected "suggester system", "scripts with user settings" and "open quickadd from your desktop".

A page whose title contains every query term now gets a +10 bonus. It's the page being asked for, even when a broader page mentions the terms more often.

Changes

  • functions/mcp.ts: one bonus line in scorePage. Weights are otherwise unchanged.

Testing / validation

Ran the real onRequest handler under Node against a build of master. I compared this fix against simpler and broader alternatives on three query sets:

Variant A: 30 realistic queries (top-1) B: 50 page titles (top-1) C: 439 unique headings (top-1 / top-3)
master 29 46 342 / 417
title weight 8 → 12 29 49 303 / 412
title weight 8 → 16 29 49 274 / 390
all-terms-in-title bonus (this PR) 30 49 342 / 417
IDF weighting only 29 47 365 / 427
  • Raising the title weight fixes titles but hurts heading queries badly. The bonus fixes titles and changes nothing else.
  • The outcome doesn't depend on the bonus size: +6, +10 and +20 give the same results.
  • Across all 524 distinct queries, only 7 top-5 rankings change: the four fixes above, plus harmless reshuffles in "user scripts" (top-1 unchanged), "notes" (top-1 unchanged) and the vague heading "my notes".
  • No lost results: all 696 heading-word queries still return results. tsc --strict is clean.
  • The remaining B miss is the one-word query "settings", which reasonably goes to "Scripts with user settings".

Checklist

Note

Add title-match bonus to scorePage in MCP search

Pages whose titles contain every query term now get an additional 10 points in search scoring. The bonus is added after the existing title, heading, description, and body-text scoring in mcp.ts. Risk: this changes relative ranking of search results when multiple pages match the query.

Macroscope summarized 4f10af6.

Summary by CodeRabbit

  • New Features
    • Search results now receive a relevance boost when the page title contains all query terms.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Deploying quickadd with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4f10af6
Status: ✅  Deploy successful!
Preview URL: https://6e593125.quickadd.pages.dev
Branch Preview URL: https://docs-mcp-title-ranking.quickadd.pages.dev

View logs

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 20daa8ba-461c-4a49-a159-2ec97753f8ee

📥 Commits

Reviewing files that changed from the base of the PR and between 17159b1 and 4f10af6.

📒 Files selected for processing (1)
  • docs/functions/mcp.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

scorePage now adds 10 points when the page title contains every query term.

Changes

Title Scoring

Layer / File(s) Summary
Title match bonus
docs/functions/mcp.ts
scorePage adds 10 points when the page title contains every query term.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 4f10a

The localized title-ranking change is ready to merge with no established blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: ranking pages whose titles match the query higher in MCP search.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the title line
Each query term now earns a sign
Ten points hop into the score
Matching pages rise some more
Tiny change, clear and fine

Comment @coderabbitai help to get the list of available commands.

@chhoumann
chhoumann merged commit 7fb4e3e into master Sep 22, 2026
16 checks passed
@chhoumann
chhoumann deleted the docs/mcp-title-ranking branch September 22, 2026 19:12
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