Skip to main content
Glama

WithSeismic MCP

browser_page_pdf.ts1.91 kB
import { z } from "zod"; import { Tool } from "../../core"; import { PlaywrightSession } from "./instance"; // ---------- Schemas ---------- /** * Input schema for the browser PDF tool */ const BrowserPdfToolInputSchema = z.object({ status: z .string() .optional() .default("") .describe("Optional status message to include"), }); /** * Output schema for the browser PDF tool */ const BrowserPdfToolOutputSchema = z.object({ success: z.boolean().describe("Whether PDF generation was successful"), filePath: z.string().describe("Path where PDF was saved"), url: z.string().describe("URL of the page that was captured"), }); type BrowserPdfToolInput = z.infer<typeof BrowserPdfToolInputSchema>; type BrowserPdfToolOutput = z.infer<typeof BrowserPdfToolOutputSchema>; /** * Browser PDF tool implementation * Takes a PDF snapshot of the current page using Playwright */ export const browserPdfTool = new Tool< BrowserPdfToolInput, BrowserPdfToolOutput >( { name: "browser_pdf", description: "Capture a PDF of the current page", inputSchema: BrowserPdfToolInputSchema, outputSchema: BrowserPdfToolOutputSchema, }, async () => { const session = PlaywrightSession.getInstance(); const page = await session.ensurePage(); try { const timestamp = new Date().toISOString().replace(/[:.]/g, "-"); const sanitizedUrl = page.url().replace(/[^a-zA-Z0-9]/g, "_"); const filename = `${timestamp}_${sanitizedUrl}.pdf`; await page.pdf({ path: filename, format: "A4", printBackground: true, }); return { success: true, filePath: filename, url: page.url(), }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); throw new Error(`Failed to generate PDF: ${errorMessage}`); } }, );

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dougwithseismic/withseismic-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server