@talonic/mcp 0.1.10 → 0.1.11

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.
@@ -36,9 +36,21 @@ function registerSchemasResource(server, talonic) {
36
36
  // src/resources/webhooks-resource.ts
37
37
  var WEBHOOK_INFO_ENDPOINTS = [
38
38
  { path: "/v1/webhooks/events", key: "events", description: "Available webhook event types" },
39
- { path: "/v1/webhooks/delivery", key: "delivery", description: "Delivery behavior and retry policy" },
40
- { path: "/v1/webhooks/signatures", key: "signatures", description: "Signature verification algorithms" },
41
- { path: "/v1/webhooks/retries", key: "retries", description: "Retry schedule and backoff policy" }
39
+ {
40
+ path: "/v1/webhooks/delivery",
41
+ key: "delivery",
42
+ description: "Delivery behavior and retry policy"
43
+ },
44
+ {
45
+ path: "/v1/webhooks/signatures",
46
+ key: "signatures",
47
+ description: "Signature verification algorithms"
48
+ },
49
+ {
50
+ path: "/v1/webhooks/retries",
51
+ key: "retries",
52
+ description: "Retry schedule and backoff policy"
53
+ }
42
54
  ];
43
55
  function registerWebhooksResource(server, apiKey, baseUrl) {
44
56
  const base = baseUrl ?? "https://api.talonic.com";
@@ -64,10 +76,16 @@ function registerWebhooksResource(server, apiKey, baseUrl) {
64
76
  if (res.ok) {
65
77
  results[key] = await res.json();
66
78
  } else {
67
- results[key] = { error: `HTTP ${res.status}`, message: await res.text().catch(() => "") };
79
+ results[key] = {
80
+ error: `HTTP ${res.status}`,
81
+ message: await res.text().catch(() => "")
82
+ };
68
83
  }
69
84
  } catch (err) {
70
- results[key] = { error: "fetch_failed", message: err instanceof Error ? err.message : String(err) };
85
+ results[key] = {
86
+ error: "fetch_failed",
87
+ message: err instanceof Error ? err.message : String(err)
88
+ };
71
89
  }
72
90
  })
73
91
  );
@@ -93,6 +111,12 @@ function jsonOk(value) {
93
111
  ]
94
112
  };
95
113
  }
114
+ function validationError(message) {
115
+ return {
116
+ isError: true,
117
+ content: [{ type: "text", text: `Validation error: ${message}` }]
118
+ };
119
+ }
96
120
  function toolError(err) {
97
121
  if (err instanceof TalonicError) {
98
122
  const lines = [
@@ -119,6 +143,8 @@ function toolError(err) {
119
143
 
120
144
  // src/tools/extract.ts
121
145
  var DESCRIPTION = [
146
+ "STATUS: stable. Production-safe when called with a schema. Schema-less extraction is disabled at the MCP layer.",
147
+ "",
122
148
  "Extract structured, schema-validated data from a document using Talonic.",
123
149
  "Returns clean JSON matching the schema, with per-field confidence scores and",
124
150
  "metadata about the document (detected type, language, page count).",
@@ -146,13 +172,24 @@ var DESCRIPTION = [
146
172
  " the public web.",
147
173
  "- document_id: re-extract a document already in the workspace.",
148
174
  "",
149
- "SCHEMA FORMATS (provide at most one of `schema` or `schema_id`):",
150
- '- JSON Schema (most reliable): { type: "object", properties: { vendor_name: { type: "string" } } }',
151
- '- 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.',
152
- "- schema_id: id of a saved schema from talonic_list_schemas. Accepts the UUID or the SCH-XXXXXXXX short id.",
175
+ "SCHEMA (REQUIRED, provide exactly one of `schema` or `schema_id`):",
176
+ '- JSON Schema (RECOMMENDED): { type: "object", properties: { vendor_name: { type: "string" } } }.',
177
+ '- Flat key-type map: { vendor_name: "string", invoice_total: "number" }. Accepted, but if you get a "no fields" error, fall back to JSON Schema.',
178
+ "- schema_id: id of a saved schema from talonic_list_schemas. Accepts UUID or SCH-XXXXXXXX short id.",
153
179
  "",
154
- "IMPORTANT: production currently rejects requests with no schema. Always provide either",
155
- "an inline `schema` or a `schema_id`."
180
+ "Calls without `schema` or `schema_id` are rejected with a validation error before they hit the API,",
181
+ "to prevent unreliable schema-free extractions reaching production.",
182
+ "",
183
+ "RESPONSE SHAPE (key fields):",
184
+ "- data: the structured extracted JSON, shaped by your schema.",
185
+ "- confidence.overall: 0..1 confidence for the extraction as a whole.",
186
+ "- confidence.fields: per-field confidence map. Treat fields below ~0.7 as needing human review.",
187
+ "- document.id, document.filename, document.pages, document.type_detected, document.language_detected.",
188
+ "- extraction_id, request_id: stable identifiers for support and re-fetch.",
189
+ "- processing.duration_ms, processing.region: useful for debugging and capacity planning.",
190
+ "- markdown: present only when `include_markdown: true`.",
191
+ "Cost, EUR price, and remaining credit balance are not surfaced in v0.1 and may appear in a later version.",
192
+ "Per-field source provenance (page, bounding box) is not surfaced in v0.1."
156
193
  ].join("\n");
157
194
  var inputSchema = {
158
195
  file_data: z.string().optional().describe(
@@ -169,10 +206,10 @@ var inputSchema = {
169
206
  ),
170
207
  document_id: z.string().optional().describe("ID of a document already in the workspace, to re-extract with a new schema."),
171
208
  schema: z.record(z.string(), z.unknown()).optional().describe(
172
- "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`."
209
+ "Inline schema definition. REQUIRED unless `schema_id` is provided. Recommended: full JSON Schema {type:'object', properties:{...}}. Also accepted: flat key-type map {field_name:'string', amount:'number'}. Mutually exclusive with `schema_id`."
173
210
  ),
174
211
  schema_id: z.string().optional().describe(
175
- "ID of a saved schema. Accepts UUID or SCH-XXXXXXXX short id. Mutually exclusive with `schema`."
212
+ "ID of a saved schema. REQUIRED unless `schema` is provided. Accepts UUID or SCH-XXXXXXXX short id from talonic_list_schemas. Mutually exclusive with `schema`."
176
213
  ),
177
214
  instructions: z.string().optional().describe(
178
215
  "Natural-language guidance for the extractor, e.g. 'Focus on the billing section. Amounts are in EUR.'"
@@ -180,6 +217,14 @@ var inputSchema = {
180
217
  include_markdown: z.boolean().optional().describe("Include OCR-converted markdown in the response alongside structured data.")
181
218
  };
182
219
  async function handleExtract(talonic, args) {
220
+ if (args.schema === void 0 && args.schema_id === void 0) {
221
+ return validationError(
222
+ "talonic_extract requires a schema. Provide either an inline `schema` (JSON Schema or flat key-type map) or a `schema_id` from talonic_list_schemas. Schema-less extraction is unreliable in v0.1 and is disabled at the MCP layer."
223
+ );
224
+ }
225
+ if (args.schema !== void 0 && args.schema_id !== void 0) {
226
+ return validationError("talonic_extract accepts `schema` OR `schema_id`, not both. Pick one.");
227
+ }
183
228
  try {
184
229
  const params = {};
185
230
  if (args.file_data !== void 0) {
@@ -211,6 +256,8 @@ function registerExtract(server, talonic) {
211
256
  );
212
257
  }
213
258
  var DESCRIPTION2 = [
259
+ "STATUS: stable. Field-name resolution is server-side. The `is_not_empty` operator is intentionally not exposed in v0.1; see workaround below.",
260
+ "",
214
261
  "Filter the user's Talonic documents by extracted field values using composable conditions.",
215
262
  "Conditions accept either a canonical field name (e.g. 'vendor.name', 'policy.0_coverage_type')",
216
263
  "or a field UUID. The Talonic API resolves names to ids server-side.",
@@ -227,13 +274,14 @@ var DESCRIPTION2 = [
227
274
  "- The user wants extracted data from a new document (use talonic_extract).",
228
275
  "",
229
276
  "OPERATORS:",
230
- "- eq, neq: equality / inequality",
231
- "- gt, gte, lt, lte: numeric or date comparisons",
232
- "- between: requires both `value` and `value_to`",
233
- "- contains: substring match on string fields",
234
- "- is_empty: presence check (no value needed)",
235
- "- is_not_empty: presence check (no value needed). Note: currently underreports;",
236
- " use `eq` / `gt` / `contains` etc. against a known value when possible.",
277
+ "- eq, neq: equality / inequality.",
278
+ "- gt, gte, lt, lte: numeric or date comparisons.",
279
+ "- between: requires both `value` and `value_to`.",
280
+ "- contains: substring match on string fields.",
281
+ "- is_empty: presence check, no value needed. Returns documents where the field is null or missing.",
282
+ "",
283
+ "NOT SUPPORTED IN v0.1:",
284
+ "- is_not_empty: underreports against fields known to be populated. Removed from the supported operator list to keep filter results trustworthy. Workaround: filter with `eq`/`gt`/`contains` against a known value, or use `is_empty` then invert the result client-side. Tracked for a later release.",
237
285
  "",
238
286
  "TIPS:",
239
287
  "- To discover available field names, call talonic_search first with a related query.",
@@ -249,8 +297,9 @@ var operatorEnum = z.enum([
249
297
  "lte",
250
298
  "between",
251
299
  "contains",
252
- "is_empty",
253
- "is_not_empty"
300
+ "is_empty"
301
+ // is_not_empty intentionally omitted in v0.1: it underreports against
302
+ // fields known to be populated. See description for the workaround.
254
303
  ]);
255
304
  var conditionSchema = z.object({
256
305
  field: z.string().optional().describe(
@@ -315,6 +364,8 @@ function registerFilter(server, talonic) {
315
364
  );
316
365
  }
317
366
  var DESCRIPTION3 = [
367
+ "STATUS: stable.",
368
+ "",
318
369
  "Fetch full metadata for a single document already in the user's Talonic workspace.",
319
370
  "Returns id, filename, page count, detected document type, language, processing log,",
320
371
  "and link URLs (self, extractions, dashboard).",
@@ -356,9 +407,12 @@ function registerGetDocument(server, talonic) {
356
407
 
357
408
  // src/tools/list-schemas.ts
358
409
  var DESCRIPTION4 = [
410
+ "STATUS: stable.",
411
+ "",
359
412
  "List all saved schemas in the user's Talonic workspace.",
360
- "Returns each schema with its id, name, description, version,",
361
- "field count, and full JSON Schema definition.",
413
+ "Returns each schema with its id (UUID), short_id (SCH-XXXXXXXX), name, description,",
414
+ "version, field count, and full JSON Schema definition. Either id form is accepted by",
415
+ "talonic_extract's `schema_id` parameter.",
362
416
  "",
363
417
  "USE WHEN:",
364
418
  "- The user asks what schemas they have, or asks to see existing schemas.",
@@ -391,6 +445,8 @@ function registerListSchemas(server, talonic) {
391
445
  );
392
446
  }
393
447
  var DESCRIPTION5 = [
448
+ "STATUS: stable.",
449
+ "",
394
450
  "Save a schema definition to the user's Talonic workspace so it can be reused",
395
451
  "across future extractions. Returns the saved schema with its newly assigned id and short_id.",
396
452
  "",
@@ -440,6 +496,8 @@ function registerSaveSchema(server, talonic) {
440
496
  );
441
497
  }
442
498
  var DESCRIPTION6 = [
499
+ "STATUS: stable.",
500
+ "",
443
501
  "Search the user's Talonic workspace for documents, fields, sources, or schemas",
444
502
  "matching a query. Returns ranked results across all entity types in one call.",
445
503
  "",
@@ -485,6 +543,8 @@ function registerSearch(server, talonic) {
485
543
  );
486
544
  }
487
545
  var DESCRIPTION7 = [
546
+ "STATUS: stable.",
547
+ "",
488
548
  "Get the OCR-converted markdown for a document. Accepts an existing document_id,",
489
549
  "raw file bytes (base64), a local file path, or a URL. When given a raw file, the",
490
550
  "tool ingests it via extract first and then returns the markdown.",
@@ -522,7 +582,12 @@ var inputSchema6 = {
522
582
  ),
523
583
  file_url: z.string().optional().describe("URL to a document file. The Talonic API fetches it server-side.")
524
584
  };
525
- var INGEST_ONLY_SCHEMA = {};
585
+ var INGEST_ONLY_SCHEMA = {
586
+ type: "object",
587
+ properties: {
588
+ document_title: { type: "string" }
589
+ }
590
+ };
526
591
  async function handleToMarkdown(talonic, args) {
527
592
  try {
528
593
  const sources = ["document_id", "file_data", "file_path", "file_url"];
@@ -576,7 +641,7 @@ function registerToMarkdown(server, talonic) {
576
641
 
577
642
  // package.json
578
643
  var package_default = {
579
- version: "0.1.10"};
644
+ version: "0.1.11"};
580
645
 
581
646
  // src/version.ts
582
647
  var VERSION = package_default.version;
@@ -643,15 +708,17 @@ var httpServer = createServer$1(async (req, res) => {
643
708
  }
644
709
  if (path === "/") {
645
710
  res.writeHead(200, { "Content-Type": "application/json" });
646
- res.end(JSON.stringify({
647
- name: SERVER_NAME,
648
- version: VERSION,
649
- description: "Talonic MCP server \u2014 extract structured, schema-validated data from any document.",
650
- mcp_endpoint: "/mcp",
651
- health_endpoint: "/health",
652
- auth: "Provide a Talonic API key via Authorization: Bearer tlnc_... header or ?apiKey=tlnc_... query param.",
653
- docs: "https://docs.talonic.com"
654
- }));
711
+ res.end(
712
+ JSON.stringify({
713
+ name: SERVER_NAME,
714
+ version: VERSION,
715
+ description: "Talonic MCP server \u2014 extract structured, schema-validated data from any document.",
716
+ mcp_endpoint: "/mcp",
717
+ health_endpoint: "/health",
718
+ auth: "Provide a Talonic API key via Authorization: Bearer tlnc_... header or ?apiKey=tlnc_... query param.",
719
+ docs: "https://docs.talonic.com"
720
+ })
721
+ );
655
722
  return;
656
723
  }
657
724
  res.setHeader("Access-Control-Allow-Origin", "*");
@@ -665,7 +732,12 @@ var httpServer = createServer$1(async (req, res) => {
665
732
  }
666
733
  if (path !== "/mcp") {
667
734
  res.writeHead(404, { "Content-Type": "application/json" });
668
- res.end(JSON.stringify({ error: "not_found", message: `No route for ${path}. Use /mcp for the MCP endpoint or /health for status.` }));
735
+ res.end(
736
+ JSON.stringify({
737
+ error: "not_found",
738
+ message: `No route for ${path}. Use /mcp for the MCP endpoint or /health for status.`
739
+ })
740
+ );
669
741
  return;
670
742
  }
671
743
  if (req.method === "DELETE") {
@@ -682,7 +754,12 @@ var httpServer = createServer$1(async (req, res) => {
682
754
  const apiKey = extractApiKey(req);
683
755
  if (!apiKey) {
684
756
  res.writeHead(401, { "Content-Type": "application/json" });
685
- res.end(JSON.stringify({ error: "unauthorized", message: "Provide a Talonic API key via Authorization: Bearer tlnc_... header or ?apiKey=tlnc_... query param." }));
757
+ res.end(
758
+ JSON.stringify({
759
+ error: "unauthorized",
760
+ message: "Provide a Talonic API key via Authorization: Bearer tlnc_... header or ?apiKey=tlnc_... query param."
761
+ })
762
+ );
686
763
  return;
687
764
  }
688
765
  const sessionId = req.headers["mcp-session-id"];
@@ -708,7 +785,12 @@ var httpServer = createServer$1(async (req, res) => {
708
785
  }
709
786
  if (sessionId && !isInitializeRequest(parsed)) {
710
787
  res.writeHead(404, { "Content-Type": "application/json" });
711
- res.end(JSON.stringify({ error: "session_not_found", message: "Unknown session. Re-initialize without the Mcp-Session-Id header." }));
788
+ res.end(
789
+ JSON.stringify({
790
+ error: "session_not_found",
791
+ message: "Unknown session. Re-initialize without the Mcp-Session-Id header."
792
+ })
793
+ );
712
794
  return;
713
795
  }
714
796
  const transport = new StreamableHTTPServerTransport({