@talonic/mcp 0.1.23 → 0.1.24

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
@@ -269,7 +269,16 @@ var outputSchema = {
269
269
  document: z.string().optional(),
270
270
  dashboard: z.string().optional()
271
271
  }).optional().describe("URLs for self, document, and human-readable dashboard view."),
272
- markdown: z.string().optional().describe("OCR-converted markdown. Present only when `include_markdown: true`.")
272
+ markdown: z.string().optional().describe("OCR-converted markdown. Present only when `include_markdown: true`."),
273
+ cost: z.object({
274
+ costCredits: z.number().describe("Credits consumed by this call."),
275
+ costEur: z.number().describe("Approximate EUR cost of this call."),
276
+ balanceCredits: z.number().describe("Workspace credit balance after this call settled."),
277
+ cellsResolvedRegistry: z.number().describe("Cells resolved from the materialized field-registry (cheap path)."),
278
+ cellsResolvedAi: z.number().describe("Cells resolved by AI extraction (priced path).")
279
+ }).nullable().optional().describe(
280
+ "Per-call cost and post-call balance, parsed from the X-Talonic-* response headers. `null` for non-extract calls; not always present on legacy clients."
281
+ )
273
282
  };
274
283
  async function handleExtract(talonic, args) {
275
284
  if (args.schema === void 0 && args.schema_id === void 0) {
@@ -457,6 +466,70 @@ function registerFilter(server, getTalonic) {
457
466
  );
458
467
  }
459
468
  var DESCRIPTION3 = [
469
+ "STATUS: stable.",
470
+ "",
471
+ "Read the user's current Talonic credit balance, EUR value, 30-day burn rate,",
472
+ "projected runway, tier, and next-tier-reset timestamp. Use this to make budget-",
473
+ "aware decisions before kicking off large batches or re-extractions.",
474
+ "",
475
+ "USE WHEN:",
476
+ "- The user asks how many credits or how much budget they have left.",
477
+ "- You are about to run a large or expensive operation (batch extract, re-extract",
478
+ " many documents) and want to confirm budget headroom first.",
479
+ "- The user asks how long their balance will last at the current rate.",
480
+ "",
481
+ "DO NOT USE WHEN:",
482
+ "- The user just wants the per-call cost of a single extraction (that is already",
483
+ " on the talonic_extract response under `cost`).",
484
+ "- The user wants to top up credits (route them to the dashboard; auto top-up is",
485
+ " guarded by a separate scope).",
486
+ "",
487
+ "RESPONSE SHAPE:",
488
+ "- balance_credits: current credit balance.",
489
+ "- balance_eur: current balance in EUR (rounded to two decimals).",
490
+ "- burn_rate_30d_credits: total credits consumed in the trailing 30 days.",
491
+ "- projected_runway_days: days of runway at the current 30-day average burn.",
492
+ " `-1` indicates no consumption in the trailing window (cannot compute runway).",
493
+ "- tier: API tier of the workspace (`free`, `pro`, `enterprise`, etc.).",
494
+ "- tier_resets_at: ISO 8601 timestamp of the next monthly tier reset."
495
+ ].join("\n");
496
+ var inputSchema3 = {};
497
+ var outputSchema3 = {
498
+ balance_credits: z.number().describe("Current credit balance."),
499
+ balance_eur: z.number().describe("Current balance in EUR (two decimals)."),
500
+ burn_rate_30d_credits: z.number().describe("Total credits consumed in the trailing 30 days."),
501
+ projected_runway_days: z.number().describe(
502
+ "Projected days of runway at the current 30-day average burn. `-1` when burn is zero (cannot compute)."
503
+ ),
504
+ tier: z.string().describe("API tier of the workspace."),
505
+ tier_resets_at: z.string().describe("ISO 8601 timestamp of the next monthly tier reset.")
506
+ };
507
+ async function handleGetBalance(talonic) {
508
+ try {
509
+ const result = await talonic.credits.getBalance();
510
+ return jsonOk(result);
511
+ } catch (err) {
512
+ return toolError(err);
513
+ }
514
+ }
515
+ function registerGetBalance(server, getTalonic) {
516
+ server.registerTool(
517
+ "talonic_get_balance",
518
+ {
519
+ title: "Get Talonic Credit Balance",
520
+ description: DESCRIPTION3,
521
+ inputSchema: inputSchema3,
522
+ outputSchema: outputSchema3,
523
+ annotations: {
524
+ title: "Get Talonic Credit Balance",
525
+ readOnlyHint: true,
526
+ openWorldHint: true
527
+ }
528
+ },
529
+ async () => handleGetBalance(getTalonic())
530
+ );
531
+ }
532
+ var DESCRIPTION4 = [
460
533
  "STATUS: stable.",
461
534
  "",
462
535
  "Fetch full metadata for a single document already in the user's Talonic workspace.",
@@ -473,12 +546,12 @@ var DESCRIPTION3 = [
473
546
  "- The user wants extracted structured data (use talonic_extract with a schema, or fetch the extraction by id).",
474
547
  "- The user has a file but no document_id yet (call talonic_extract first to ingest the document)."
475
548
  ].join("\n");
476
- var inputSchema3 = {
549
+ var inputSchema4 = {
477
550
  document_id: z.string().min(1).describe(
478
551
  "The Talonic document ID. Get this from a previous talonic_extract or talonic_search response."
479
552
  )
480
553
  };
481
- var outputSchema3 = {
554
+ var outputSchema4 = {
482
555
  id: z.string(),
483
556
  filename: z.string().optional(),
484
557
  pages: z.number().optional(),
@@ -533,9 +606,9 @@ function registerGetDocument(server, getTalonic) {
533
606
  "talonic_get_document",
534
607
  {
535
608
  title: "Get Talonic Document",
536
- description: DESCRIPTION3,
537
- inputSchema: inputSchema3,
538
- outputSchema: outputSchema3,
609
+ description: DESCRIPTION4,
610
+ inputSchema: inputSchema4,
611
+ outputSchema: outputSchema4,
539
612
  annotations: {
540
613
  title: "Get Talonic Document",
541
614
  readOnlyHint: true,
@@ -545,7 +618,7 @@ function registerGetDocument(server, getTalonic) {
545
618
  async (args) => handleGetDocument(getTalonic(), args)
546
619
  );
547
620
  }
548
- var DESCRIPTION4 = [
621
+ var DESCRIPTION5 = [
549
622
  "STATUS: stable.",
550
623
  "",
551
624
  "List all saved schemas in the user's Talonic workspace.",
@@ -582,7 +655,7 @@ var schemaItem = z.object({
582
655
  dashboard: z.string().optional()
583
656
  }).optional()
584
657
  });
585
- var outputSchema4 = {
658
+ var outputSchema5 = {
586
659
  data: z.array(schemaItem).describe("Saved schemas in the workspace."),
587
660
  pagination: z.object({
588
661
  total: z.number().optional(),
@@ -604,9 +677,9 @@ function registerListSchemas(server, getTalonic) {
604
677
  "talonic_list_schemas",
605
678
  {
606
679
  title: "List Talonic Schemas",
607
- description: DESCRIPTION4,
680
+ description: DESCRIPTION5,
608
681
  inputSchema: {},
609
- outputSchema: outputSchema4,
682
+ outputSchema: outputSchema5,
610
683
  annotations: {
611
684
  title: "List Talonic Schemas",
612
685
  readOnlyHint: true,
@@ -616,7 +689,7 @@ function registerListSchemas(server, getTalonic) {
616
689
  async () => handleListSchemas(getTalonic())
617
690
  );
618
691
  }
619
- var DESCRIPTION5 = [
692
+ var DESCRIPTION6 = [
620
693
  "STATUS: stable.",
621
694
  "",
622
695
  "Save a schema definition to the user's Talonic workspace so it can be reused",
@@ -637,14 +710,14 @@ var DESCRIPTION5 = [
637
710
  "",
638
711
  "TIP: After saving, call talonic_extract with `schema_id` set to the returned id (UUID or SCH- short id) for consistent results."
639
712
  ].join("\n");
640
- var inputSchema4 = {
713
+ var inputSchema5 = {
641
714
  name: z.string().min(1).describe("Human-readable name for the schema, e.g. 'Standard Invoice'."),
642
715
  definition: z.record(z.string(), z.unknown()).describe(
643
716
  "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."
644
717
  ),
645
718
  description: z.string().optional().describe("Optional description of what this schema extracts and when to use it.")
646
719
  };
647
- var outputSchema5 = {
720
+ var outputSchema6 = {
648
721
  id: z.string().describe("UUID of the newly saved schema."),
649
722
  short_id: z.string().optional().describe("Human-readable short id (SCH-XXXXXXXX)."),
650
723
  name: z.string(),
@@ -679,9 +752,9 @@ function registerSaveSchema(server, getTalonic) {
679
752
  "talonic_save_schema",
680
753
  {
681
754
  title: "Save Talonic Schema",
682
- description: DESCRIPTION5,
683
- inputSchema: inputSchema4,
684
- outputSchema: outputSchema5,
755
+ description: DESCRIPTION6,
756
+ inputSchema: inputSchema5,
757
+ outputSchema: outputSchema6,
685
758
  annotations: {
686
759
  title: "Save Talonic Schema",
687
760
  readOnlyHint: false,
@@ -692,7 +765,7 @@ function registerSaveSchema(server, getTalonic) {
692
765
  async (args) => handleSaveSchema(getTalonic(), args)
693
766
  );
694
767
  }
695
- var DESCRIPTION6 = [
768
+ var DESCRIPTION7 = [
696
769
  "STATUS: stable.",
697
770
  "",
698
771
  "Search the user's Talonic workspace for documents, fields, sources, or schemas",
@@ -714,13 +787,13 @@ var DESCRIPTION6 = [
714
787
  "filterable: true can be used with talonic_filter. Fields with filterable: false exist",
715
788
  "in a schema but have no extracted data yet. Pick the entity type the user actually needs."
716
789
  ].join("\n");
717
- var inputSchema5 = {
790
+ var inputSchema6 = {
718
791
  query: z.string().min(1).describe(
719
792
  "Natural-language search query, e.g. 'indemnification clauses' or 'Acme invoices Q4'."
720
793
  ),
721
794
  limit: z.number().int().positive().optional().describe("Maximum results per entity type. Default: 5. Increase for broader exploration.")
722
795
  };
723
- var outputSchema6 = {
796
+ var outputSchema7 = {
724
797
  documents: z.array(
725
798
  z.object({
726
799
  id: z.string(),
@@ -772,9 +845,9 @@ function registerSearch(server, getTalonic) {
772
845
  "talonic_search",
773
846
  {
774
847
  title: "Search Talonic Workspace",
775
- description: DESCRIPTION6,
776
- inputSchema: inputSchema5,
777
- outputSchema: outputSchema6,
848
+ description: DESCRIPTION7,
849
+ inputSchema: inputSchema6,
850
+ outputSchema: outputSchema7,
778
851
  annotations: {
779
852
  title: "Search Talonic Workspace",
780
853
  readOnlyHint: true,
@@ -784,7 +857,7 @@ function registerSearch(server, getTalonic) {
784
857
  async (args) => handleSearch(getTalonic(), args)
785
858
  );
786
859
  }
787
- var DESCRIPTION7 = [
860
+ var DESCRIPTION8 = [
788
861
  "STATUS: stable.",
789
862
  "",
790
863
  "Get the OCR-converted markdown for a document. Accepts an existing document_id,",
@@ -814,7 +887,7 @@ var DESCRIPTION7 = [
814
887
  "- file_url: a URL the Talonic API will fetch directly. Use for documents already on the",
815
888
  " public web. Best path for Claude.ai users dealing with files larger than the parameter cap."
816
889
  ].join("\n");
817
- var inputSchema6 = {
890
+ var inputSchema7 = {
818
891
  document_id: z.string().min(1).optional().describe(
819
892
  "The Talonic document id whose markdown you want. Get this from a previous talonic_extract or talonic_search response."
820
893
  ),
@@ -829,9 +902,18 @@ var inputSchema6 = {
829
902
  ),
830
903
  file_url: z.string().optional().describe("URL to a document file. The Talonic API fetches it server-side.")
831
904
  };
832
- var outputSchema7 = {
905
+ var outputSchema8 = {
833
906
  document_id: z.string().describe("ID of the document the markdown was extracted from."),
834
- markdown: z.string().describe("OCR-converted markdown text content of the document.")
907
+ markdown: z.string().describe("OCR-converted markdown text content of the document."),
908
+ cost: z.object({
909
+ costCredits: z.number(),
910
+ costEur: z.number(),
911
+ balanceCredits: z.number(),
912
+ cellsResolvedRegistry: z.number(),
913
+ cellsResolvedAi: z.number()
914
+ }).nullable().optional().describe(
915
+ "Per-call cost and post-call balance from the underlying extract step, parsed from the X-Talonic-* response headers. `null` when the document was already ingested (document_id path) and no extract call ran. Not always present on legacy clients."
916
+ )
835
917
  };
836
918
  var INGEST_ONLY_SCHEMA = {
837
919
  type: "object",
@@ -883,9 +965,9 @@ function registerToMarkdown(server, getTalonic) {
883
965
  "talonic_to_markdown",
884
966
  {
885
967
  title: "Document to Markdown",
886
- description: DESCRIPTION7,
887
- inputSchema: inputSchema6,
888
- outputSchema: outputSchema7,
968
+ description: DESCRIPTION8,
969
+ inputSchema: inputSchema7,
970
+ outputSchema: outputSchema8,
889
971
  annotations: {
890
972
  title: "Document to Markdown",
891
973
  readOnlyHint: false,
@@ -899,7 +981,7 @@ function registerToMarkdown(server, getTalonic) {
899
981
 
900
982
  // package.json
901
983
  var package_default = {
902
- version: "0.1.23"};
984
+ version: "0.1.24"};
903
985
 
904
986
  // src/version.ts
905
987
  var VERSION = package_default.version;
@@ -969,6 +1051,7 @@ function createServer(options) {
969
1051
  registerFilter(server, getTalonic);
970
1052
  registerToMarkdown(server, getTalonic);
971
1053
  registerExtract(server, getTalonic);
1054
+ registerGetBalance(server, getTalonic);
972
1055
  registerSchemasResource(server, getTalonic);
973
1056
  registerWebhooksResource(server, getToken, baseUrl);
974
1057
  return server;