Get Talonic Document
talonic_get_documentFetch complete metadata for a specific document in the Talonic workspace using its document ID.
Instructions
Fetch full metadata for a single document already in the user's Talonic workspace. Returns id, filename, page count, detected document type, language, processing log, and link URLs (self, extractions, dashboard).
USE WHEN:
You need details about a specific document the user already extracted or uploaded.
You have a document_id from a previous extract or search call and want more context.
The user asks 'tell me about document X' or similar.
DO NOT USE WHEN:
The user wants the document's full text content (use talonic_to_markdown for OCR markdown).
The user wants extracted structured data (use talonic_extract with a schema, or fetch the extraction by id).
The user has a file but no document_id yet (call talonic_extract first to ingest the document).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| document_id | Yes | The Talonic document ID. Get this from a previous talonic_extract or talonic_search response. |
Implementation Reference
- src/tools/get-document.ts:31-41 (handler)The main handler function `handleGetDocument` that calls `talonic.documents.get(args.document_id)` to fetch document metadata from the Talonic API and returns the result as JSON.
export async function handleGetDocument( talonic: Talonic, args: { document_id: string }, ): Promise<ToolResult> { try { const result = await talonic.documents.get(args.document_id) return jsonOk(result) } catch (err) { return toolError(err) } } - src/tools/get-document.ts:22-29 (schema)The input schema defining the `document_id` parameter — a required string (min length 1) described as the Talonic document ID from a previous extract or search.
const inputSchema = { document_id: z .string() .min(1) .describe( "The Talonic document ID. Get this from a previous talonic_extract or talonic_search response.", ), } - src/tools/get-document.ts:43-53 (registration)The `registerGetDocument` function that registers the tool named `talonic_get_document` on the MCP server with its title, description, input schema, and handler callback.
export function registerGetDocument(server: McpServer, talonic: Talonic): void { server.registerTool( "talonic_get_document", { title: "Get Talonic Document", description: DESCRIPTION, inputSchema, }, async (args) => handleGetDocument(talonic, args), ) } - src/server-factory.ts:90-100 (registration)The call site in `createServer` where `registerGetDocument` is invoked to register the tool on the MCP server.
registerGetDocument(server, talonic) registerSearch(server, talonic) registerFilter(server, talonic) registerToMarkdown(server, talonic) registerExtract(server, talonic) // Resource registrations. registerSchemasResource(server, talonic) return server } - src/tools/_shared.ts:38-78 (helper)Helper functions `jsonOk` and `toolError` used by the handler to format successful and error responses for the MCP protocol.
export function jsonOk(value: unknown): ToolSuccessResult { return { content: [ { type: "text", text: JSON.stringify(value, null, 2), }, ], } } /** * Convert any thrown error into a tool error result with stable * formatting. Talonic API errors include `code`, `status`, and * `request_id` so the user (or another tool call) can act on them. * * @internal */ export function toolError(err: unknown): ToolErrorResult { if (err instanceof TalonicError) { const lines = [ `Talonic API error: ${err.message}`, `code: ${err.code}`, `status: ${err.status}`, ] if (err.requestId) lines.push(`request_id: ${err.requestId}`) return { isError: true, content: [{ type: "text", text: lines.join("\n") }], } } return { isError: true, content: [ { type: "text", text: `Unexpected error: ${err instanceof Error ? err.message : String(err)}`, }, ], } }