Get Text
pinchtab_get_textGet readable text from any web page to extract article content or page information via accessibility tree snapshots.
Instructions
Get readable text content from the page (~800 tokens). Best for extracting article content or page information.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/content.ts:15-23 (handler)The async handler function for the pinchtab_get_text tool. It calls pinch('GET', '/text') to fetch readable page content from the PinchTab server, then returns it as a text content block. Wraps errors via toolError().
async () => { try { const result = await pinch("GET", "/text"); const text = typeof result === "string" ? result : toJson(result); return { content: [{ text, type: "text" as const }] }; } catch (error) { return toolError(error); } }, - src/tools/content.ts:9-13 (schema)The tool registration call including the schema (z.object({}) — no input parameters), description, and title for pinchtab_get_text.
{ description: "Get readable text content from the page (~800 tokens). Best for extracting article content or page information.", inputSchema: z.object({}), title: "Get Text", - src/tools/content.ts:6-24 (registration)The registerContentTools function registers pinchtab_get_text (along with screenshot, eval, pdf) on the MCP server via server.registerTool().
export function registerContentTools(server: McpServer) { server.registerTool( "pinchtab_get_text", { description: "Get readable text content from the page (~800 tokens). Best for extracting article content or page information.", inputSchema: z.object({}), title: "Get Text", }, async () => { try { const result = await pinch("GET", "/text"); const text = typeof result === "string" ? result : toJson(result); return { content: [{ text, type: "text" as const }] }; } catch (error) { return toolError(error); } }, ); - src/tools/index.ts:7-12 (registration)registerAllTools calls registerContentTools(server) which registers pinchtab_get_text on the MCP server.
export function registerAllTools(server: McpServer) { registerInstanceTools(server); registerNavigationTools(server); registerInteractionTools(server); registerContentTools(server); } - src/pinchtab/client.ts:6-49 (helper)The pinch() helper function that makes HTTP requests to the PinchTab server. Used by the handler to GET /text. Handles auth, timeouts, and JSON/text response parsing.
export async function pinch( method: string, path: string, body?: Record<string, unknown>, ): Promise<unknown> { if (!(await isPinchtabRunning())) { await ensurePinchtabRunning(); } const headers: Record<string, string> = { "Content-Type": "application/json", }; if (PINCHTAB_TOKEN) { headers["Authorization"] = `Bearer ${PINCHTAB_TOKEN}`; } const url = `${PINCHTAB_URL}${path}`; let res: Response; try { res = await fetch(url, { body: body ? JSON.stringify(body) : undefined, headers, method, signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS), }); } catch (error) { if (error instanceof DOMException && error.name === "TimeoutError") { throw new Error(`PinchTab ${method} ${path} timed out after ${REQUEST_TIMEOUT_MS / 1000}s`); } throw error; } if (!res.ok) { const text = await res.text(); throw new Error(`PinchTab ${method} ${path} → ${res.status}: ${text}`); } const contentType = (res.headers.get("content-type") ?? "").split(";")[0].toLowerCase().trim(); if (contentType === "application/json") { return res.json(); } return res.text(); }