fidelity_screenshot
Capture a screenshot of a Fidelity Investments page to verify account data or debug unexpected results from trading tools. Optionally navigate to a specific URL first.
Instructions
Take a screenshot of the current Fidelity browser page. Useful for debugging when tools return unexpected results.
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": "fidelity_screenshot"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | Optional URL to navigate to before taking the screenshot. If omitted, captures the current page. |
Implementation Reference
- src/index.ts:490-539 (registration)Registers the 'fidelity_screenshot' tool on the MCP server with Zod schema for optional 'url' parameter and handler that takes a screenshot.
server.tool( "fidelity_screenshot", "Take a screenshot of the current Fidelity browser page. Useful for debugging when tools return unexpected results.", { url: z .string() .optional() .describe( "Optional URL to navigate to before taking the screenshot. If omitted, captures the current page." ), }, async ({ url }) => { try { const page = await getPage(); if (url) { await page.goto(url, { waitUntil: "domcontentloaded" }); const { waitForLoadingCompleteDouble } = await import("./browser.js"); await waitForLoadingCompleteDouble(page, 30000); } const screenshotBuffer = await page.screenshot({ fullPage: true }); const base64 = screenshotBuffer.toString("base64"); return { content: [ { type: "text", text: `Screenshot of: ${page.url()}`, }, { type: "image", data: base64, mimeType: "image/png", }, ], }; } catch (e) { return { content: [ { type: "text", text: `Screenshot failed: ${e instanceof Error ? e.message : String(e)}`, }, ], isError: true, }; } } ); - src/index.ts:501-538 (handler)The handler function that gets the browser page, optionally navigates to a URL, waits for loading to complete, takes a full-page screenshot, and returns it as base64-encoded image.
async ({ url }) => { try { const page = await getPage(); if (url) { await page.goto(url, { waitUntil: "domcontentloaded" }); const { waitForLoadingCompleteDouble } = await import("./browser.js"); await waitForLoadingCompleteDouble(page, 30000); } const screenshotBuffer = await page.screenshot({ fullPage: true }); const base64 = screenshotBuffer.toString("base64"); return { content: [ { type: "text", text: `Screenshot of: ${page.url()}`, }, { type: "image", data: base64, mimeType: "image/png", }, ], }; } catch (e) { return { content: [ { type: "text", text: `Screenshot failed: ${e instanceof Error ? e.message : String(e)}`, }, ], isError: true, }; } } - src/index.ts:493-500 (schema)Zod schema defining the optional 'url' input parameter with description.
{ url: z .string() .optional() .describe( "Optional URL to navigate to before taking the screenshot. If omitted, captures the current page." ), }, - src/browser.ts:80-87 (helper)The getPage() helper function used by the handler to retrieve the current browser page; throws if browser not initialized.
export async function getPage(): Promise<Page> { if (!page || page.isClosed()) { throw new Error( "Browser not initialized. Call fidelity_login first." ); } return page; }