WebMCP 类
🌐 WebMCP class
实验性的 WebMCP 类为 WebMCP API 提供了一个 API。
🌐 The experimental WebMCP class provides an API for the WebMCP API.
有关更多详细信息,请参见 WebMCP 指南。
🌐 See the WebMCP guide for more details.
语法
🌐 Signature
export declare class WebMCP extends EventEmitter<{
toolsadded: WebMCPToolsAddedEvent;
toolsremoved: WebMCPToolsRemovedEvent;
toolinvoked: WebMCPToolCall;
toolresponded: WebMCPToolCallResult;
}>
Extends: EventEmitter<{ toolsadded: WebMCPToolsAddedEvent; toolsremoved: WebMCPToolsRemovedEvent; toolinvoked: WebMCPToolCall; toolresponded: WebMCPToolCallResult; }>
附注
🌐 Remarks
这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 WebMCP 类的子类。
🌐 The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the WebMCP class.
示例
🌐 Example
await page.goto('https://www.example.com');
const tools = page.webmcp.tools();
for (const tool of tools) {
console.log(`Tool found: ${tool.name} - ${tool.description}`);
}
方法
🌐 Methods
方法 🌐 Method | 修饰符 🌐 Modifiers | 描述 🌐 Description |
|---|---|---|
| tools() | 获取页面定义的所有 WebMCP 工具。 🌐 Gets all WebMCP tools defined by the page. |