@talonic/mcp 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/content.js +300 -18
- package/dist/content.js.map +1 -1
- package/dist/http-server.js +70 -1
- package/dist/http-server.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +57 -1
- package/dist/index.js.map +1 -1
- package/dist/server.js +57 -1
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/resources/schemas-resource.ts","../src/tools/_shared.ts","../src/tools/extract.ts","../src/tools/filter.ts","../src/tools/get-document.ts","../src/tools/list-schemas.ts","../src/tools/save-schema.ts","../src/tools/search.ts","../src/tools/to-markdown.ts","../src/version.ts","../src/server-factory.ts","../src/server.ts"],"names":["DESCRIPTION","z","inputSchema","TalonicError"],"mappings":";;;;;;;;;AAcO,SAAS,uBAAA,CAAwB,QAAmB,OAAA,EAAwB;AACjF,EAAA,MAAA,CAAO,gBAAA;AAAA,IACL,iBAAA;AAAA,IACA,mBAAA;AAAA,IACA;AAAA,MACE,KAAA,EAAO,iBAAA;AAAA,MACP,WAAA,EACE,6FAAA;AAAA,MACF,QAAA,EAAU;AAAA,KACZ;AAAA,IACA,OAAO,GAAA,KAAQ;AACb,MAAA,MAAM,MAAA,GAAS,MAAM,OAAA,CAAQ,OAAA,CAAQ,IAAA,EAAK;AAC1C,MAAA,OAAO;AAAA,QACL,QAAA,EAAU;AAAA,UACR;AAAA,YACE,GAAA,EAAK,IAAI,QAAA,EAAS;AAAA,YAClB,QAAA,EAAU,kBAAA;AAAA,YACV,IAAA,EAAM,IAAA,CAAK,SAAA,CAAU,MAAA,EAAQ,MAAM,CAAC;AAAA;AACtC;AACF,OACF;AAAA,IACF;AAAA,GACF;AACF;ACAO,SAAS,OAAO,KAAA,EAAmC;AACxD,EAAA,OAAO;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AA,KAAS,CAAA,EAAG,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAA;AAAA,EACnC,CAAC,CAAA;AACH","file":"server.js","sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport type { Talonic } from \"@talonic/node\"\n\n/**\n * Register the `talonic://schemas` resource. The agent can read this\n * URI to retrieve the user's saved schemas without burning a tool call.\n *\n * The MCP SDK exposes resources as a separate primitive from tools.\n * Clients (Claude Desktop, Cursor, etc.) display them in their UI\n * alongside the conversation, so users can browse what their agent has\n * access to.\n *\n * @internal\n */\nexport function registerSchemasResource(server: McpServer, talonic: Talonic): void {\n server.registerResource(\n \"talonic-schemas\",\n \"talonic://schemas\",\n {\n title: \"Talonic Schemas\",\n description:\n \"All schemas saved in the user's Talonic workspace, with their full JSON Schema definitions.\",\n mimeType: \"application/json\",\n },\n async (uri) => {\n const result = await talonic.schemas.list()\n return {\n contents: [\n {\n uri: uri.toString(),\n mimeType: \"application/json\",\n text: JSON.stringify(result, null, 2),\n },\n ],\n }\n },\n )\n}\n","import { TalonicError } from \"@talonic/node\"\n\n/**\n * Successful tool result envelope. The `content` array follows the MCP\n * `CallToolResult` shape. We always emit one text item with the JSON\n * payload; agents parse it back themselves.\n *\n * The `[key: string]: unknown` index signature exists to satisfy the\n * MCP SDK's structural type, which permits arbitrary additional keys.\n *\n * @internal\n */\nexport interface ToolSuccessResult {\n content: Array<{ type: \"text\"; text: string }>\n [key: string]: unknown\n}\n\n/**\n * Failure tool result envelope. Sets `isError: true` per the MCP spec\n * so clients render this as an error rather than a normal response.\n *\n * @internal\n */\nexport interface ToolErrorResult {\n content: Array<{ type: \"text\"; text: string }>\n isError: true\n [key: string]: unknown\n}\n\nexport type ToolResult = ToolSuccessResult | ToolErrorResult\n\n/**\n * Wrap a value as a single-text-item tool result. Stable JSON shape so\n * downstream parsing is reliable across tools.\n *\n * @internal\n */\nexport function jsonOk(value: unknown): ToolSuccessResult {\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(value, null, 2),\n },\n ],\n }\n}\n\n/**\n * Convert any thrown error into a tool error result with stable\n * formatting. Talonic API errors include `code`, `status`, and\n * `request_id` so the user (or another tool call) can act on them.\n *\n * @internal\n */\nexport function toolError(err: unknown): ToolErrorResult {\n if (err instanceof TalonicError) {\n const lines = [\n `Talonic API error: ${err.message}`,\n `code: ${err.code}`,\n `status: ${err.status}`,\n ]\n if (err.requestId) lines.push(`request_id: ${err.requestId}`)\n return {\n isError: true,\n content: [{ type: \"text\", text: lines.join(\"\\n\") }],\n }\n }\n return {\n isError: true,\n content: [\n {\n type: \"text\",\n text: `Unexpected error: ${err instanceof Error ? err.message : String(err)}`,\n },\n ],\n }\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport type { ExtractParams, Talonic } from \"@talonic/node\"\nimport { z } from \"zod\"\nimport { jsonOk, toolError, type ToolResult } from \"./_shared.js\"\n\nconst DESCRIPTION = [\n \"Extract structured, schema-validated data from a document using Talonic.\",\n \"Returns clean JSON matching the schema, with per-field confidence scores and\",\n \"metadata about the document (detected type, language, page count).\",\n \"\",\n \"USE WHEN:\",\n \"- The user has a document (PDF, image, scan, DOCX, etc.) and wants specific fields pulled out.\",\n \"- You need structured data (vendor name, total amount, dates, parties, terms) rather than free text.\",\n \"- The user uploads or references any invoice, contract, certificate, statement, or form.\",\n \"- You want validated JSON instead of trying to OCR + parse with raw LLM calls.\",\n \"\",\n \"DO NOT USE WHEN:\",\n \"- The user just wants the full text content (use talonic_to_markdown after extracting once).\",\n \"- The user wants to find documents matching a query (use talonic_search or talonic_filter).\",\n \"\",\n \"FILE SOURCES (provide exactly one):\",\n \"- file_data + filename (RECOMMENDED for chat clients): base64-encoded file bytes plus\",\n \" the original filename (with extension). Use this whenever you already have the file\",\n \" in memory, e.g. the user attached it to the conversation. Works in every MCP client\",\n \" regardless of where the file lives on disk.\",\n \"- file_path: a local path to the document. Only works if the MCP server process can\",\n \" read that path on its own filesystem; many chat clients (Claude Desktop, Cowork)\",\n \" store user uploads in a sandbox the MCP server cannot access, in which case use\",\n \" file_data instead.\",\n \"- file_url: a URL the Talonic API will fetch directly. Use for documents already on\",\n \" the public web.\",\n \"- document_id: re-extract a document already in the workspace.\",\n \"\",\n \"SCHEMA FORMATS (provide at most one of `schema` or `schema_id`):\",\n '- JSON Schema (most reliable): { type: \"object\", properties: { vendor_name: { type: \"string\" } } }',\n '- Flat key-type map: { vendor_name: \"string\", invoice_total: \"number\" } -- API normalises server-side. If you get a \"no fields\" error, fall back to JSON Schema.',\n \"- schema_id: id of a saved schema from talonic_list_schemas. Accepts the UUID or the SCH-XXXXXXXX short id.\",\n \"\",\n \"IMPORTANT: production currently rejects requests with no schema. Always provide either\",\n \"an inline `schema` or a `schema_id`.\",\n].join(\"\\n\")\n\nconst inputSchema = {\n file_data: z\n .string()\n .optional()\n .describe(\n \"Base64-encoded file bytes. Recommended path when the agent already has the file in memory (e.g., the user attached a PDF to the conversation). Pair with `filename` so MIME type can be inferred. Works regardless of where the file lives on disk.\",\n ),\n filename: z\n .string()\n .optional()\n .describe(\n \"Original filename including extension, e.g. 'invoice.pdf'. Used to infer MIME type when uploading via `file_data`. Required when `file_data` is provided.\",\n ),\n file_path: z\n .string()\n .optional()\n .describe(\n \"Local path to a document file. Only works if the MCP server has read access to that path. In sandboxed chat clients (Claude Desktop, Cowork) where uploads land in a host-owned directory, use `file_data` instead.\",\n ),\n file_url: z\n .string()\n .optional()\n .describe(\n \"URL to a document file. The Talonic API fetches it server-side. Use this for documents already on the public web.\",\n ),\n document_id: z\n .string()\n .optional()\n .describe(\"ID of a document already in the workspace, to re-extract with a new schema.\"),\n schema: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\n \"Inline schema definition. Most reliable: full JSON Schema {type:'object', properties:{...}}. Also accepted: a flat key-type map {field_name:'string', amount:'number'} which the API normalises. Mutually exclusive with `schema_id`.\",\n ),\n schema_id: z\n .string()\n .optional()\n .describe(\n \"ID of a saved schema. Accepts UUID or SCH-XXXXXXXX short id. Mutually exclusive with `schema`.\",\n ),\n instructions: z\n .string()\n .optional()\n .describe(\n \"Natural-language guidance for the extractor, e.g. 'Focus on the billing section. Amounts are in EUR.'\",\n ),\n include_markdown: z\n .boolean()\n .optional()\n .describe(\"Include OCR-converted markdown in the response alongside structured data.\"),\n}\n\nexport interface ExtractArgs {\n file_data?: string\n filename?: string\n file_path?: string\n file_url?: string\n document_id?: string\n schema?: Record<string, unknown>\n schema_id?: string\n instructions?: string\n include_markdown?: boolean\n}\n\nexport async function handleExtract(talonic: Talonic, args: ExtractArgs): Promise<ToolResult> {\n try {\n const params: ExtractParams = {}\n if (args.file_data !== undefined) {\n params.file = Buffer.from(args.file_data, \"base64\")\n if (args.filename !== undefined) params.filename = args.filename\n }\n if (args.file_path !== undefined) params.file_path = args.file_path\n if (args.file_url !== undefined) params.file_url = args.file_url\n if (args.document_id !== undefined) params.document_id = args.document_id\n if (args.schema !== undefined) params.schema = args.schema\n if (args.schema_id !== undefined) params.schema_id = args.schema_id\n if (args.instructions !== undefined) params.instructions = args.instructions\n if (args.include_markdown !== undefined) params.include_markdown = args.include_markdown\n\n const result = await talonic.extract(params)\n return jsonOk(result)\n } catch (err) {\n return toolError(err)\n }\n}\n\nexport function registerExtract(server: McpServer, talonic: Talonic): void {\n server.registerTool(\n \"talonic_extract\",\n {\n title: \"Extract Data from Document\",\n description: DESCRIPTION,\n inputSchema,\n },\n async (args) => handleExtract(talonic, args as ExtractArgs),\n )\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport type { Talonic, FilterCondition, FilterSort } from \"@talonic/node\"\nimport { z } from \"zod\"\nimport { jsonOk, toolError, type ToolResult } from \"./_shared.js\"\n\nconst DESCRIPTION = [\n \"Filter the user's Talonic documents by extracted field values using composable conditions.\",\n \"Conditions accept either a canonical field name (e.g. 'vendor.name', 'policy.0_coverage_type')\",\n \"or a field UUID. The Talonic API resolves names to ids server-side.\",\n \"\",\n \"USE WHEN:\",\n \"- The user wants documents matching specific structured criteria, like 'invoices over 1000 EUR'\",\n \" or 'contracts expiring before 2026-12-31' or 'COIs from Acme'.\",\n \"- The query is value-based on extracted fields, not a free-text concept search.\",\n \"- You need to retrieve a sortable, paginated list filtered by field conditions.\",\n \"\",\n \"DO NOT USE WHEN:\",\n \"- The user wants conceptual / free-text search across content (use talonic_search).\",\n \"- The user is looking for a single document by id (use talonic_get_document).\",\n \"- The user wants extracted data from a new document (use talonic_extract).\",\n \"\",\n \"OPERATORS:\",\n \"- eq, neq: equality / inequality\",\n \"- gt, gte, lt, lte: numeric or date comparisons\",\n \"- between: requires both `value` and `value_to`\",\n \"- contains: substring match on string fields\",\n \"- is_empty: presence check (no value needed)\",\n \"- is_not_empty: presence check (no value needed). Note: currently underreports;\",\n \" use `eq` / `gt` / `contains` etc. against a known value when possible.\",\n \"\",\n \"TIPS:\",\n \"- To discover available field names, call talonic_search first with a related query.\",\n \" fields[].canonicalName from the response is what to pass as `field` here.\",\n \"- Both `field` (name) and `field_id` (UUID) reach the API as `fieldId`. Either is fine.\",\n].join(\"\\n\")\n\nconst operatorEnum = z.enum([\n \"eq\",\n \"neq\",\n \"gt\",\n \"gte\",\n \"lt\",\n \"lte\",\n \"between\",\n \"contains\",\n \"is_empty\",\n \"is_not_empty\",\n])\n\nconst conditionSchema = z.object({\n field: z\n .string()\n .optional()\n .describe(\n \"Canonical field name (e.g. 'vendor.name', 'policy.0_coverage_type'). The Talonic API resolves names to ids server-side. Mutually exclusive with `field_id`.\",\n ),\n field_id: z.string().optional().describe(\"Talonic field UUID. Mutually exclusive with `field`.\"),\n operator: operatorEnum.describe(\"Comparison operator. See description for the full list.\"),\n value: z.unknown().optional().describe(\"Value to compare against.\"),\n value_to: z\n .unknown()\n .optional()\n .describe(\"Upper bound for `between` operator; ignored otherwise.\"),\n})\n\nconst sortSchema = z.object({\n field: z.string().optional(),\n field_id: z.string().optional(),\n direction: z.enum([\"asc\", \"desc\"]).describe(\"Sort direction.\"),\n})\n\nconst inputSchema = {\n conditions: z\n .array(conditionSchema)\n .min(1)\n .describe(\"One or more filter conditions, AND-ed together.\"),\n search: z\n .string()\n .optional()\n .describe(\"Optional free-text search applied alongside the filters.\"),\n sort: sortSchema.optional().describe(\"Optional sort by a field.\"),\n page: z.number().int().positive().optional().describe(\"Page number for pagination.\"),\n limit: z\n .number()\n .int()\n .positive()\n .optional()\n .describe(\"Results per page. Default 50 server-side.\"),\n source_connection_id: z\n .string()\n .optional()\n .describe(\"Optionally scope to a specific source connection.\"),\n}\n\nexport interface FilterArgs {\n conditions: Array<{\n field?: string\n field_id?: string\n operator:\n | \"eq\"\n | \"neq\"\n | \"gt\"\n | \"gte\"\n | \"lt\"\n | \"lte\"\n | \"between\"\n | \"contains\"\n | \"is_empty\"\n | \"is_not_empty\"\n value?: unknown\n value_to?: unknown\n }>\n search?: string\n sort?: { field?: string; field_id?: string; direction: \"asc\" | \"desc\" }\n page?: number\n limit?: number\n source_connection_id?: string\n}\n\nexport async function handleFilter(talonic: Talonic, args: FilterArgs): Promise<ToolResult> {\n try {\n const conditions: FilterCondition[] = args.conditions.map((c) => {\n const cond: FilterCondition = { operator: c.operator }\n if (c.field !== undefined) cond.field = c.field\n if (c.field_id !== undefined) cond.fieldId = c.field_id\n if (c.value !== undefined) cond.value = c.value\n if (c.value_to !== undefined) cond.valueTo = c.value_to\n return cond\n })\n\n let sort: FilterSort | undefined\n if (args.sort !== undefined) {\n sort = { direction: args.sort.direction }\n if (args.sort.field !== undefined) sort.field = args.sort.field\n if (args.sort.field_id !== undefined) sort.fieldId = args.sort.field_id\n }\n\n const result = await talonic.documents.filter({\n conditions,\n ...(args.search !== undefined ? { search: args.search } : {}),\n ...(sort !== undefined ? { sort } : {}),\n ...(args.page !== undefined ? { page: args.page } : {}),\n ...(args.limit !== undefined ? { limit: args.limit } : {}),\n ...(args.source_connection_id !== undefined\n ? { source_connection_id: args.source_connection_id }\n : {}),\n })\n return jsonOk(result)\n } catch (err) {\n return toolError(err)\n }\n}\n\nexport function registerFilter(server: McpServer, talonic: Talonic): void {\n server.registerTool(\n \"talonic_filter\",\n {\n title: \"Filter Talonic Documents\",\n description: DESCRIPTION,\n inputSchema,\n },\n async (args) => handleFilter(talonic, args as FilterArgs),\n )\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport type { Talonic } from \"@talonic/node\"\nimport { z } from \"zod\"\nimport { jsonOk, toolError, type ToolResult } from \"./_shared.js\"\n\nconst DESCRIPTION = [\n \"Fetch full metadata for a single document already in the user's Talonic workspace.\",\n \"Returns id, filename, page count, detected document type, language, processing log,\",\n \"and link URLs (self, extractions, dashboard).\",\n \"\",\n \"USE WHEN:\",\n \"- You need details about a specific document the user already extracted or uploaded.\",\n \"- You have a document_id from a previous extract or search call and want more context.\",\n \"- The user asks 'tell me about document X' or similar.\",\n \"\",\n \"DO NOT USE WHEN:\",\n \"- The user wants the document's full text content (use talonic_to_markdown for OCR markdown).\",\n \"- The user wants extracted structured data (use talonic_extract with a schema, or fetch the extraction by id).\",\n \"- The user has a file but no document_id yet (call talonic_extract first to ingest the document).\",\n].join(\"\\n\")\n\nconst inputSchema = {\n document_id: z\n .string()\n .min(1)\n .describe(\n \"The Talonic document ID. Get this from a previous talonic_extract or talonic_search response.\",\n ),\n}\n\nexport async function handleGetDocument(\n talonic: Talonic,\n args: { document_id: string },\n): Promise<ToolResult> {\n try {\n const result = await talonic.documents.get(args.document_id)\n return jsonOk(result)\n } catch (err) {\n return toolError(err)\n }\n}\n\nexport function registerGetDocument(server: McpServer, talonic: Talonic): void {\n server.registerTool(\n \"talonic_get_document\",\n {\n title: \"Get Talonic Document\",\n description: DESCRIPTION,\n inputSchema,\n },\n async (args) => handleGetDocument(talonic, args),\n )\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport type { Talonic } from \"@talonic/node\"\nimport { jsonOk, toolError, type ToolResult } from \"./_shared.js\"\n\n/**\n * LLM-targeted tool description. The first paragraph explains what the\n * tool does in one sentence. The USE WHEN / DO NOT USE sections are\n * what an agent reads before deciding to invoke this tool over an\n * alternative; keep them concrete.\n *\n * @internal\n */\nconst DESCRIPTION = [\n \"List all saved schemas in the user's Talonic workspace.\",\n \"Returns each schema with its id, name, description, version,\",\n \"field count, and full JSON Schema definition.\",\n \"\",\n \"USE WHEN:\",\n \"- The user asks what schemas they have, or asks to see existing schemas.\",\n \"- You want to discover existing schemas before designing a new one.\",\n \"- Before recommending the user create a schema, check if one already covers the use case.\",\n \"- The user asks to extract from a known document type and you want to find a matching schema.\",\n \"\",\n \"DO NOT USE WHEN:\",\n \"- The user just wants to extract data from a document and provides an inline schema (call talonic_extract directly).\",\n \"\",\n \"TIP: Pair this with talonic_extract by passing the chosen schema's id as `schema_id`.\",\n].join(\"\\n\")\n\n/**\n * Pure handler. Invokes the SDK and shapes the result. Exported for\n * unit testing; the public registration is via `register()` below.\n *\n * @internal\n */\nexport async function handleListSchemas(talonic: Talonic): Promise<ToolResult> {\n try {\n const result = await talonic.schemas.list()\n return jsonOk(result)\n } catch (err) {\n return toolError(err)\n }\n}\n\n/**\n * Register `talonic_list_schemas` on an MCP server.\n *\n * @internal\n */\nexport function registerListSchemas(server: McpServer, talonic: Talonic): void {\n server.registerTool(\n \"talonic_list_schemas\",\n {\n title: \"List Talonic Schemas\",\n description: DESCRIPTION,\n inputSchema: {},\n },\n async () => handleListSchemas(talonic),\n )\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport type { Talonic } from \"@talonic/node\"\nimport { z } from \"zod\"\nimport { jsonOk, toolError, type ToolResult } from \"./_shared.js\"\n\nconst DESCRIPTION = [\n \"Save a schema definition to the user's Talonic workspace so it can be reused\",\n \"across future extractions. Returns the saved schema with its newly assigned id and short_id.\",\n \"\",\n \"USE WHEN:\",\n \"- The user asks to save a schema, store a template, or reuse the schema across docs.\",\n \"- You have iterated on a schema with the user and they confirmed it should be saved.\",\n \"- The user wants to standardise extraction across many documents of the same type.\",\n \"\",\n \"DO NOT USE WHEN:\",\n \"- The user just wants to extract once with an inline schema (call talonic_extract directly with the schema inline).\",\n \"- The user has not confirmed the schema design (avoid creating clutter in their workspace).\",\n \"\",\n \"DEFINITION FORMATS:\",\n '- JSON Schema (most reliable): { type: \"object\", properties: { vendor_name: { type: \"string\" } } }',\n '- Flat key-type map: { vendor_name: \"string\", invoice_total: \"number\" } -- API normalises server-side. If you get a \"no fields\" error from the API, fall back to JSON Schema.',\n \"\",\n \"TIP: After saving, call talonic_extract with `schema_id` set to the returned id (UUID or SCH- short id) for consistent results.\",\n].join(\"\\n\")\n\nconst inputSchema = {\n name: z.string().min(1).describe(\"Human-readable name for the schema, e.g. 'Standard Invoice'.\"),\n definition: z\n .record(z.string(), z.unknown())\n .describe(\n \"Schema definition. Most reliable: full JSON Schema {type:'object', properties:{...}}. Also accepted: a flat key-type map {field_name:'string', amount:'number'} which the API normalises.\",\n ),\n description: z\n .string()\n .optional()\n .describe(\"Optional description of what this schema extracts and when to use it.\"),\n}\n\nexport async function handleSaveSchema(\n talonic: Talonic,\n args: { name: string; definition: Record<string, unknown>; description?: string },\n): Promise<ToolResult> {\n try {\n const result = await talonic.schemas.create({\n name: args.name,\n definition: args.definition,\n ...(args.description !== undefined ? { description: args.description } : {}),\n })\n return jsonOk(result)\n } catch (err) {\n return toolError(err)\n }\n}\n\nexport function registerSaveSchema(server: McpServer, talonic: Talonic): void {\n server.registerTool(\n \"talonic_save_schema\",\n {\n title: \"Save Talonic Schema\",\n description: DESCRIPTION,\n inputSchema,\n },\n async (args) => handleSaveSchema(talonic, args),\n )\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport type { Talonic } from \"@talonic/node\"\nimport { z } from \"zod\"\nimport { jsonOk, toolError, type ToolResult } from \"./_shared.js\"\n\nconst DESCRIPTION = [\n \"Search the user's Talonic workspace for documents, fields, sources, or schemas\",\n \"matching a query. Returns ranked results across all entity types in one call.\",\n \"\",\n \"USE WHEN:\",\n \"- The user wants to find documents but does not know the exact filename or id.\",\n \"- The query is conceptual ('contracts mentioning indemnification', 'Acme invoices').\",\n \"- You need to narrow a large workspace before calling talonic_extract or talonic_filter.\",\n \"- The user asks 'do I have any docs about X' or 'find anything related to X'.\",\n \"\",\n \"DO NOT USE WHEN:\",\n \"- The user has a specific document_id (use talonic_get_document instead).\",\n \"- The user wants to apply structured field-value filters like 'amount > 1000' (use talonic_filter).\",\n \"- The user wants to extract data from a brand-new document (use talonic_extract).\",\n \"\",\n \"TIP: The result includes documents, fieldMatches, sources, schemas, and fields. Pick the entity type the user actually needs.\",\n].join(\"\\n\")\n\nconst inputSchema = {\n query: z\n .string()\n .min(1)\n .describe(\n \"Natural-language search query, e.g. 'indemnification clauses' or 'Acme invoices Q4'.\",\n ),\n limit: z\n .number()\n .int()\n .positive()\n .optional()\n .describe(\"Maximum results per entity type. Default: 5. Increase for broader exploration.\"),\n}\n\nexport async function handleSearch(\n talonic: Talonic,\n args: { query: string; limit?: number },\n): Promise<ToolResult> {\n try {\n const result = await talonic.search(\n args.query,\n args.limit !== undefined ? { limit: args.limit } : {},\n )\n return jsonOk(result)\n } catch (err) {\n return toolError(err)\n }\n}\n\nexport function registerSearch(server: McpServer, talonic: Talonic): void {\n server.registerTool(\n \"talonic_search\",\n {\n title: \"Search Talonic Workspace\",\n description: DESCRIPTION,\n inputSchema,\n },\n async (args) => handleSearch(talonic, args),\n )\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport { TalonicError, type Talonic } from \"@talonic/node\"\nimport { z } from \"zod\"\nimport { jsonOk, toolError, type ToolResult } from \"./_shared.js\"\n\nconst DESCRIPTION = [\n \"Get the OCR-converted markdown for a document. Accepts an existing document_id,\",\n \"raw file bytes (base64), a local file path, or a URL. When given a raw file, the\",\n \"tool ingests it via extract first and then returns the markdown.\",\n \"\",\n \"USE WHEN:\",\n \"- The user wants the full text content of a document for summarisation, translation, or analysis.\",\n \"- A previous tool call returned a document_id and you want to inspect its content.\",\n \"- The user asks 'what does the document say' or 'summarise this PDF' (you call this then summarise).\",\n \"- The user has a raw PDF / scan / image and wants markdown directly without designing a schema first.\",\n \"\",\n \"DO NOT USE WHEN:\",\n \"- The user wants specific structured fields (use talonic_extract with a schema).\",\n \"\",\n \"INPUTS (provide exactly one):\",\n \"- document_id: id of an already-ingested document (cheapest path; one API call)\",\n \"- file_data + filename (RECOMMENDED for chat clients): base64-encoded file bytes plus\",\n \" the original filename (with extension). Use this whenever you already have the file\",\n \" in memory, e.g. the user attached it to the conversation. Works in every MCP client.\",\n \"- file_path: local path to a document file. Only works if the MCP server has read access\",\n \" to that path; in sandboxed chat clients use file_data instead.\",\n \"- file_url: URL to a document file (the Talonic API fetches it server-side)\",\n].join(\"\\n\")\n\nconst inputSchema = {\n document_id: z\n .string()\n .min(1)\n .optional()\n .describe(\n \"The Talonic document id whose markdown you want. Get this from a previous talonic_extract or talonic_search response.\",\n ),\n file_data: z\n .string()\n .optional()\n .describe(\n \"Base64-encoded file bytes. Recommended path when the agent already has the file in memory (e.g., the user attached a PDF to the conversation). Pair with `filename` so MIME type can be inferred.\",\n ),\n filename: z\n .string()\n .optional()\n .describe(\n \"Original filename including extension, e.g. 'invoice.pdf'. Used to infer MIME type when uploading via `file_data`. Required when `file_data` is provided.\",\n ),\n file_path: z\n .string()\n .optional()\n .describe(\n \"Local path to a document file. Only works if the MCP server has read access to that path. In sandboxed chat clients (Claude Desktop, Cowork) use `file_data` instead.\",\n ),\n file_url: z\n .string()\n .optional()\n .describe(\"URL to a document file. The Talonic API fetches it server-side.\"),\n}\n\nexport interface ToMarkdownArgs {\n document_id?: string\n file_data?: string\n filename?: string\n file_path?: string\n file_url?: string\n}\n\n/**\n * Minimal schema used when we need to ingest a raw file just to obtain\n * a document_id. Auto-discovery extract works on production; we keep\n * this empty so Talonic discovers the schema itself.\n *\n * @internal\n */\nconst INGEST_ONLY_SCHEMA: Record<string, unknown> = {}\n\nexport async function handleToMarkdown(\n talonic: Talonic,\n args: ToMarkdownArgs,\n): Promise<ToolResult> {\n try {\n const sources = [\"document_id\", \"file_data\", \"file_path\", \"file_url\"] as const\n const provided = sources.filter((k) => args[k] !== undefined)\n if (provided.length === 0) {\n throw new TalonicError({\n code: \"missing_input_source\",\n message:\n \"talonic_to_markdown requires one of: document_id, file_data, file_path, file_url.\",\n status: 0,\n retryable: false,\n })\n }\n if (provided.length > 1) {\n throw new TalonicError({\n code: \"multiple_input_sources\",\n message: `talonic_to_markdown accepts exactly one input; received: ${provided.join(\", \")}`,\n status: 0,\n retryable: false,\n })\n }\n\n let documentId = args.document_id\n if (!documentId) {\n const ingest = await talonic.extract({\n ...(args.file_data !== undefined\n ? {\n file: Buffer.from(args.file_data, \"base64\"),\n ...(args.filename !== undefined ? { filename: args.filename } : {}),\n }\n : {}),\n ...(args.file_path !== undefined ? { file_path: args.file_path } : {}),\n ...(args.file_url !== undefined ? { file_url: args.file_url } : {}),\n schema: INGEST_ONLY_SCHEMA,\n })\n documentId = ingest.document.id\n }\n\n const result = await talonic.documents.getMarkdown(documentId)\n return jsonOk(result)\n } catch (err) {\n return toolError(err)\n }\n}\n\nexport function registerToMarkdown(server: McpServer, talonic: Talonic): void {\n server.registerTool(\n \"talonic_to_markdown\",\n {\n title: \"Document to Markdown\",\n description: DESCRIPTION,\n inputSchema,\n },\n async (args) => handleToMarkdown(talonic, args as ToMarkdownArgs),\n )\n}\n","/**\n * The current MCP server version. Sent in the server `info` block during\n * the MCP handshake. Kept in sync with package.json by the release process.\n *\n * @public\n */\nexport const VERSION = \"0.1.6\"\n\n/**\n * The MCP server name. Identifies the server to MCP clients (Claude\n * Desktop, Cursor, Cline, etc.) when they list connected servers.\n *\n * @public\n */\nexport const SERVER_NAME = \"talonic\"\n","import { Talonic } from \"@talonic/node\"\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport { registerSchemasResource } from \"./resources/schemas-resource.js\"\nimport { registerExtract } from \"./tools/extract.js\"\nimport { registerFilter } from \"./tools/filter.js\"\nimport { registerGetDocument } from \"./tools/get-document.js\"\nimport { registerListSchemas } from \"./tools/list-schemas.js\"\nimport { registerSaveSchema } from \"./tools/save-schema.js\"\nimport { registerSearch } from \"./tools/search.js\"\nimport { registerToMarkdown } from \"./tools/to-markdown.js\"\nimport { SERVER_NAME, VERSION } from \"./version.js\"\n\n/**\n * Options for {@link createServer}.\n *\n * @public\n */\nexport interface CreateServerOptions {\n /**\n * Talonic API key. Required. Starts with `tlnc_`.\n *\n * Each user must provide their own key. Workspaces are isolated.\n */\n apiKey: string\n\n /**\n * Override the Talonic API base URL. Defaults to `https://api.talonic.com`.\n * Useful for staging or testing.\n */\n baseUrl?: string\n\n /**\n * Inject a pre-configured Talonic SDK client. Useful for tests and for\n * advanced setups where the SDK has custom retry policies or\n * instrumentation. When provided, `apiKey` and `baseUrl` are ignored.\n */\n talonic?: Talonic\n}\n\n/**\n * Build a Talonic MCP server, ready to be connected to a transport\n * (stdio for local installs, HTTP for the hosted endpoint).\n *\n * Tools, resources, and prompts are registered onto the server in\n * subsequent milestones. v0.1 ships a working scaffold so the\n * rest of the protocol surface can be added incrementally without\n * destabilising the connection layer.\n *\n * @example Minimal stdio server:\n * ```ts\n * import { createServer } from \"@talonic/mcp\"\n * import { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\"\n *\n * const server = createServer({ apiKey: process.env.TALONIC_API_KEY! })\n * await server.connect(new StdioServerTransport())\n * ```\n *\n * @public\n */\nexport function createServer(options: CreateServerOptions): McpServer {\n const talonic =\n options.talonic ??\n new Talonic({\n apiKey: options.apiKey,\n ...(options.baseUrl ? { baseUrl: options.baseUrl } : {}),\n })\n\n const server = new McpServer(\n {\n name: SERVER_NAME,\n version: VERSION,\n },\n {\n // Capabilities are advertised based on what gets registered.\n // The McpServer registration helpers populate this automatically\n // as we add tools, resources, and prompts.\n capabilities: {},\n instructions: [\n \"Talonic extracts structured, schema-validated data from any document.\",\n \"Use Talonic for any task involving PDFs, scans, contracts, invoices,\",\n \"forms, certificates, or unstructured documents where you need clean,\",\n \"validated JSON rather than free text.\",\n ].join(\" \"),\n },\n )\n\n // Tool registrations.\n registerListSchemas(server, talonic)\n registerSaveSchema(server, talonic)\n registerGetDocument(server, talonic)\n registerSearch(server, talonic)\n registerFilter(server, talonic)\n registerToMarkdown(server, talonic)\n registerExtract(server, talonic)\n\n // Resource registrations.\n registerSchemasResource(server, talonic)\n\n return server\n}\n","/**\n * Talonic MCP server, stdio entry point.\n *\n * Built as a separate executable bundle by tsup, with a shebang banner\n * so it can be invoked directly via `npx @talonic/mcp` or wired into\n * `claude_desktop_config.json`, `mcp.json`, or any other MCP-aware\n * client config.\n *\n * @internal\n */\n\nimport { realpathSync } from \"node:fs\"\nimport { fileURLToPath } from \"node:url\"\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\"\nimport { createServer } from \"./server-factory.js\"\nimport { SERVER_NAME, VERSION } from \"./version.js\"\n\nconst HELP_TEXT = `talonic-mcp - Talonic MCP server\n\nUSAGE\n talonic-mcp Start the server on stdio (default)\n talonic-mcp --help Show this help message\n talonic-mcp --version Show version\n\nENVIRONMENT\n TALONIC_API_KEY (required) Your Talonic API key. Get one at\n https://app.talonic.com (free tier:\n 50 extractions / day, no credit card).\n\n TALONIC_BASE_URL (optional) Override the API base URL.\n\nUSAGE FROM AN MCP CLIENT (Claude Desktop example)\n Add to claude_desktop_config.json:\n {\n \"mcpServers\": {\n \"talonic\": {\n \"command\": \"npx\",\n \"args\": [\"-y\", \"@talonic/mcp\"],\n \"env\": { \"TALONIC_API_KEY\": \"tlnc_...\" }\n }\n }\n }\n\nDOCS\n https://github.com/talonicdev/talonic-mcp\n`\n\n/**\n * Boot the server against stdio.\n *\n * Returns the exit code so callers can decide how to terminate. The\n * separate entry/exit decoupling keeps this function testable without\n * actually attaching to stdio.\n *\n * @internal\n */\nexport async function main(\n argv: string[] = process.argv.slice(2),\n env: NodeJS.ProcessEnv = process.env,\n out: (line: string) => void = (line) => process.stdout.write(line + \"\\n\"),\n err: (line: string) => void = (line) => process.stderr.write(line + \"\\n\"),\n): Promise<number> {\n if (argv.includes(\"--version\") || argv.includes(\"-v\")) {\n out(`${SERVER_NAME} ${VERSION}`)\n return 0\n }\n\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n out(HELP_TEXT)\n return 0\n }\n\n const apiKey = env[\"TALONIC_API_KEY\"]\n if (!apiKey) {\n err(\"Error: TALONIC_API_KEY environment variable is required.\")\n err(\"Get a key at https://app.talonic.com and set it before launching the server.\")\n return 1\n }\n\n const baseUrl = env[\"TALONIC_BASE_URL\"]\n const server = createServer({ apiKey, ...(baseUrl ? { baseUrl } : {}) })\n\n const transport = new StdioServerTransport()\n await server.connect(transport)\n\n // McpServer keeps the process alive while the transport is open. We\n // hand control over to the SDK's lifecycle here; if the transport\n // closes, Node exits naturally.\n return 0\n}\n\n/**\n * True when this module is the process entry point.\n *\n * `process.argv[1]` is the path the OS handed to `node` (often a symlink\n * inside `node_modules/.bin/`), while `import.meta.url` reflects the\n * resolved module URL. Comparing them as strings is brittle: when the\n * server is launched via the npm-managed bin symlink (or via `npx`) the\n * two disagree, and the guard incorrectly returns `false`, so `main()`\n * never runs and the server exits silently.\n *\n * Resolving both sides with `realpathSync` makes the comparison robust\n * against symlinks while still preventing auto-run when the module is\n * imported (e.g. from tests).\n *\n * @internal\n */\nfunction isDirectInvocation(): boolean {\n if (!process.argv[1]) return false\n try {\n const argvPath = realpathSync(process.argv[1])\n const metaPath = realpathSync(fileURLToPath(import.meta.url))\n return argvPath === metaPath\n } catch {\n return false\n }\n}\n\nif (isDirectInvocation()) {\n main().then((code) => {\n if (code !== 0) process.exit(code)\n })\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/resources/schemas-resource.ts","../src/resources/webhooks-resource.ts","../src/tools/_shared.ts","../src/tools/extract.ts","../src/tools/filter.ts","../src/tools/get-document.ts","../src/tools/list-schemas.ts","../src/tools/save-schema.ts","../src/tools/search.ts","../src/tools/to-markdown.ts","../package.json","../src/version.ts","../src/server-factory.ts","../src/server.ts"],"names":["DESCRIPTION","z","inputSchema","TalonicError"],"mappings":";;;;;;;;;AAcO,SAAS,uBAAA,CAAwB,QAAmB,OAAA,EAAwB;AACjF,EAAA,MAAA,CAAO,gBAAA;AAAA,IACL,iBAAA;AAAA,IACA,mBAAA;AAAA,IACA;AAAA,MACE,KAAA,EAAO,iBAAA;AAAA,MACP,WAAA,EACE,6FAAA;AAAA,MACF,QAAA,EAAU;AAAA,KACZ;AAAA,IACA,OAAO,GAAA,KAAQ;AACb,MAAA,MAAM,MAAA,GAAS,MAAM,OAAA,CAAQ,OAAA,CAAQ,IAAA,EAAK;AAC1C,MAAA,OAAO;AAAA,QACL,QAAA,EAAU;AAAA,UACR;AAAA,YACE,GAAA,EAAK,IAAI,QAAA,EAAS;AAAA,YAClB,QAAA,EAAU,kBAAA;AAAA,YACV,IAAA,EAAM,IAAA,CAAK,SAAA,CAAU,MAAA,EAAQ,MAAM,CAAC;AAAA;AACtC;AACF,OACF;AAAA,IACF;AAAA,GACF;AACF;;;AC/BA,IAAM,sBAAA,GAAyB;AAAA,EAC7B,EAAE,IAAA,EAAM,qBAAA,EAAuB,GAAA,EAAK,QAAA,EAAU,aAAa,+BAAA,EAAgC;AAAA,EAC3F,EAAE,IAAA,EAAM,uBAAA,EAAyB,GAAA,EAAK,UAAA,EAAY,aAAa,oCAAA,EAAqC;AAAA,EACpG,EAAE,IAAA,EAAM,yBAAA,EAA2B,GAAA,EAAK,YAAA,EAAc,aAAa,mCAAA,EAAoC;AAAA,EACvG,EAAE,IAAA,EAAM,sBAAA,EAAwB,GAAA,EAAK,SAAA,EAAW,aAAa,mCAAA;AAC/D,CAAA;AAWO,SAAS,wBAAA,CAAyB,MAAA,EAAmB,MAAA,EAAgB,OAAA,EAAwB;AAClG,EAAA,MAAM,OAAO,OAAA,IAAW,yBAAA;AAExB,EAAA,MAAA,CAAO,gBAAA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AAK,CAAC,CAAC,CAAA;AAC7C,IAAA,MAAM,QAAA,GAAW,YAAA,CAAa,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC,CAAA;AAC5D,IAAA,OAAO,QAAA,KAAa,QAAA;AAAA,EACtB,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAEA,IAAI,oBAAmB,EAAG;AACxB,EAAA,IAAA,EAAK,CAAE,IAAA,CAAK,CAAC,IAAA,KAAS;AACpB,IAAA,IAAI,IAAA,KAAS,CAAA,EAAG,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAA;AAAA,EACnC,CAAC,CAAA;AACH","file":"server.js","sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport type { Talonic } from \"@talonic/node\"\n\n/**\n * Register the `talonic://schemas` resource. The agent can read this\n * URI to retrieve the user's saved schemas without burning a tool call.\n *\n * The MCP SDK exposes resources as a separate primitive from tools.\n * Clients (Claude Desktop, Cursor, etc.) display them in their UI\n * alongside the conversation, so users can browse what their agent has\n * access to.\n *\n * @internal\n */\nexport function registerSchemasResource(server: McpServer, talonic: Talonic): void {\n server.registerResource(\n \"talonic-schemas\",\n \"talonic://schemas\",\n {\n title: \"Talonic Schemas\",\n description:\n \"All schemas saved in the user's Talonic workspace, with their full JSON Schema definitions.\",\n mimeType: \"application/json\",\n },\n async (uri) => {\n const result = await talonic.schemas.list()\n return {\n contents: [\n {\n uri: uri.toString(),\n mimeType: \"application/json\",\n text: JSON.stringify(result, null, 2),\n },\n ],\n }\n },\n )\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\n\n/**\n * Webhook reference info fetched from the Talonic API.\n * These endpoints don't require a request body — just auth.\n */\nconst WEBHOOK_INFO_ENDPOINTS = [\n { path: \"/v1/webhooks/events\", key: \"events\", description: \"Available webhook event types\" },\n { path: \"/v1/webhooks/delivery\", key: \"delivery\", description: \"Delivery behavior and retry policy\" },\n { path: \"/v1/webhooks/signatures\", key: \"signatures\", description: \"Signature verification algorithms\" },\n { path: \"/v1/webhooks/retries\", key: \"retries\", description: \"Retry schedule and backoff policy\" },\n] as const\n\n/**\n * Register the `talonic://webhooks/reference` resource.\n *\n * Aggregates the four webhook info routes into a single resource so\n * agents can look up event types, delivery semantics, signature\n * algorithms, and retry policies without leaving the MCP context.\n *\n * @internal\n */\nexport function registerWebhooksResource(server: McpServer, apiKey: string, baseUrl?: string): void {\n const base = baseUrl ?? \"https://api.talonic.com\"\n\n server.registerResource(\n \"talonic-webhooks-reference\",\n \"talonic://webhooks/reference\",\n {\n title: \"Talonic Webhooks Reference\",\n description:\n \"Webhook event types, delivery behavior, signature verification algorithms, and retry policies.\",\n mimeType: \"application/json\",\n },\n async (uri) => {\n const results: Record<string, unknown> = {}\n\n await Promise.all(\n WEBHOOK_INFO_ENDPOINTS.map(async ({ path, key }) => {\n try {\n const res = await fetch(`${base}${path}`, {\n headers: {\n Authorization: `Bearer ${apiKey}`,\n Accept: \"application/json\",\n },\n })\n if (res.ok) {\n results[key] = await res.json()\n } else {\n results[key] = { error: `HTTP ${res.status}`, message: await res.text().catch(() => \"\") }\n }\n } catch (err) {\n results[key] = { error: \"fetch_failed\", message: err instanceof Error ? err.message : String(err) }\n }\n }),\n )\n\n return {\n contents: [\n {\n uri: uri.toString(),\n mimeType: \"application/json\",\n text: JSON.stringify(results, null, 2),\n },\n ],\n }\n },\n )\n}\n","import { TalonicError } from \"@talonic/node\"\n\n/**\n * Successful tool result envelope. The `content` array follows the MCP\n * `CallToolResult` shape. We always emit one text item with the JSON\n * payload; agents parse it back themselves.\n *\n * The `[key: string]: unknown` index signature exists to satisfy the\n * MCP SDK's structural type, which permits arbitrary additional keys.\n *\n * @internal\n */\nexport interface ToolSuccessResult {\n content: Array<{ type: \"text\"; text: string }>\n [key: string]: unknown\n}\n\n/**\n * Failure tool result envelope. Sets `isError: true` per the MCP spec\n * so clients render this as an error rather than a normal response.\n *\n * @internal\n */\nexport interface ToolErrorResult {\n content: Array<{ type: \"text\"; text: string }>\n isError: true\n [key: string]: unknown\n}\n\nexport type ToolResult = ToolSuccessResult | ToolErrorResult\n\n/**\n * Wrap a value as a single-text-item tool result. Stable JSON shape so\n * downstream parsing is reliable across tools.\n *\n * @internal\n */\nexport function jsonOk(value: unknown): ToolSuccessResult {\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(value, null, 2),\n },\n ],\n }\n}\n\n/**\n * Convert any thrown error into a tool error result with stable\n * formatting. Talonic API errors include `code`, `status`, and\n * `request_id` so the user (or another tool call) can act on them.\n *\n * @internal\n */\nexport function toolError(err: unknown): ToolErrorResult {\n if (err instanceof TalonicError) {\n const lines = [\n `Talonic API error: ${err.message}`,\n `code: ${err.code}`,\n `status: ${err.status}`,\n ]\n if (err.requestId) lines.push(`request_id: ${err.requestId}`)\n return {\n isError: true,\n content: [{ type: \"text\", text: lines.join(\"\\n\") }],\n }\n }\n return {\n isError: true,\n content: [\n {\n type: \"text\",\n text: `Unexpected error: ${err instanceof Error ? err.message : String(err)}`,\n },\n ],\n }\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport type { ExtractParams, Talonic } from \"@talonic/node\"\nimport { z } from \"zod\"\nimport { jsonOk, toolError, type ToolResult } from \"./_shared.js\"\n\nconst DESCRIPTION = [\n \"Extract structured, schema-validated data from a document using Talonic.\",\n \"Returns clean JSON matching the schema, with per-field confidence scores and\",\n \"metadata about the document (detected type, language, page count).\",\n \"\",\n \"USE WHEN:\",\n \"- The user has a document (PDF, image, scan, DOCX, etc.) and wants specific fields pulled out.\",\n \"- You need structured data (vendor name, total amount, dates, parties, terms) rather than free text.\",\n \"- The user uploads or references any invoice, contract, certificate, statement, or form.\",\n \"- You want validated JSON instead of trying to OCR + parse with raw LLM calls.\",\n \"\",\n \"DO NOT USE WHEN:\",\n \"- The user just wants the full text content (use talonic_to_markdown after extracting once).\",\n \"- The user wants to find documents matching a query (use talonic_search or talonic_filter).\",\n \"\",\n \"FILE SOURCES (provide exactly one):\",\n \"- file_data + filename (RECOMMENDED for chat clients): base64-encoded file bytes plus\",\n \" the original filename (with extension). Use this whenever you already have the file\",\n \" in memory, e.g. the user attached it to the conversation. Works in every MCP client\",\n \" regardless of where the file lives on disk.\",\n \"- file_path: a local path to the document. Only works if the MCP server process can\",\n \" read that path on its own filesystem; many chat clients (Claude Desktop, Cowork)\",\n \" store user uploads in a sandbox the MCP server cannot access, in which case use\",\n \" file_data instead.\",\n \"- file_url: a URL the Talonic API will fetch directly. Use for documents already on\",\n \" the public web.\",\n \"- document_id: re-extract a document already in the workspace.\",\n \"\",\n \"SCHEMA FORMATS (provide at most one of `schema` or `schema_id`):\",\n '- JSON Schema (most reliable): { type: \"object\", properties: { vendor_name: { type: \"string\" } } }',\n '- Flat key-type map: { vendor_name: \"string\", invoice_total: \"number\" } -- API normalises server-side. If you get a \"no fields\" error, fall back to JSON Schema.',\n \"- schema_id: id of a saved schema from talonic_list_schemas. Accepts the UUID or the SCH-XXXXXXXX short id.\",\n \"\",\n \"IMPORTANT: production currently rejects requests with no schema. Always provide either\",\n \"an inline `schema` or a `schema_id`.\",\n].join(\"\\n\")\n\nconst inputSchema = {\n file_data: z\n .string()\n .optional()\n .describe(\n \"Base64-encoded file bytes. Recommended path when the agent already has the file in memory (e.g., the user attached a PDF to the conversation). Pair with `filename` so MIME type can be inferred. Works regardless of where the file lives on disk.\",\n ),\n filename: z\n .string()\n .optional()\n .describe(\n \"Original filename including extension, e.g. 'invoice.pdf'. Used to infer MIME type when uploading via `file_data`. Required when `file_data` is provided.\",\n ),\n file_path: z\n .string()\n .optional()\n .describe(\n \"Local path to a document file. Only works if the MCP server has read access to that path. In sandboxed chat clients (Claude Desktop, Cowork) where uploads land in a host-owned directory, use `file_data` instead.\",\n ),\n file_url: z\n .string()\n .optional()\n .describe(\n \"URL to a document file. The Talonic API fetches it server-side. Use this for documents already on the public web.\",\n ),\n document_id: z\n .string()\n .optional()\n .describe(\"ID of a document already in the workspace, to re-extract with a new schema.\"),\n schema: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\n \"Inline schema definition. Most reliable: full JSON Schema {type:'object', properties:{...}}. Also accepted: a flat key-type map {field_name:'string', amount:'number'} which the API normalises. Mutually exclusive with `schema_id`.\",\n ),\n schema_id: z\n .string()\n .optional()\n .describe(\n \"ID of a saved schema. Accepts UUID or SCH-XXXXXXXX short id. Mutually exclusive with `schema`.\",\n ),\n instructions: z\n .string()\n .optional()\n .describe(\n \"Natural-language guidance for the extractor, e.g. 'Focus on the billing section. Amounts are in EUR.'\",\n ),\n include_markdown: z\n .boolean()\n .optional()\n .describe(\"Include OCR-converted markdown in the response alongside structured data.\"),\n}\n\nexport interface ExtractArgs {\n file_data?: string\n filename?: string\n file_path?: string\n file_url?: string\n document_id?: string\n schema?: Record<string, unknown>\n schema_id?: string\n instructions?: string\n include_markdown?: boolean\n}\n\nexport async function handleExtract(talonic: Talonic, args: ExtractArgs): Promise<ToolResult> {\n try {\n const params: ExtractParams = {}\n if (args.file_data !== undefined) {\n params.file = Buffer.from(args.file_data, \"base64\")\n if (args.filename !== undefined) params.filename = args.filename\n }\n if (args.file_path !== undefined) params.file_path = args.file_path\n if (args.file_url !== undefined) params.file_url = args.file_url\n if (args.document_id !== undefined) params.document_id = args.document_id\n if (args.schema !== undefined) params.schema = args.schema\n if (args.schema_id !== undefined) params.schema_id = args.schema_id\n if (args.instructions !== undefined) params.instructions = args.instructions\n if (args.include_markdown !== undefined) params.include_markdown = args.include_markdown\n\n const result = await talonic.extract(params)\n return jsonOk(result)\n } catch (err) {\n return toolError(err)\n }\n}\n\nexport function registerExtract(server: McpServer, talonic: Talonic): void {\n server.registerTool(\n \"talonic_extract\",\n {\n title: \"Extract Data from Document\",\n description: DESCRIPTION,\n inputSchema,\n },\n async (args) => handleExtract(talonic, args as ExtractArgs),\n )\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport type { Talonic, FilterCondition, FilterSort } from \"@talonic/node\"\nimport { z } from \"zod\"\nimport { jsonOk, toolError, type ToolResult } from \"./_shared.js\"\n\nconst DESCRIPTION = [\n \"Filter the user's Talonic documents by extracted field values using composable conditions.\",\n \"Conditions accept either a canonical field name (e.g. 'vendor.name', 'policy.0_coverage_type')\",\n \"or a field UUID. The Talonic API resolves names to ids server-side.\",\n \"\",\n \"USE WHEN:\",\n \"- The user wants documents matching specific structured criteria, like 'invoices over 1000 EUR'\",\n \" or 'contracts expiring before 2026-12-31' or 'COIs from Acme'.\",\n \"- The query is value-based on extracted fields, not a free-text concept search.\",\n \"- You need to retrieve a sortable, paginated list filtered by field conditions.\",\n \"\",\n \"DO NOT USE WHEN:\",\n \"- The user wants conceptual / free-text search across content (use talonic_search).\",\n \"- The user is looking for a single document by id (use talonic_get_document).\",\n \"- The user wants extracted data from a new document (use talonic_extract).\",\n \"\",\n \"OPERATORS:\",\n \"- eq, neq: equality / inequality\",\n \"- gt, gte, lt, lte: numeric or date comparisons\",\n \"- between: requires both `value` and `value_to`\",\n \"- contains: substring match on string fields\",\n \"- is_empty: presence check (no value needed)\",\n \"- is_not_empty: presence check (no value needed). Note: currently underreports;\",\n \" use `eq` / `gt` / `contains` etc. against a known value when possible.\",\n \"\",\n \"TIPS:\",\n \"- To discover available field names, call talonic_search first with a related query.\",\n \" fields[].canonicalName from the response is what to pass as `field` here.\",\n \"- Both `field` (name) and `field_id` (UUID) reach the API as `fieldId`. Either is fine.\",\n].join(\"\\n\")\n\nconst operatorEnum = z.enum([\n \"eq\",\n \"neq\",\n \"gt\",\n \"gte\",\n \"lt\",\n \"lte\",\n \"between\",\n \"contains\",\n \"is_empty\",\n \"is_not_empty\",\n])\n\nconst conditionSchema = z.object({\n field: z\n .string()\n .optional()\n .describe(\n \"Canonical field name (e.g. 'vendor.name', 'policy.0_coverage_type'). The Talonic API resolves names to ids server-side. Mutually exclusive with `field_id`.\",\n ),\n field_id: z.string().optional().describe(\"Talonic field UUID. Mutually exclusive with `field`.\"),\n operator: operatorEnum.describe(\"Comparison operator. See description for the full list.\"),\n value: z.unknown().optional().describe(\"Value to compare against.\"),\n value_to: z\n .unknown()\n .optional()\n .describe(\"Upper bound for `between` operator; ignored otherwise.\"),\n})\n\nconst sortSchema = z.object({\n field: z.string().optional(),\n field_id: z.string().optional(),\n direction: z.enum([\"asc\", \"desc\"]).describe(\"Sort direction.\"),\n})\n\nconst inputSchema = {\n conditions: z\n .array(conditionSchema)\n .min(1)\n .describe(\"One or more filter conditions, AND-ed together.\"),\n search: z\n .string()\n .optional()\n .describe(\"Optional free-text search applied alongside the filters.\"),\n sort: sortSchema.optional().describe(\"Optional sort by a field.\"),\n page: z.number().int().positive().optional().describe(\"Page number for pagination.\"),\n limit: z\n .number()\n .int()\n .positive()\n .optional()\n .describe(\"Results per page. Default 50 server-side.\"),\n source_connection_id: z\n .string()\n .optional()\n .describe(\"Optionally scope to a specific source connection.\"),\n}\n\nexport interface FilterArgs {\n conditions: Array<{\n field?: string\n field_id?: string\n operator:\n | \"eq\"\n | \"neq\"\n | \"gt\"\n | \"gte\"\n | \"lt\"\n | \"lte\"\n | \"between\"\n | \"contains\"\n | \"is_empty\"\n | \"is_not_empty\"\n value?: unknown\n value_to?: unknown\n }>\n search?: string\n sort?: { field?: string; field_id?: string; direction: \"asc\" | \"desc\" }\n page?: number\n limit?: number\n source_connection_id?: string\n}\n\nexport async function handleFilter(talonic: Talonic, args: FilterArgs): Promise<ToolResult> {\n try {\n const conditions: FilterCondition[] = args.conditions.map((c) => {\n const cond: FilterCondition = { operator: c.operator }\n if (c.field !== undefined) cond.field = c.field\n if (c.field_id !== undefined) cond.fieldId = c.field_id\n if (c.value !== undefined) cond.value = c.value\n if (c.value_to !== undefined) cond.valueTo = c.value_to\n return cond\n })\n\n let sort: FilterSort | undefined\n if (args.sort !== undefined) {\n sort = { direction: args.sort.direction }\n if (args.sort.field !== undefined) sort.field = args.sort.field\n if (args.sort.field_id !== undefined) sort.fieldId = args.sort.field_id\n }\n\n const result = await talonic.documents.filter({\n conditions,\n ...(args.search !== undefined ? { search: args.search } : {}),\n ...(sort !== undefined ? { sort } : {}),\n ...(args.page !== undefined ? { page: args.page } : {}),\n ...(args.limit !== undefined ? { limit: args.limit } : {}),\n ...(args.source_connection_id !== undefined\n ? { source_connection_id: args.source_connection_id }\n : {}),\n })\n return jsonOk(result)\n } catch (err) {\n return toolError(err)\n }\n}\n\nexport function registerFilter(server: McpServer, talonic: Talonic): void {\n server.registerTool(\n \"talonic_filter\",\n {\n title: \"Filter Talonic Documents\",\n description: DESCRIPTION,\n inputSchema,\n },\n async (args) => handleFilter(talonic, args as FilterArgs),\n )\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport type { Talonic } from \"@talonic/node\"\nimport { z } from \"zod\"\nimport { jsonOk, toolError, type ToolResult } from \"./_shared.js\"\n\nconst DESCRIPTION = [\n \"Fetch full metadata for a single document already in the user's Talonic workspace.\",\n \"Returns id, filename, page count, detected document type, language, processing log,\",\n \"and link URLs (self, extractions, dashboard).\",\n \"\",\n \"USE WHEN:\",\n \"- You need details about a specific document the user already extracted or uploaded.\",\n \"- You have a document_id from a previous extract or search call and want more context.\",\n \"- The user asks 'tell me about document X' or similar.\",\n \"\",\n \"DO NOT USE WHEN:\",\n \"- The user wants the document's full text content (use talonic_to_markdown for OCR markdown).\",\n \"- The user wants extracted structured data (use talonic_extract with a schema, or fetch the extraction by id).\",\n \"- The user has a file but no document_id yet (call talonic_extract first to ingest the document).\",\n].join(\"\\n\")\n\nconst inputSchema = {\n document_id: z\n .string()\n .min(1)\n .describe(\n \"The Talonic document ID. Get this from a previous talonic_extract or talonic_search response.\",\n ),\n}\n\nexport async function handleGetDocument(\n talonic: Talonic,\n args: { document_id: string },\n): Promise<ToolResult> {\n try {\n const result = await talonic.documents.get(args.document_id)\n return jsonOk(result)\n } catch (err) {\n return toolError(err)\n }\n}\n\nexport function registerGetDocument(server: McpServer, talonic: Talonic): void {\n server.registerTool(\n \"talonic_get_document\",\n {\n title: \"Get Talonic Document\",\n description: DESCRIPTION,\n inputSchema,\n },\n async (args) => handleGetDocument(talonic, args),\n )\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport type { Talonic } from \"@talonic/node\"\nimport { jsonOk, toolError, type ToolResult } from \"./_shared.js\"\n\n/**\n * LLM-targeted tool description. The first paragraph explains what the\n * tool does in one sentence. The USE WHEN / DO NOT USE sections are\n * what an agent reads before deciding to invoke this tool over an\n * alternative; keep them concrete.\n *\n * @internal\n */\nconst DESCRIPTION = [\n \"List all saved schemas in the user's Talonic workspace.\",\n \"Returns each schema with its id, name, description, version,\",\n \"field count, and full JSON Schema definition.\",\n \"\",\n \"USE WHEN:\",\n \"- The user asks what schemas they have, or asks to see existing schemas.\",\n \"- You want to discover existing schemas before designing a new one.\",\n \"- Before recommending the user create a schema, check if one already covers the use case.\",\n \"- The user asks to extract from a known document type and you want to find a matching schema.\",\n \"\",\n \"DO NOT USE WHEN:\",\n \"- The user just wants to extract data from a document and provides an inline schema (call talonic_extract directly).\",\n \"\",\n \"TIP: Pair this with talonic_extract by passing the chosen schema's id as `schema_id`.\",\n].join(\"\\n\")\n\n/**\n * Pure handler. Invokes the SDK and shapes the result. Exported for\n * unit testing; the public registration is via `register()` below.\n *\n * @internal\n */\nexport async function handleListSchemas(talonic: Talonic): Promise<ToolResult> {\n try {\n const result = await talonic.schemas.list()\n return jsonOk(result)\n } catch (err) {\n return toolError(err)\n }\n}\n\n/**\n * Register `talonic_list_schemas` on an MCP server.\n *\n * @internal\n */\nexport function registerListSchemas(server: McpServer, talonic: Talonic): void {\n server.registerTool(\n \"talonic_list_schemas\",\n {\n title: \"List Talonic Schemas\",\n description: DESCRIPTION,\n inputSchema: {},\n },\n async () => handleListSchemas(talonic),\n )\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport type { Talonic } from \"@talonic/node\"\nimport { z } from \"zod\"\nimport { jsonOk, toolError, type ToolResult } from \"./_shared.js\"\n\nconst DESCRIPTION = [\n \"Save a schema definition to the user's Talonic workspace so it can be reused\",\n \"across future extractions. Returns the saved schema with its newly assigned id and short_id.\",\n \"\",\n \"USE WHEN:\",\n \"- The user asks to save a schema, store a template, or reuse the schema across docs.\",\n \"- You have iterated on a schema with the user and they confirmed it should be saved.\",\n \"- The user wants to standardise extraction across many documents of the same type.\",\n \"\",\n \"DO NOT USE WHEN:\",\n \"- The user just wants to extract once with an inline schema (call talonic_extract directly with the schema inline).\",\n \"- The user has not confirmed the schema design (avoid creating clutter in their workspace).\",\n \"\",\n \"DEFINITION FORMATS:\",\n '- JSON Schema (most reliable): { type: \"object\", properties: { vendor_name: { type: \"string\" } } }',\n '- Flat key-type map: { vendor_name: \"string\", invoice_total: \"number\" } -- API normalises server-side. If you get a \"no fields\" error from the API, fall back to JSON Schema.',\n \"\",\n \"TIP: After saving, call talonic_extract with `schema_id` set to the returned id (UUID or SCH- short id) for consistent results.\",\n].join(\"\\n\")\n\nconst inputSchema = {\n name: z.string().min(1).describe(\"Human-readable name for the schema, e.g. 'Standard Invoice'.\"),\n definition: z\n .record(z.string(), z.unknown())\n .describe(\n \"Schema definition. Most reliable: full JSON Schema {type:'object', properties:{...}}. Also accepted: a flat key-type map {field_name:'string', amount:'number'} which the API normalises.\",\n ),\n description: z\n .string()\n .optional()\n .describe(\"Optional description of what this schema extracts and when to use it.\"),\n}\n\nexport async function handleSaveSchema(\n talonic: Talonic,\n args: { name: string; definition: Record<string, unknown>; description?: string },\n): Promise<ToolResult> {\n try {\n const result = await talonic.schemas.create({\n name: args.name,\n definition: args.definition,\n ...(args.description !== undefined ? { description: args.description } : {}),\n })\n return jsonOk(result)\n } catch (err) {\n return toolError(err)\n }\n}\n\nexport function registerSaveSchema(server: McpServer, talonic: Talonic): void {\n server.registerTool(\n \"talonic_save_schema\",\n {\n title: \"Save Talonic Schema\",\n description: DESCRIPTION,\n inputSchema,\n },\n async (args) => handleSaveSchema(talonic, args),\n )\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport type { Talonic } from \"@talonic/node\"\nimport { z } from \"zod\"\nimport { jsonOk, toolError, type ToolResult } from \"./_shared.js\"\n\nconst DESCRIPTION = [\n \"Search the user's Talonic workspace for documents, fields, sources, or schemas\",\n \"matching a query. Returns ranked results across all entity types in one call.\",\n \"\",\n \"USE WHEN:\",\n \"- The user wants to find documents but does not know the exact filename or id.\",\n \"- The query is conceptual ('contracts mentioning indemnification', 'Acme invoices').\",\n \"- You need to narrow a large workspace before calling talonic_extract or talonic_filter.\",\n \"- The user asks 'do I have any docs about X' or 'find anything related to X'.\",\n \"\",\n \"DO NOT USE WHEN:\",\n \"- The user has a specific document_id (use talonic_get_document instead).\",\n \"- The user wants to apply structured field-value filters like 'amount > 1000' (use talonic_filter).\",\n \"- The user wants to extract data from a brand-new document (use talonic_extract).\",\n \"\",\n \"TIP: The result includes documents, fieldMatches, sources, schemas, and fields. Pick the entity type the user actually needs.\",\n].join(\"\\n\")\n\nconst inputSchema = {\n query: z\n .string()\n .min(1)\n .describe(\n \"Natural-language search query, e.g. 'indemnification clauses' or 'Acme invoices Q4'.\",\n ),\n limit: z\n .number()\n .int()\n .positive()\n .optional()\n .describe(\"Maximum results per entity type. Default: 5. Increase for broader exploration.\"),\n}\n\nexport async function handleSearch(\n talonic: Talonic,\n args: { query: string; limit?: number },\n): Promise<ToolResult> {\n try {\n const result = await talonic.search(\n args.query,\n args.limit !== undefined ? { limit: args.limit } : {},\n )\n return jsonOk(result)\n } catch (err) {\n return toolError(err)\n }\n}\n\nexport function registerSearch(server: McpServer, talonic: Talonic): void {\n server.registerTool(\n \"talonic_search\",\n {\n title: \"Search Talonic Workspace\",\n description: DESCRIPTION,\n inputSchema,\n },\n async (args) => handleSearch(talonic, args),\n )\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport { TalonicError, type Talonic } from \"@talonic/node\"\nimport { z } from \"zod\"\nimport { jsonOk, toolError, type ToolResult } from \"./_shared.js\"\n\nconst DESCRIPTION = [\n \"Get the OCR-converted markdown for a document. Accepts an existing document_id,\",\n \"raw file bytes (base64), a local file path, or a URL. When given a raw file, the\",\n \"tool ingests it via extract first and then returns the markdown.\",\n \"\",\n \"USE WHEN:\",\n \"- The user wants the full text content of a document for summarisation, translation, or analysis.\",\n \"- A previous tool call returned a document_id and you want to inspect its content.\",\n \"- The user asks 'what does the document say' or 'summarise this PDF' (you call this then summarise).\",\n \"- The user has a raw PDF / scan / image and wants markdown directly without designing a schema first.\",\n \"\",\n \"DO NOT USE WHEN:\",\n \"- The user wants specific structured fields (use talonic_extract with a schema).\",\n \"\",\n \"INPUTS (provide exactly one):\",\n \"- document_id: id of an already-ingested document (cheapest path; one API call)\",\n \"- file_data + filename (RECOMMENDED for chat clients): base64-encoded file bytes plus\",\n \" the original filename (with extension). Use this whenever you already have the file\",\n \" in memory, e.g. the user attached it to the conversation. Works in every MCP client.\",\n \"- file_path: local path to a document file. Only works if the MCP server has read access\",\n \" to that path; in sandboxed chat clients use file_data instead.\",\n \"- file_url: URL to a document file (the Talonic API fetches it server-side)\",\n].join(\"\\n\")\n\nconst inputSchema = {\n document_id: z\n .string()\n .min(1)\n .optional()\n .describe(\n \"The Talonic document id whose markdown you want. Get this from a previous talonic_extract or talonic_search response.\",\n ),\n file_data: z\n .string()\n .optional()\n .describe(\n \"Base64-encoded file bytes. Recommended path when the agent already has the file in memory (e.g., the user attached a PDF to the conversation). Pair with `filename` so MIME type can be inferred.\",\n ),\n filename: z\n .string()\n .optional()\n .describe(\n \"Original filename including extension, e.g. 'invoice.pdf'. Used to infer MIME type when uploading via `file_data`. Required when `file_data` is provided.\",\n ),\n file_path: z\n .string()\n .optional()\n .describe(\n \"Local path to a document file. Only works if the MCP server has read access to that path. In sandboxed chat clients (Claude Desktop, Cowork) use `file_data` instead.\",\n ),\n file_url: z\n .string()\n .optional()\n .describe(\"URL to a document file. The Talonic API fetches it server-side.\"),\n}\n\nexport interface ToMarkdownArgs {\n document_id?: string\n file_data?: string\n filename?: string\n file_path?: string\n file_url?: string\n}\n\n/**\n * Minimal schema used when we need to ingest a raw file just to obtain\n * a document_id. Auto-discovery extract works on production; we keep\n * this empty so Talonic discovers the schema itself.\n *\n * @internal\n */\nconst INGEST_ONLY_SCHEMA: Record<string, unknown> = {}\n\nexport async function handleToMarkdown(\n talonic: Talonic,\n args: ToMarkdownArgs,\n): Promise<ToolResult> {\n try {\n const sources = [\"document_id\", \"file_data\", \"file_path\", \"file_url\"] as const\n const provided = sources.filter((k) => args[k] !== undefined)\n if (provided.length === 0) {\n throw new TalonicError({\n code: \"missing_input_source\",\n message:\n \"talonic_to_markdown requires one of: document_id, file_data, file_path, file_url.\",\n status: 0,\n retryable: false,\n })\n }\n if (provided.length > 1) {\n throw new TalonicError({\n code: \"multiple_input_sources\",\n message: `talonic_to_markdown accepts exactly one input; received: ${provided.join(\", \")}`,\n status: 0,\n retryable: false,\n })\n }\n\n let documentId = args.document_id\n if (!documentId) {\n const ingest = await talonic.extract({\n ...(args.file_data !== undefined\n ? {\n file: Buffer.from(args.file_data, \"base64\"),\n ...(args.filename !== undefined ? { filename: args.filename } : {}),\n }\n : {}),\n ...(args.file_path !== undefined ? { file_path: args.file_path } : {}),\n ...(args.file_url !== undefined ? { file_url: args.file_url } : {}),\n schema: INGEST_ONLY_SCHEMA,\n })\n documentId = ingest.document.id\n }\n\n const result = await talonic.documents.getMarkdown(documentId)\n return jsonOk(result)\n } catch (err) {\n return toolError(err)\n }\n}\n\nexport function registerToMarkdown(server: McpServer, talonic: Talonic): void {\n server.registerTool(\n \"talonic_to_markdown\",\n {\n title: \"Document to Markdown\",\n description: DESCRIPTION,\n inputSchema,\n },\n async (args) => handleToMarkdown(talonic, args as ToMarkdownArgs),\n )\n}\n","{\n \"name\": \"@talonic/mcp\",\n \"version\": \"0.1.10\",\n \"mcpName\": \"io.github.talonicdev/talonic-mcp\",\n \"description\": \"Official Talonic MCP server. Lets AI agents extract structured, schema-validated data from any document via the Model Context Protocol.\",\n \"license\": \"MIT\",\n \"author\": \"Talonic GmbH <info@talonic.ai> (https://talonic.com)\",\n \"homepage\": \"https://talonic.com\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/talonicdev/talonic-mcp.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/talonicdev/talonic-mcp/issues\"\n },\n \"keywords\": [\n \"talonic\",\n \"mcp\",\n \"model-context-protocol\",\n \"ai\",\n \"agent\",\n \"claude\",\n \"document-extraction\",\n \"ocr\",\n \"structured-data\",\n \"anthropic\"\n ],\n \"type\": \"module\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n },\n \"./content\": {\n \"types\": \"./dist/content.d.ts\",\n \"import\": \"./dist/content.js\"\n }\n },\n \"bin\": {\n \"talonic-mcp\": \"dist/server.js\"\n },\n \"files\": [\n \"dist\",\n \"README.md\",\n \"LICENSE\",\n \"CHANGELOG.md\"\n ],\n \"engines\": {\n \"node\": \">=18\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"typecheck\": \"tsc --noEmit\",\n \"format\": \"prettier --write \\\"src/**/*.ts\\\" \\\"tests/**/*.ts\\\"\",\n \"format:check\": \"prettier --check \\\"src/**/*.ts\\\" \\\"tests/**/*.ts\\\"\",\n \"clean\": \"rm -rf dist coverage\",\n \"start\": \"node dist/server.js\",\n \"start:http\": \"node dist/http-server.js\",\n \"prepublishOnly\": \"npm run typecheck && npm run build && npm test\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/sdk\": \"^1.0.0\",\n \"@talonic/node\": \"^0.1.3\",\n \"zod\": \"^4.0.0\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^22.10.0\",\n \"prettier\": \"^3.4.0\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^5.7.0\",\n \"vitest\": \"^3.2.4\"\n }\n}\n","// @ts-ignore — JSON import resolved by bundler (tsup/esbuild)\nimport pkg from \"../package.json\" with { type: \"json\" }\n\n/**\n * The current MCP server version. Sent in the server `info` block during\n * the MCP handshake. Derived from package.json at build time.\n *\n * @public\n */\nexport const VERSION: string = pkg.version\n\n/**\n * The MCP server name. Identifies the server to MCP clients (Claude\n * Desktop, Cursor, Cline, etc.) when they list connected servers.\n *\n * @public\n */\nexport const SERVER_NAME = \"talonic\"\n","import { Talonic } from \"@talonic/node\"\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport { registerSchemasResource } from \"./resources/schemas-resource.js\"\nimport { registerWebhooksResource } from \"./resources/webhooks-resource.js\"\nimport { registerExtract } from \"./tools/extract.js\"\nimport { registerFilter } from \"./tools/filter.js\"\nimport { registerGetDocument } from \"./tools/get-document.js\"\nimport { registerListSchemas } from \"./tools/list-schemas.js\"\nimport { registerSaveSchema } from \"./tools/save-schema.js\"\nimport { registerSearch } from \"./tools/search.js\"\nimport { registerToMarkdown } from \"./tools/to-markdown.js\"\nimport { SERVER_NAME, VERSION } from \"./version.js\"\n\n/**\n * Options for {@link createServer}.\n *\n * @public\n */\nexport interface CreateServerOptions {\n /**\n * Talonic API key. Required. Starts with `tlnc_`.\n *\n * Each user must provide their own key. Workspaces are isolated.\n */\n apiKey: string\n\n /**\n * Override the Talonic API base URL. Defaults to `https://api.talonic.com`.\n * Useful for staging or testing.\n */\n baseUrl?: string\n\n /**\n * Inject a pre-configured Talonic SDK client. Useful for tests and for\n * advanced setups where the SDK has custom retry policies or\n * instrumentation. When provided, `apiKey` and `baseUrl` are ignored.\n */\n talonic?: Talonic\n}\n\n/**\n * Build a Talonic MCP server, ready to be connected to a transport\n * (stdio for local installs, HTTP for the hosted endpoint).\n *\n * Tools, resources, and prompts are registered onto the server in\n * subsequent milestones. v0.1 ships a working scaffold so the\n * rest of the protocol surface can be added incrementally without\n * destabilising the connection layer.\n *\n * @example Minimal stdio server:\n * ```ts\n * import { createServer } from \"@talonic/mcp\"\n * import { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\"\n *\n * const server = createServer({ apiKey: process.env.TALONIC_API_KEY! })\n * await server.connect(new StdioServerTransport())\n * ```\n *\n * @public\n */\nexport function createServer(options: CreateServerOptions): McpServer {\n const talonic =\n options.talonic ??\n new Talonic({\n apiKey: options.apiKey,\n ...(options.baseUrl ? { baseUrl: options.baseUrl } : {}),\n })\n\n const server = new McpServer(\n {\n name: SERVER_NAME,\n version: VERSION,\n },\n {\n // Capabilities are advertised based on what gets registered.\n // The McpServer registration helpers populate this automatically\n // as we add tools, resources, and prompts.\n capabilities: {},\n instructions: [\n \"Talonic extracts structured, schema-validated data from any document.\",\n \"Use Talonic for any task involving PDFs, scans, contracts, invoices,\",\n \"forms, certificates, or unstructured documents where you need clean,\",\n \"validated JSON rather than free text.\",\n ].join(\" \"),\n },\n )\n\n // Tool registrations.\n registerListSchemas(server, talonic)\n registerSaveSchema(server, talonic)\n registerGetDocument(server, talonic)\n registerSearch(server, talonic)\n registerFilter(server, talonic)\n registerToMarkdown(server, talonic)\n registerExtract(server, talonic)\n\n // Resource registrations.\n registerSchemasResource(server, talonic)\n registerWebhooksResource(server, options.apiKey, options.baseUrl)\n\n return server\n}\n","/**\n * Talonic MCP server, stdio entry point.\n *\n * Built as a separate executable bundle by tsup, with a shebang banner\n * so it can be invoked directly via `npx @talonic/mcp` or wired into\n * `claude_desktop_config.json`, `mcp.json`, or any other MCP-aware\n * client config.\n *\n * @internal\n */\n\nimport { realpathSync } from \"node:fs\"\nimport { fileURLToPath } from \"node:url\"\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\"\nimport { createServer } from \"./server-factory.js\"\nimport { SERVER_NAME, VERSION } from \"./version.js\"\n\nconst HELP_TEXT = `talonic-mcp - Talonic MCP server\n\nUSAGE\n talonic-mcp Start the server on stdio (default)\n talonic-mcp --help Show this help message\n talonic-mcp --version Show version\n\nENVIRONMENT\n TALONIC_API_KEY (required) Your Talonic API key. Get one at\n https://app.talonic.com (free tier:\n 50 extractions / day, no credit card).\n\n TALONIC_BASE_URL (optional) Override the API base URL.\n\nUSAGE FROM AN MCP CLIENT (Claude Desktop example)\n Add to claude_desktop_config.json:\n {\n \"mcpServers\": {\n \"talonic\": {\n \"command\": \"npx\",\n \"args\": [\"-y\", \"@talonic/mcp\"],\n \"env\": { \"TALONIC_API_KEY\": \"tlnc_...\" }\n }\n }\n }\n\nDOCS\n https://github.com/talonicdev/talonic-mcp\n`\n\n/**\n * Boot the server against stdio.\n *\n * Returns the exit code so callers can decide how to terminate. The\n * separate entry/exit decoupling keeps this function testable without\n * actually attaching to stdio.\n *\n * @internal\n */\nexport async function main(\n argv: string[] = process.argv.slice(2),\n env: NodeJS.ProcessEnv = process.env,\n out: (line: string) => void = (line) => process.stdout.write(line + \"\\n\"),\n err: (line: string) => void = (line) => process.stderr.write(line + \"\\n\"),\n): Promise<number> {\n if (argv.includes(\"--version\") || argv.includes(\"-v\")) {\n out(`${SERVER_NAME} ${VERSION}`)\n return 0\n }\n\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n out(HELP_TEXT)\n return 0\n }\n\n const apiKey = env[\"TALONIC_API_KEY\"]\n if (!apiKey) {\n err(\"Error: TALONIC_API_KEY environment variable is required.\")\n err(\"Get a key at https://app.talonic.com and set it before launching the server.\")\n return 1\n }\n\n const baseUrl = env[\"TALONIC_BASE_URL\"]\n const server = createServer({ apiKey, ...(baseUrl ? { baseUrl } : {}) })\n\n const transport = new StdioServerTransport()\n await server.connect(transport)\n\n // McpServer keeps the process alive while the transport is open. We\n // hand control over to the SDK's lifecycle here; if the transport\n // closes, Node exits naturally.\n return 0\n}\n\n/**\n * True when this module is the process entry point.\n *\n * `process.argv[1]` is the path the OS handed to `node` (often a symlink\n * inside `node_modules/.bin/`), while `import.meta.url` reflects the\n * resolved module URL. Comparing them as strings is brittle: when the\n * server is launched via the npm-managed bin symlink (or via `npx`) the\n * two disagree, and the guard incorrectly returns `false`, so `main()`\n * never runs and the server exits silently.\n *\n * Resolving both sides with `realpathSync` makes the comparison robust\n * against symlinks while still preventing auto-run when the module is\n * imported (e.g. from tests).\n *\n * @internal\n */\nfunction isDirectInvocation(): boolean {\n if (!process.argv[1]) return false\n try {\n const argvPath = realpathSync(process.argv[1])\n const metaPath = realpathSync(fileURLToPath(import.meta.url))\n return argvPath === metaPath\n } catch {\n return false\n }\n}\n\nif (isDirectInvocation()) {\n main().then((code) => {\n if (code !== 0) process.exit(code)\n })\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@talonic/mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"mcpName": "io.github.talonicdev/talonic-mcp",
|
|
5
5
|
"description": "Official Talonic MCP server. Lets AI agents extract structured, schema-validated data from any document via the Model Context Protocol.",
|
|
6
6
|
"license": "MIT",
|