💬 Commit message: Update 2026-02-11 04:13:54, 13 files, 595 lines

📁 Files changed: 13
📝 Lines changed: 595

  • PLAN.md
  • TODO.md
  • browser.d.ts
  • browser.d.ts.map
  • browser.js
  • browser.js.map
  • mcp.js
  • mcp.js.map
  • types.d.ts
  • types.d.ts.map
  • browser.ts
  • mcp.ts
  • types.ts
This commit is contained in:
Adam Ladachowski
2026-02-11 04:13:54 +01:00
parent dd26376833
commit 5a7466b67d
13 changed files with 421 additions and 218 deletions
Vendored
+37
View File
@@ -106,6 +106,19 @@ server.tool('eval', 'Execute JavaScript in the browser context', { script: z.str
const result = await browser.eval(script);
return textResult(JSON.stringify({ ok: true, result }));
}));
// Console
server.tool('console', 'Get captured console messages (log, warn, error, etc.) from the browser', {
level: z
.enum(['log', 'info', 'warn', 'error', 'debug', 'all'])
.optional()
.default('all')
.describe('Filter by log level'),
clear: z.boolean().optional().default(false).describe('Clear messages after retrieving'),
}, withLogging('console', async ({ level, clear }) => {
await ensureLaunched();
const messages = browser.getConsole(level, clear);
return textResult(JSON.stringify({ ok: true, count: messages.length, messages }));
}));
// Utility
server.tool('wait', 'Wait for a specified time in milliseconds', { ms: z.number().optional().default(1000) }, withLogging('wait', async ({ ms }) => {
await ensureLaunched();
@@ -337,6 +350,30 @@ server.resource('Full Page HTML', 'browser://html/full', { description: 'Complet
],
};
});
// Resource: browser://console - Captured console messages
server.resource('Console Messages', 'browser://console', { description: 'Console messages captured from the browser', mimeType: 'application/json' }, async () => {
if (!launched) {
return {
contents: [
{
uri: 'browser://console',
mimeType: 'application/json',
text: JSON.stringify({ launched: false, messages: [] }),
},
],
};
}
const messages = browser.getConsole('all', false);
return {
contents: [
{
uri: 'browser://console',
mimeType: 'application/json',
text: JSON.stringify({ launched: true, count: messages.length, messages }),
},
],
};
});
// Resource: browser://screenshot - Current page screenshot (base64)
server.resource('Page Screenshot', 'browser://screenshot', { description: 'Screenshot of the current page as base64 PNG', mimeType: 'image/png' }, async () => {
if (!launched) {