feat: add preview tool — navigate + screenshot in one call with optional POST
New MCP tool `preview` combines goto + screenshot with viewport control. Optionally POSTs result to any HTTP endpoint (e.g. HUD/visor) via previewUrl. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Vendored
+25
@@ -168,6 +168,31 @@ server.tool('screenshot', 'Take a screenshot of the current page', {
|
||||
const result = await browser.screenshot(path, fullPage);
|
||||
return textResult(JSON.stringify({ ok: true, path: result.path }));
|
||||
}));
|
||||
// Preview — navigate + screenshot in one call, optional POST to preview endpoint
|
||||
server.tool('preview', 'Navigate to a URL and take a screenshot in one call. Optionally POST the result to a preview endpoint.', {
|
||||
url: z.string().describe('URL or file:///path to preview'),
|
||||
width: z.number().optional().default(1280).describe('Viewport width'),
|
||||
height: z.number().optional().default(800).describe('Viewport height'),
|
||||
fullPage: z.boolean().optional().default(false),
|
||||
output: z.string().optional().default('/tmp/preview.png').describe('Screenshot output path'),
|
||||
previewUrl: z.string().optional().describe('HTTP endpoint to POST screenshot result to'),
|
||||
title: z.string().optional().describe('Title sent with preview POST'),
|
||||
caption: z.string().optional().describe('Caption sent with preview POST'),
|
||||
}, withLogging('preview', async ({ url, width, height, fullPage, output, previewUrl, title, caption }) => {
|
||||
await ensureLaunched();
|
||||
const result = await browser.executeCommand({
|
||||
cmd: 'preview',
|
||||
url,
|
||||
width,
|
||||
height,
|
||||
fullPage,
|
||||
output,
|
||||
previewUrl,
|
||||
title,
|
||||
caption,
|
||||
});
|
||||
return textResult(JSON.stringify(result));
|
||||
}));
|
||||
// Eval
|
||||
server.tool('eval', 'Execute JavaScript in the browser context', { script: z.string() }, withLogging('eval', async ({ script }) => {
|
||||
await ensureLaunched();
|
||||
|
||||
Reference in New Issue
Block a user