@talonic/mcp 0.1.15 → 0.1.17

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/dist/index.js CHANGED
@@ -98,7 +98,7 @@ function registerWebhooksResource(server, apiKey, baseUrl) {
98
98
  );
99
99
  }
100
100
  function jsonOk(value) {
101
- return {
101
+ const result = {
102
102
  content: [
103
103
  {
104
104
  type: "text",
@@ -106,6 +106,10 @@ function jsonOk(value) {
106
106
  }
107
107
  ]
108
108
  };
109
+ if (value !== null && typeof value === "object" && !Array.isArray(value)) {
110
+ result["structuredContent"] = value;
111
+ }
112
+ return result;
109
113
  }
110
114
  function validationError(message) {
111
115
  return {
@@ -155,18 +159,22 @@ var DESCRIPTION = [
155
159
  "- The user just wants the full text content (use talonic_to_markdown after extracting once).",
156
160
  "- The user wants to find documents matching a query (use talonic_search or talonic_filter).",
157
161
  "",
158
- "FILE SOURCES (provide exactly one):",
159
- "- file_data + filename (RECOMMENDED for chat clients): base64-encoded file bytes plus",
160
- " the original filename (with extension). Use this whenever you already have the file",
161
- " in memory, e.g. the user attached it to the conversation. Works in every MCP client",
162
- " regardless of where the file lives on disk.",
163
- "- file_path: a local path to the document. Only works if the MCP server process can",
164
- " read that path on its own filesystem; many chat clients (Claude Desktop, Cowork)",
165
- " store user uploads in a sandbox the MCP server cannot access, in which case use",
166
- " file_data instead.",
167
- "- file_url: a URL the Talonic API will fetch directly. Use for documents already on",
168
- " the public web.",
169
- "- document_id: re-extract a document already in the workspace.",
162
+ "FILE SOURCES (provide exactly EXACTLY ONE; never combine, e.g. do NOT pass both file_data and file_path):",
163
+ "- file_data + filename: base64-encoded file bytes plus the original filename (with extension).",
164
+ " RECOMMENDED for local-stdio installs (Claude Desktop, Cursor, Cline, Continue, Cowork).",
165
+ " WARNING for hosted-MCP via Claude.ai connectors: Claude.ai imposes a hard size limit on",
166
+ " tool-call arguments (effectively under ~1KB), so file_data CANNOT carry a real PDF through",
167
+ " Claude.ai's pipeline. The bytes get truncated before reaching the MCP server. For files",
168
+ " larger than a trivial test, use file_url or document_id instead when running through",
169
+ " Claude.ai. Local stdio installs do NOT have this limit.",
170
+ "- file_path: a local path to the document. Only works if the MCP server process can read",
171
+ " that path on its own filesystem. Chat clients (Claude Desktop, Claude.ai, Cowork) store",
172
+ " user uploads in a sandbox the MCP server cannot access, so file_path is only useful when",
173
+ " the agent explicitly knows a path on the same machine as the MCP server.",
174
+ "- file_url: a URL the Talonic API will fetch directly. Use for documents already on the",
175
+ " public web. Best path for Claude.ai users dealing with files larger than the parameter cap.",
176
+ "- document_id: re-extract a document already in the workspace. Cheapest option when the",
177
+ " document is already uploaded via app.talonic.com or a previous extract call.",
170
178
  "",
171
179
  "SCHEMA (REQUIRED, provide exactly one of `schema` or `schema_id`):",
172
180
  '- JSON Schema (RECOMMENDED): { type: "object", properties: { vendor_name: { type: "string" } } }.',
@@ -216,6 +224,52 @@ var inputSchema = {
216
224
  "Include per-field provenance (source_text, section, page) showing where each value was found in the document."
217
225
  )
218
226
  };
227
+ var outputSchema = {
228
+ extraction_id: z.string().describe("Stable identifier for this extraction."),
229
+ request_id: z.string().optional().describe("Server-assigned request ID for support and debugging."),
230
+ status: z.string().describe("Extraction status (e.g. 'complete')."),
231
+ document: z.object({
232
+ id: z.string(),
233
+ filename: z.string(),
234
+ pages: z.number().optional(),
235
+ size_bytes: z.number().optional(),
236
+ mime_type: z.string().optional(),
237
+ type_detected: z.string().nullable().optional(),
238
+ language_detected: z.string().nullable().optional()
239
+ }).describe("Metadata about the ingested document."),
240
+ data: z.record(z.string(), z.unknown()).describe("The extracted structured data, shape determined by the schema."),
241
+ schema: z.object({
242
+ source: z.string().optional(),
243
+ id: z.string().nullable().optional(),
244
+ definition: z.record(z.string(), z.unknown()).optional(),
245
+ save_url: z.string().optional()
246
+ }).optional().describe("Schema metadata: which schema was used and how it can be saved."),
247
+ confidence: z.object({
248
+ overall: z.number().describe("0..1 confidence for the extraction as a whole."),
249
+ fields: z.record(z.string(), z.number()).describe("Per-field confidence map (0..1).")
250
+ }).optional().describe("Extraction confidence. Treat fields below ~0.7 as needing human review."),
251
+ provenance: z.record(
252
+ z.string(),
253
+ z.object({
254
+ source_text: z.string().optional(),
255
+ section: z.string().optional(),
256
+ page: z.number().optional()
257
+ })
258
+ ).optional().describe(
259
+ "Per-field source evidence (source_text, section, page). Present only when `include_provenance: true`."
260
+ ),
261
+ processing: z.object({
262
+ duration_ms: z.number().optional(),
263
+ pages_processed: z.number().optional(),
264
+ region: z.string().optional()
265
+ }).optional().describe("Processing metadata: duration, pages processed, region."),
266
+ links: z.object({
267
+ self: z.string().optional(),
268
+ document: z.string().optional(),
269
+ dashboard: z.string().optional()
270
+ }).optional().describe("URLs for self, document, and human-readable dashboard view."),
271
+ markdown: z.string().optional().describe("OCR-converted markdown. Present only when `include_markdown: true`.")
272
+ };
219
273
  async function handleExtract(talonic, args) {
220
274
  if (args.schema === void 0 && args.schema_id === void 0) {
221
275
  return validationError(
@@ -252,7 +306,14 @@ function registerExtract(server, talonic) {
252
306
  {
253
307
  title: "Extract Data from Document",
254
308
  description: DESCRIPTION,
255
- inputSchema
309
+ inputSchema,
310
+ outputSchema,
311
+ annotations: {
312
+ title: "Extract Data from Document",
313
+ readOnlyHint: false,
314
+ destructiveHint: false,
315
+ openWorldHint: true
316
+ }
256
317
  },
257
318
  async (args) => handleExtract(talonic, args)
258
319
  );
@@ -282,6 +343,9 @@ var DESCRIPTION2 = [
282
343
  "- contains: substring match on string fields.",
283
344
  "- is_empty: presence check, no value needed. Returns documents where the field is null or missing.",
284
345
  "",
346
+ "SCHEMA TYPING:",
347
+ "- Numeric operators (`gt`, `gte`, `lt`, `lte`, `between`) only resolve correctly when the schema field is typed as `number`. A field typed as `string` that holds numeric content (e.g. '\u20AC1,500.00') will silently return zero matches even after extraction. Pick the right type at schema design time.",
348
+ "",
285
349
  "NOT SUPPORTED IN v0.1:",
286
350
  "- 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.",
287
351
  "",
@@ -328,6 +392,23 @@ var inputSchema2 = {
328
392
  limit: z.number().int().positive().optional().describe("Results per page. Default 50 server-side."),
329
393
  source_connection_id: z.string().optional().describe("Optionally scope to a specific source connection.")
330
394
  };
395
+ var outputSchema2 = {
396
+ data: z.array(
397
+ z.object({
398
+ document_id: z.string().optional(),
399
+ filename: z.string().optional(),
400
+ fields: z.record(z.string(), z.unknown()).optional()
401
+ }).passthrough()
402
+ ).describe("Documents matching the filter conditions, with their extracted field values."),
403
+ total: z.number().optional().describe("Total documents matching across all pages."),
404
+ page: z.number().optional().describe("Current page number."),
405
+ pagination: z.object({
406
+ total: z.number().optional(),
407
+ limit: z.number().optional(),
408
+ has_more: z.boolean().optional(),
409
+ next_cursor: z.string().nullable().optional()
410
+ }).optional().describe("Cursor-based pagination metadata.")
411
+ };
331
412
  async function handleFilter(talonic, args) {
332
413
  try {
333
414
  const conditions = args.conditions.map((c) => {
@@ -363,7 +444,13 @@ function registerFilter(server, talonic) {
363
444
  {
364
445
  title: "Filter Talonic Documents",
365
446
  description: DESCRIPTION2,
366
- inputSchema: inputSchema2
447
+ inputSchema: inputSchema2,
448
+ outputSchema: outputSchema2,
449
+ annotations: {
450
+ title: "Filter Talonic Documents",
451
+ readOnlyHint: true,
452
+ openWorldHint: true
453
+ }
367
454
  },
368
455
  async (args) => handleFilter(talonic, args)
369
456
  );
@@ -390,6 +477,48 @@ var inputSchema3 = {
390
477
  "The Talonic document ID. Get this from a previous talonic_extract or talonic_search response."
391
478
  )
392
479
  };
480
+ var outputSchema3 = {
481
+ id: z.string(),
482
+ filename: z.string().optional(),
483
+ pages: z.number().optional(),
484
+ size_bytes: z.number().optional(),
485
+ mime_type: z.string().optional(),
486
+ type_detected: z.string().nullable().optional(),
487
+ language_detected: z.string().nullable().optional(),
488
+ status: z.string().optional(),
489
+ source: z.object({
490
+ id: z.string().optional(),
491
+ type: z.string().optional()
492
+ }).optional(),
493
+ triage: z.object({
494
+ sensitivity: z.string().optional(),
495
+ department: z.string().optional(),
496
+ jurisdiction: z.string().nullable().optional(),
497
+ pii_detected: z.boolean().optional(),
498
+ pii_categories: z.array(z.string()).nullable().optional(),
499
+ regulated_data: z.boolean().optional(),
500
+ confidentiality_marking: z.string().nullable().optional()
501
+ }).optional(),
502
+ original_path: z.string().nullable().optional(),
503
+ extraction_count: z.number().optional(),
504
+ latest_extraction_id: z.string().nullable().optional(),
505
+ processing_log: z.array(
506
+ z.object({
507
+ step: z.string().optional(),
508
+ detail: z.string().optional(),
509
+ status: z.string().optional(),
510
+ started_at: z.string().optional(),
511
+ completed_at: z.string().optional(),
512
+ duration_ms: z.number().optional()
513
+ })
514
+ ).optional(),
515
+ created_at: z.string().optional(),
516
+ links: z.object({
517
+ self: z.string().optional(),
518
+ extractions: z.string().optional(),
519
+ dashboard: z.string().optional()
520
+ }).optional()
521
+ };
393
522
  async function handleGetDocument(talonic, args) {
394
523
  try {
395
524
  const result = await talonic.documents.get(args.document_id);
@@ -404,13 +533,17 @@ function registerGetDocument(server, talonic) {
404
533
  {
405
534
  title: "Get Talonic Document",
406
535
  description: DESCRIPTION3,
407
- inputSchema: inputSchema3
536
+ inputSchema: inputSchema3,
537
+ outputSchema: outputSchema3,
538
+ annotations: {
539
+ title: "Get Talonic Document",
540
+ readOnlyHint: true,
541
+ openWorldHint: true
542
+ }
408
543
  },
409
544
  async (args) => handleGetDocument(talonic, args)
410
545
  );
411
546
  }
412
-
413
- // src/tools/list-schemas.ts
414
547
  var DESCRIPTION4 = [
415
548
  "STATUS: stable.",
416
549
  "",
@@ -430,6 +563,31 @@ var DESCRIPTION4 = [
430
563
  "",
431
564
  "TIP: Pair this with talonic_extract by passing the chosen schema's id as `schema_id`."
432
565
  ].join("\n");
566
+ var schemaItem = z.object({
567
+ id: z.string().describe("UUID of the schema."),
568
+ short_id: z.string().optional().describe("Human-readable short id (SCH-XXXXXXXX)."),
569
+ name: z.string(),
570
+ description: z.string().optional(),
571
+ definition: z.record(z.string(), z.unknown()).optional(),
572
+ field_count: z.number().optional(),
573
+ version: z.number().optional(),
574
+ created_at: z.string().optional(),
575
+ updated_at: z.string().optional(),
576
+ links: z.object({
577
+ self: z.string().optional(),
578
+ extractions: z.string().optional(),
579
+ dashboard: z.string().optional()
580
+ }).optional()
581
+ });
582
+ var outputSchema4 = {
583
+ data: z.array(schemaItem).describe("Saved schemas in the workspace."),
584
+ pagination: z.object({
585
+ total: z.number().optional(),
586
+ limit: z.number().optional(),
587
+ has_more: z.boolean().optional(),
588
+ next_cursor: z.string().nullable().optional()
589
+ }).optional().describe("Cursor-based pagination metadata.")
590
+ };
433
591
  async function handleListSchemas(talonic) {
434
592
  try {
435
593
  const result = await talonic.schemas.list();
@@ -444,7 +602,13 @@ function registerListSchemas(server, talonic) {
444
602
  {
445
603
  title: "List Talonic Schemas",
446
604
  description: DESCRIPTION4,
447
- inputSchema: {}
605
+ inputSchema: {},
606
+ outputSchema: outputSchema4,
607
+ annotations: {
608
+ title: "List Talonic Schemas",
609
+ readOnlyHint: true,
610
+ openWorldHint: true
611
+ }
448
612
  },
449
613
  async () => handleListSchemas(talonic)
450
614
  );
@@ -477,6 +641,22 @@ var inputSchema4 = {
477
641
  ),
478
642
  description: z.string().optional().describe("Optional description of what this schema extracts and when to use it.")
479
643
  };
644
+ var outputSchema5 = {
645
+ id: z.string().describe("UUID of the newly saved schema."),
646
+ short_id: z.string().optional().describe("Human-readable short id (SCH-XXXXXXXX)."),
647
+ name: z.string(),
648
+ description: z.string().optional(),
649
+ definition: z.record(z.string(), z.unknown()).optional().describe("Final schema definition as stored, normalised by the API."),
650
+ field_count: z.number().optional(),
651
+ version: z.number().optional().describe("Schema version (1 for new schemas; increments on update)."),
652
+ created_at: z.string().optional(),
653
+ updated_at: z.string().optional(),
654
+ links: z.object({
655
+ self: z.string().optional(),
656
+ extractions: z.string().optional(),
657
+ dashboard: z.string().optional()
658
+ }).optional()
659
+ };
480
660
  async function handleSaveSchema(talonic, args) {
481
661
  try {
482
662
  const result = await talonic.schemas.create({
@@ -495,7 +675,14 @@ function registerSaveSchema(server, talonic) {
495
675
  {
496
676
  title: "Save Talonic Schema",
497
677
  description: DESCRIPTION5,
498
- inputSchema: inputSchema4
678
+ inputSchema: inputSchema4,
679
+ outputSchema: outputSchema5,
680
+ annotations: {
681
+ title: "Save Talonic Schema",
682
+ readOnlyHint: false,
683
+ destructiveHint: false,
684
+ openWorldHint: true
685
+ }
499
686
  },
500
687
  async (args) => handleSaveSchema(talonic, args)
501
688
  );
@@ -528,6 +715,40 @@ var inputSchema5 = {
528
715
  ),
529
716
  limit: z.number().int().positive().optional().describe("Maximum results per entity type. Default: 5. Increase for broader exploration.")
530
717
  };
718
+ var outputSchema6 = {
719
+ documents: z.array(
720
+ z.object({
721
+ id: z.string(),
722
+ name: z.string().optional(),
723
+ sourceId: z.string().optional(),
724
+ sourceName: z.string().optional()
725
+ })
726
+ ).describe("Documents matching the query."),
727
+ fieldMatches: z.array(
728
+ z.object({
729
+ resolvedFieldId: z.string().nullable(),
730
+ displayName: z.string().optional(),
731
+ matchedValue: z.string().optional(),
732
+ documentCount: z.number().optional(),
733
+ filterable: z.boolean().describe("Only filterable: true entries can be used with talonic_filter.")
734
+ })
735
+ ).describe(
736
+ "Field-level matches with a filterable flag indicating whether the entry can drive talonic_filter."
737
+ ),
738
+ sources: z.array(z.object({ id: z.string(), name: z.string().optional() })).describe("Source connections matching the query."),
739
+ schemas: z.array(z.object({ id: z.string(), name: z.string().optional() })).describe("Saved schemas matching the query."),
740
+ fields: z.array(
741
+ z.object({
742
+ id: z.string(),
743
+ canonicalName: z.string().optional(),
744
+ displayName: z.string().optional(),
745
+ documentCount: z.number().optional(),
746
+ filterable: z.boolean().optional()
747
+ })
748
+ ).describe(
749
+ "Field-registry entries matching the query. filterable: true entries are usable with talonic_filter."
750
+ )
751
+ };
531
752
  async function handleSearch(talonic, args) {
532
753
  try {
533
754
  const result = await talonic.search(
@@ -545,7 +766,13 @@ function registerSearch(server, talonic) {
545
766
  {
546
767
  title: "Search Talonic Workspace",
547
768
  description: DESCRIPTION6,
548
- inputSchema: inputSchema5
769
+ inputSchema: inputSchema5,
770
+ outputSchema: outputSchema6,
771
+ annotations: {
772
+ title: "Search Talonic Workspace",
773
+ readOnlyHint: true,
774
+ openWorldHint: true
775
+ }
549
776
  },
550
777
  async (args) => handleSearch(talonic, args)
551
778
  );
@@ -590,6 +817,10 @@ var inputSchema6 = {
590
817
  ),
591
818
  file_url: z.string().optional().describe("URL to a document file. The Talonic API fetches it server-side.")
592
819
  };
820
+ var outputSchema7 = {
821
+ document_id: z.string().describe("ID of the document the markdown was extracted from."),
822
+ markdown: z.string().describe("OCR-converted markdown text content of the document.")
823
+ };
593
824
  var INGEST_ONLY_SCHEMA = {
594
825
  type: "object",
595
826
  properties: {
@@ -641,7 +872,14 @@ function registerToMarkdown(server, talonic) {
641
872
  {
642
873
  title: "Document to Markdown",
643
874
  description: DESCRIPTION7,
644
- inputSchema: inputSchema6
875
+ inputSchema: inputSchema6,
876
+ outputSchema: outputSchema7,
877
+ annotations: {
878
+ title: "Document to Markdown",
879
+ readOnlyHint: false,
880
+ destructiveHint: false,
881
+ openWorldHint: true
882
+ }
645
883
  },
646
884
  async (args) => handleToMarkdown(talonic, args)
647
885
  );
@@ -649,7 +887,7 @@ function registerToMarkdown(server, talonic) {
649
887
 
650
888
  // package.json
651
889
  var package_default = {
652
- version: "0.1.15"};
890
+ version: "0.1.17"};
653
891
 
654
892
  // src/version.ts
655
893
  var VERSION = package_default.version;