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