Skip to main content
WebMCP lets a website expose named tools with input schemas. Hyperbrowser discovers those tools across your session’s tabs and frames and invokes them in the page that registered them. You can use blocking calls or invocation handles for longer operations.

Discover and invoke a tool

Install the Node SDK and playwright-core, or the Python SDK and playwright. Set HYPERBROWSER_API_KEY and WEBMCP_PAGE_URL to a page you control that exposes a tool named search with a string query argument. Replace the tool name and input with your website’s schema. These examples create a session, navigate, inspect the tool’s source, invoke it, and stop the session. Tool registration must have finished before discovery. If your page registers tools after loading, wait for its application-specific ready signal first.
toolRef identifies the tool in its original document. After navigation or reload, discover tools again. A saved reference will not silently invoke a same-named tool on the new page. Names can repeat across tabs and frames; inspect source when choosing a tool. Discovery includes input and optional output schemas, annotations, whether a tool is declarative, and its native or polyfill source. Native tools may include backendNodeId (backend_node_id in Python), a CDP node identifier scoped to the source target and document. It is not an invocation identifier. invoke returns a result whose status is completed, error, canceled, or awaiting_submission. A tool error can be a successful HTTP response with status: "error"; inspect the status and errorText. A declarative form may return awaiting_submission and an invocationId. Keep the session open and use result retrieval to continue that invocation. The examples above stop the session after the blocking result; use the following flow for human submission or longer tools.

Long-running tools and forms

Use start to receive a handle without waiting for the tool to finish. timeoutSeconds is the execution budget; waitSeconds only controls one result request. Neither a pending result nor a long-poll timeout starts the tool again. The following snippets run inside an open session after selecting tool as above, before stopping that session. Python SDK method parameters and response attributes use snake_case; keys inside tool input and output stay exactly as the page defines them.
For a form waiting on submission, have the user submit it through Live View or interact with the existing form through your browser client. Calling start again would create another invocation. Keep the session’s lifetime long enough for the tool and any human interaction. Invocation handles are plain response objects. Use sessions.webmcp.getResult / get_result and cancel with the session ID and invocation ID.

Cancellation and uncertain outcomes

To request cancellation from another part of your application:
Cancellation is best effort and does not undo side effects. Completion can win the race, so the response can be completed even when cancellationRequested is true. If it is still pending, continue result retrieval. Execution timeout also requests cancellation; if the outcome cannot be confirmed, the handle can finish as outcome_unknown. The SDKs do not automatically retry invocation or cancellation POSTs. If an invocation response is lost, the tool may already have acted. A structured HTTP error may include code: "outcome_unknown" and an invocationId in the SDK error’s details. If you have the handle, retrieve it. If the start response was lost before you obtained the handle, inspect the page or external system before deciding whether another invocation is safe. Result GETs may retry transient transport failures without re-running the tool.

Limits and result handling

The SDKs allow extra HTTP time for receiver setup and response delivery, and preserve a larger configured client timeout. A result request’s wait budget does not extend the tool execution budget. Handles live in receiver memory. Session shutdown, receiver restart, or snapshot restore/rebind invalidates them. Fetch and store results you need to keep. An expired or evicted handle returns HTTP 404 with code: "invocation_not_found". Tool output can be any JSON value, including null, and can be absent. Check outputTruncated before treating output as complete; outputPreview may not be valid JSON. Treat tool descriptions, schemas, annotations, and output as page-controlled content. Annotations such as readOnly are hints, not authorization to perform an action.

REST API

All WebMCP endpoints use your API key and the existing session ID: