docs(webmcp): Add missing documentation (#14849)

This commit is contained in:
François Beaufort
2026-04-09 08:21:23 +02:00
committed by GitHub
parent cd18d6b99d
commit a5f11f0a8c
9 changed files with 103 additions and 0 deletions
+4
View File
@@ -1440,6 +1440,8 @@ The TouchHandle interface exposes methods to manipulate touches that have been s
</td><td>
Tool annotations
</td></tr>
<tr><td>
@@ -1977,6 +1979,8 @@ Whether to wait for the element to be [visible](./puppeteer.elementhandle.isvisi
</td><td>
Represents the status of a tool invocation.
</td></tr>
<tr><td>
+6
View File
@@ -4,6 +4,8 @@ sidebar_label: WebMCPAnnotation
# WebMCPAnnotation interface
Tool annotations
### Signature
```typescript
@@ -47,6 +49,8 @@ boolean
</td><td>
If the declarative tool was declared with the autosubmit attribute.
</td><td>
</td></tr>
@@ -64,6 +68,8 @@ boolean
</td><td>
A hint indicating that the tool does not modify any state.
</td><td>
</td></tr>
@@ -4,6 +4,8 @@ sidebar_label: WebMCPInvocationStatus
# WebMCPInvocationStatus type
Represents the status of a tool invocation.
### Signature
```typescript
+10
View File
@@ -53,6 +53,8 @@ Description
</td><td>
Optional annotations for the tool.
</td></tr>
<tr><td>
@@ -66,6 +68,8 @@ string
</td><td>
Tool description.
</td></tr>
<tr><td>
@@ -81,6 +85,8 @@ Promise&lt;[ElementHandle](./puppeteer.elementhandle.md)&lt;HTMLFormElement&gt;
</td><td>
The corresponding ElementHandle when tool was registered via a form.
</td></tr>
<tr><td>
@@ -111,6 +117,8 @@ object
</td><td>
Schema for the tool's input parameters.
</td></tr>
<tr><td>
@@ -141,5 +149,7 @@ string
</td><td>
Tool name.
</td></tr>
</tbody></table>
+6
View File
@@ -45,6 +45,8 @@ string
</td><td>
Tool invocation identifier.
</td></tr>
<tr><td>
@@ -58,6 +60,8 @@ object
</td><td>
The input parameters used for the call.
</td></tr>
<tr><td>
@@ -71,5 +75,7 @@ object
</td><td>
Tool that was called.
</td></tr>
</tbody></table>
@@ -47,6 +47,8 @@ Default
</td><td>
The corresponding tool call if available.
</td><td>
</td></tr>
@@ -64,6 +66,8 @@ string
</td><td>
Error text.
</td><td>
</td></tr>
@@ -81,6 +85,8 @@ Protocol.Runtime.RemoteObject
</td><td>
The exception object, if the javascript tool threw an error.
</td><td>
</td></tr>
@@ -96,6 +102,8 @@ string
</td><td>
Tool invocation identifier.
</td><td>
</td></tr>
@@ -113,6 +121,8 @@ any
</td><td>
Output or error delivered as delivered to the agent. Missing if `status` is anything other than Success.
</td><td>
</td></tr>
@@ -128,6 +138,8 @@ any
</td><td>
Status of the invocation.
</td><td>
</td></tr>
@@ -45,6 +45,8 @@ Default
</td><td>
Array of tools that were added.
</td><td>
</td></tr>
@@ -45,6 +45,8 @@ Default
</td><td>
Array of tools that were removed.
</td><td>
</td></tr>
+59
View File
@@ -19,14 +19,24 @@ import {FrameManagerEvent} from './FrameManagerEvents.js';
import {MAIN_WORLD} from './IsolatedWorlds.js';
/**
* Tool annotations
*
* @public
*/
export interface WebMCPAnnotation {
/**
* A hint indicating that the tool does not modify any state.
*/
readOnly?: boolean;
/**
* If the declarative tool was declared with the autosubmit attribute.
*/
autosubmit?: boolean;
}
/**
* Represents the status of a tool invocation.
*
* @public
*/
export type WebMCPInvocationStatus = 'Success' | 'Canceled' | 'Error';
@@ -76,9 +86,21 @@ export class WebMCPTool extends EventEmitter<{
#backendNodeId?: number;
#formElement?: ElementHandle<HTMLFormElement>;
/**
* Tool name.
*/
name: string;
/**
* Tool description.
*/
description: string;
/**
* Schema for the tool's input parameters.
*/
inputSchema?: object;
/**
* Optional annotations for the tool.
*/
annotations?: WebMCPAnnotation;
/**
* Frame the tool was defined for.
@@ -114,6 +136,9 @@ export class WebMCPTool extends EventEmitter<{
this.rawStackTrace = tool.stackTrace;
}
/**
* The corresponding ElementHandle when tool was registered via a form.
*/
get formElement(): Promise<ElementHandle<HTMLFormElement> | undefined> {
return (async () => {
if (this.#formElement && !this.#formElement.disposed) {
@@ -136,6 +161,9 @@ export class WebMCPTool extends EventEmitter<{
* @public
*/
export interface WebMCPToolsAddedEvent {
/**
* Array of tools that were added.
*/
tools: WebMCPTool[];
}
@@ -143,6 +171,9 @@ export interface WebMCPToolsAddedEvent {
* @public
*/
export interface WebMCPToolsRemovedEvent {
/**
* Array of tools that were removed.
*/
tools: WebMCPTool[];
}
@@ -150,8 +181,17 @@ export interface WebMCPToolsRemovedEvent {
* @public
*/
export class WebMCPToolCall {
/**
* Tool invocation identifier.
*/
id: string;
/**
* Tool that was called.
*/
tool: WebMCPTool;
/**
* The input parameters used for the call.
*/
input: object;
/**
@@ -173,11 +213,30 @@ export class WebMCPToolCall {
* @public
*/
export interface WebMCPToolCallResult {
/**
* Tool invocation identifier.
*/
id: string;
/**
* The corresponding tool call if available.
*/
call?: WebMCPToolCall;
/**
* Status of the invocation.
*/
status: WebMCPInvocationStatus;
/**
* Output or error delivered as delivered to the agent. Missing if `status` is anything
* other than Success.
*/
output?: any;
/**
* Error text.
*/
errorText?: string;
/**
* The exception object, if the javascript tool threw an error.
*/
exception?: Protocol.Runtime.RemoteObject;
}