lithtrix_blob_parse
Extract text and tables from a blob using its unique identifier. Supports synchronous parsing or asynchronous processing with a callback URL for completion.
Instructions
POST /v1/blobs/{blob_id}/parse — extract text/tables; set async=true for QStash. Optional callback_url in JSON body. Requires LITHTRIX_API_KEY.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| blob_id | Yes | Content-addressed blob id (b_ + 16 hex chars) | |
| async | No | When true, calls ?async=true (async parse + poll) | |
| callback_url | No | HTTPS callback for async completion (public host) |
Implementation Reference
- tools/parse.js:80-124 (registration)Registration of the 'lithtrix_blob_parse' tool via server.tool() on the MCP server. It defines the tool name, description, input schema (blob_id, async, callback_url), and the handler function.
server.tool( "lithtrix_blob_parse", "POST /v1/blobs/{blob_id}/parse — extract text/tables; set async=true for QStash. Optional callback_url in JSON body. Requires LITHTRIX_API_KEY.", { blob_id: blobIdSchema, async: z .boolean() .optional() .describe("When true, calls ?async=true (async parse + poll)"), callback_url: z .string() .url() .max(2048) .optional() .describe("HTTPS callback for async completion (public host)"), }, async ({ blob_id, async: asyncFlag, callback_url }) => { const apiKey = process.env.LITHTRIX_API_KEY; if (!apiKey) return missingApiKeyResponse(); const url = new URL( `/v1/blobs/${encodeURIComponent(blob_id)}/parse`, LITHTRIX_API_URL ); if (asyncFlag) url.searchParams.set("async", "true"); const body = callback_url !== undefined ? JSON.stringify({ callback_url }) : undefined; let response; try { response = await fetch(url.toString(), { method: "POST", headers: { Authorization: `Bearer ${apiKey}`, ...(body ? { "Content-Type": "application/json" } : {}), }, body, }); } catch (err) { return networkErrorResponse(err); } return apiJsonResponse(response); } ); - tools/parse.js:83-95 (schema)Input schema for lithtrix_blob_parse using Zod: blob_id (19-char hex string starting with b_), optional async boolean, and optional callback_url.
{ blob_id: blobIdSchema, async: z .boolean() .optional() .describe("When true, calls ?async=true (async parse + poll)"), callback_url: z .string() .url() .max(2048) .optional() .describe("HTTPS callback for async completion (public host)"), }, - tools/parse.js:96-123 (handler)Handler function that makes a POST request to /v1/blobs/{blob_id}/parse with optional async flag and callback_url body. Requires LITHTRIX_API_KEY env var.
async ({ blob_id, async: asyncFlag, callback_url }) => { const apiKey = process.env.LITHTRIX_API_KEY; if (!apiKey) return missingApiKeyResponse(); const url = new URL( `/v1/blobs/${encodeURIComponent(blob_id)}/parse`, LITHTRIX_API_URL ); if (asyncFlag) url.searchParams.set("async", "true"); const body = callback_url !== undefined ? JSON.stringify({ callback_url }) : undefined; let response; try { response = await fetch(url.toString(), { method: "POST", headers: { Authorization: `Bearer ${apiKey}`, ...(body ? { "Content-Type": "application/json" } : {}), }, body, }); } catch (err) { return networkErrorResponse(err); } return apiJsonResponse(response); } - tools/parse.js:17-31 (helper)Helper function missingApiKeyResponse() used when LITHTRIX_API_KEY is not set.
function missingApiKeyResponse() { return { content: [ { type: "text", text: JSON.stringify({ error: "LITHTRIX_API_KEY environment variable is not set. " + "Register at https://lithtrix.ai and use lithtrix_register, then set the key.", }), }, ], isError: true, }; } - tools/parse.js:33-45 (helper)Helper function networkErrorResponse(err) used when the fetch call fails.
function networkErrorResponse(err) { return { content: [ { type: "text", text: JSON.stringify({ error: `Network error contacting Lithtrix API: ${err.message}`, }), }, ], isError: true, }; }