feat: add site adapter support to browser MCP server#13482
Draft
feat: add site adapter support to browser MCP server#13482
Conversation
Signed-off-by: Vaayne <liu.vaayne@gmail.com>
Add sites/registry.ts with: - parseSiteMeta() for @meta JSON and @tag fallback parsing - scanSites() for recursive .js file discovery - getAllSites() with mtime-based caching - findSite() for exact name lookup - searchSites() for fuzzy matching on name/description/domain - ensureSitesAvailable() for async git clone - backgroundUpdate() for async git pull when >24h stale Signed-off-by: Vaayne <liu.vaayne@gmail.com>
Test coverage for: - parseSiteMeta: @meta JSON, @tag fallback, malformed JSON, missing meta - scanSites: empty dir, recursive walk, .git dir skipping - getAllSites: local overrides community, mtime-based caching - findSite: exact match, non-existent adapter - searchSites: by name, description, domain, case-insensitive - ensureSitesAvailable: already available, clone success, clone failure - backgroundUpdate: no .git, recent update, stale update, missing timestamp Signed-off-by: Vaayne <liu.vaayne@gmail.com>
Signed-off-by: Vaayne <liu.vaayne@gmail.com>
Signed-off-by: Vaayne <liu.vaayne@gmail.com>
Signed-off-by: Vaayne <liu.vaayne@gmail.com>
- Use [\r\n] in @meta regex for Windows CRLF compatibility - Remove premature cache invalidation in backgroundUpdate() to avoid race condition with in-progress git pull Signed-off-by: Vaayne <liu.vaayne@gmail.com>
Signed-off-by: Vaayne <liu.vaayne@gmail.com>
Signed-off-by: Vaayne <liu.vaayne@gmail.com>
Signed-off-by: Vaayne <liu.vaayne@gmail.com>
- Change bare `auth` to `auth.?(?:failed|expired|required|error|token)` - Add test verifying "author not found" does not trigger login hint Signed-off-by: Vaayne <liu.vaayne@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Before this PR:
The
@cherry/browserMCP server only had three generic tools (open,execute,reset) — AI agents had to manually navigate to sites, figure out DOM structure or API endpoints, and write custom JS for every data extraction task.After this PR:
Adds a
siteMCP tool that reuses the bb-sites adapter ecosystem — 104 pre-built JavaScript adapters across 36 platforms (Twitter, GitHub, Reddit, Bilibili, Hacker News, YouTube, etc.). AI agents can now:site(action='list')— discover available adapters grouped by platformsite(action='search', query='twitter')— find adapters by keywordsite(action='info', name='twitter/search')— get adapter metadata and argssite(action='run', name='hackernews/top', args={count:'10'})— execute and get structured JSONKey features:
persist:defaultpartition for logged-in accessWhy we need it and why it was done in this way
The bb-sites adapter pattern (
/* @meta { ... } */+ bare JS function) is already proven with 104 adapters. Reusing it gives Cherry Studio instant access to structured data extraction for dozens of platforms without writing custom code.The following tradeoffs were made:
sitetool withactionparameter instead of 104 individual MCP tools — keeps the tool list manageable~/.bb-browser/bb-sites/(community) and~/.bb-browser/sites/(local), updating independently via gitshowWindowdefaults tofalsefor site tool (unlikeopenwhich defaults totrue) since adapter execution is programmatic, not interactiveThe following alternatives were considered:
Breaking changes
None. This is purely additive — new
sitetool alongside existingopen/execute/resettools. No existing APIs or behavior changed.Special notes for your reviewer
controller.ts— all execution flows through existingopen(),execute(),listTabs()methods.jsfile → strip@metablock → wrap as IIFE(${jsBody})(${argsJson})→ CDPRuntime.evaluatewithawaitPromise: true— identical to how bb-browser runs adaptersexecFile/spawn, neverexecSync, to avoid blocking Electron's main processChecklist
/gh-pr-review,gh pr diff, or GitHub UI) before requesting review from othersRelease note