UNPKG

@sylphlab/tools-pdf

Version:

Core logic for MCP PDF tools (text extraction, etc.)

96 lines (92 loc) 2.87 kB
import * as _sylphlab_tools_core from '@sylphlab/tools-core'; import { z } from 'zod'; declare const GetTextItemSchema: z.ZodObject<{ id: z.ZodOptional<z.ZodString>; filePath: z.ZodString; }, "strip", z.ZodTypeAny, { filePath: string; id?: string | undefined; }, { filePath: string; id?: string | undefined; }>; declare const getTextToolInputSchema: z.ZodObject<{ items: z.ZodArray<z.ZodObject<{ id: z.ZodOptional<z.ZodString>; filePath: z.ZodString; }, "strip", z.ZodTypeAny, { filePath: string; id?: string | undefined; }, { filePath: string; id?: string | undefined; }>, "many">; }, "strip", z.ZodTypeAny, { items: { filePath: string; id?: string | undefined; }[]; }, { items: { filePath: string; id?: string | undefined; }[]; }>; /** * Extracts text content from a PDF buffer using MuPDF. * @param pdfBuffer Buffer containing the PDF data. * @returns A promise resolving to the extracted text content. * @throws If PDF parsing or text extraction fails. */ declare function extractPdfText(pdfBuffer: Buffer): Promise<string>; type GetTextInputItem = z.infer<typeof GetTextItemSchema>; type GetTextToolInput = z.infer<typeof getTextToolInputSchema>; interface GetTextResultItem { /** Optional ID from the input item. */ id?: string; /** The input file path. */ path: string; /** Whether the text extraction for this item was successful. */ success: boolean; /** The extracted text content, if successful. */ result?: string; /** Error message, if extraction failed for this item. */ error?: string; /** Suggestion for fixing the error. */ suggestion?: string; } declare const getTextTool: _sylphlab_tools_core.ToolDefinition<z.ZodObject<{ items: z.ZodArray<z.ZodObject<{ id: z.ZodOptional<z.ZodString>; filePath: z.ZodString; }, "strip", z.ZodTypeAny, { filePath: string; id?: string | undefined; }, { filePath: string; id?: string | undefined; }>, "many">; }, "strip", z.ZodTypeAny, { items: { filePath: string; id?: string | undefined; }[]; }, { items: { filePath: string; id?: string | undefined; }[]; }>, z.ZodObject<{ allowOutsideWorkspace: z.ZodOptional<z.ZodBoolean>; maxOutputChars: z.ZodOptional<z.ZodNumber>; workspaceRoot: z.ZodString; }, "strip", z.ZodTypeAny, { workspaceRoot: string; allowOutsideWorkspace?: boolean | undefined; maxOutputChars?: number | undefined; }, { workspaceRoot: string; allowOutsideWorkspace?: boolean | undefined; maxOutputChars?: number | undefined; }>>; export { type GetTextInputItem, type GetTextResultItem, type GetTextToolInput, extractPdfText, getTextTool, getTextToolInputSchema };