Skip to content

Add custom WebMCP tools - #405

Merged
rgarcia merged 20 commits into
mainfrom
hypeship/custom-webmcp-tools
Sep 23, 2026
Merged

rgarcia merged 20 commits into
mainfrom
hypeship/custom-webmcp-tools

Conversation

@rgarcia

@rgarcia rgarcia commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add namespaced batches of page-backed and CDP-backed custom WebMCP tools through POST /webmcp/custom-tools and the Browser REPL, with per-tool IDs, conflict detection, listing, removal, and atomic namespace replacement
  • discover custom tools alongside page tools through GET /webmcp/tools with nested MCP metadata and source.custom provenance; invoke them with the existing tool_ref through /webmcp/invoke or webmcp.invokeTool
  • match top-level pages, nested frames, and OOPIFs; retry failed registrations in the same document and keep active invocations running when definitions are removed
  • separate definition validation, browser reconciliation, and page registration/transport; read custom discovery metadata from an atomic snapshot and fail explicitly if it is unavailable
  • return CDP-backed results even when the handler navigates its registration tab; validate input and optional output schemas
  • document registration, discovery, invocation, and page/CDP examples

QA and validation

  • built the headful image and tested structured flight-search tools against five public airline sites: three returned rendered flight results, and two denied access before results loaded
  • invoked a CDP-backed flight search that navigates its own tab through both the HTTP API and Browser REPL; both returned structured flight data
  • passed image regressions for same-tab navigation, same-document registration recovery, invalid input, bounded output, and REPL deadline handling; exercised filtering, namespace replacement, removal, nested-frame invocation, and native/custom name coexistence
  • CI unit and e2e tests, image builds, runtime checks, live-view test, and BugBot pass on the latest commit

API compatibility

Discovery consumers must read tool.name, tool.description, tool.inputSchema, and tool.annotations; legacy flat fields are not returned. Custom sources include target_id for the registration tab. CDP-backed custom outputs over 240 KiB return an explicit error. Coordinate discovery consumer updates before release.

@socket-security

socket-security Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​modelcontextprotocol/​server@​2.0.01001008591100
Addednpm/​@​modelcontextprotocol/​core@​2.0.01001008590100
Addednpm/​@​paralleldrive/​cuid2@​3.3.010010010088100

View full report

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/runtime/custom-webmcp.ts
Comment thread server/runtime/custom-webmcp.ts Outdated
Comment thread server/runtime/custom-webmcp.ts Outdated

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/runtime/custom-webmcp.ts Outdated

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/runtime/custom-webmcp.ts
Comment thread server/runtime/custom-webmcp.ts Outdated

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/runtime/custom-webmcp.ts

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/cmd/api/api/webmcp.go

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/cmd/api/api/browser_repl.go

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/cmd/api/api/custom_webmcp.go
Comment thread server/runtime/browser-repl.ts
Comment thread server/e2e/e2e_custom_webmcp_test.go Outdated

@masnwilliams masnwilliams left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requesting changes on the custom-tool lifecycle before merge. the happy path works in a headful image, but there is a reproducible recovery failure and two structural issues that should be addressed here.

  1. failed page registrations are marked current (server/runtime/custom-webmcp.ts:761-774). installPageDefinitions returns per-tool errors, but reconciliation commits documentKey and signature regardless; the next pass exits as registrationCurrent (:735-737). i reproduced this by making document.modelContext.registerTool fail once, then restoring it: add returned 201, but the tool remained undiscoverable after the failure cleared. removing and re-adding it did register. only commit successful installs; retry/report failed registrations, and add a same-document recovery test.

  2. the new custom-webmcp.ts is 1,048 lines and owns validation/matching, registry transactions, CDP page/OOPIF tracking, page-runtime source generation, and binding RPC. please decompose this around explicit owners (definitions, browser reconciliation, page runtime/transport) rather than making one registry coordinate all five lifecycles.

  3. custom metadata is independently held by the Node registry, a published state file, and a Go cache (browser_repl.go:100-153). on file read/decode failure the API silently serves cached metadata, even if a definition was replaced or removed. please make the discovery snapshot authoritative or define and test an intentional stale-read policy, and collapse the redundant generation/revision bookkeeping where possible.

non-blocking follow-up: webmcp.invokeTool in the REPL now calls full listTools() before even native-tool invocations (browser-repl.ts:339-345). that adds target refresh/settling and a new failure dependency to the existing path; avoid the preflight for native tools when possible.

focused Go and TypeScript tests pass, and HTTP/REPL custom invocation, URL reconciliation, and native discovery/invocation passed in the built headful image. those successes do not cover the one-time install failure above.

@rgarcia

rgarcia commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/cmd/api/api/webmcp.go

@masnwilliams masnwilliams left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-reviewed at 26f56c9. the three change requests from my previous review are addressed: failed page registrations now retry on the same document with an e2e regression test; definition ownership, browser reconciliation, and page runtime/transport are split into focused modules; and discovery reads one authoritative atomic snapshot rather than maintaining a second Go metadata cache. the native REPL invocation path also avoids full discovery for known native refs. focused Go/TypeScript tests and typecheck pass locally; CI and BugBot are green on this commit. approving.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/cmd/api/api/custom_webmcp.go
Comment thread server/cmd/api/api/webmcp.go
@rgarcia rgarcia changed the title Add REPL-backed custom WebMCP tools Add custom WebMCP tools Sep 23, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5e28c7b. Configure here.

Comment thread server/cmd/api/api/custom_webmcp.go
@rgarcia
rgarcia merged commit 92a94a0 into main Sep 23, 2026
12 checks passed
@rgarcia
rgarcia deleted the hypeship/custom-webmcp-tools branch September 23, 2026 21:20
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.

2 participants