browser_console_messages
Retrieve console messages from web pages to monitor JavaScript errors, warnings, and logs during browser automation testing with Playwright.
Instructions
Returns all console messages
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "browser_console_messages"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/console.ts:29-31 (handler)The main handler function for the 'browser_console_messages' tool. It iterates over console messages from the current tab and adds each as a result to the response.
handle: async (tab, params, response) => { tab.consoleMessages().map(message => response.addResult(message.toString())); }, - src/tools/console.ts:22-28 (schema)Schema definition for the tool, specifying name, title, description, no input parameters, and read-only type.
schema: { name: 'browser_console_messages', title: 'Get console messages', description: 'Returns all console messages', inputSchema: z.object({}), type: 'readOnly', }, - src/tools/console.ts:34-36 (registration)Local registration: exports the defined tool in an array for aggregation.
export default [ console, ]; - src/tools.ts:36-52 (registration)Global registration: imports and spreads the console tool (among others) into the allTools array, which is used to provide the complete set of tools.
export const allTools: Tool<any>[] = [ ...common, ...console, ...dialogs, ...evaluate, ...files, ...install, ...keyboard, ...navigate, ...network, ...mouse, ...pdf, ...screenshot, ...snapshot, ...tabs, ...wait, ];