@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.
@@ -273,7 +273,16 @@ var outputSchema = {
273
273
  document: z.string().optional(),
274
274
  dashboard: z.string().optional()
275
275
  }).optional().describe("URLs for self, document, and human-readable dashboard view."),
276
- markdown: z.string().optional().describe("OCR-converted markdown. Present only when `include_markdown: true`.")
276
+ markdown: z.string().optional().describe("OCR-converted markdown. Present only when `include_markdown: true`."),
277
+ cost: z.object({
278
+ costCredits: z.number().describe("Credits consumed by this call."),
279
+ costEur: z.number().describe("Approximate EUR cost of this call."),
280
+ balanceCredits: z.number().describe("Workspace credit balance after this call settled."),
281
+ cellsResolvedRegistry: z.number().describe("Cells resolved from the materialized field-registry (cheap path)."),
282
+ cellsResolvedAi: z.number().describe("Cells resolved by AI extraction (priced path).")
283
+ }).nullable().optional().describe(
284
+ "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."
285
+ )
277
286
  };
278
287
  async function handleExtract(talonic, args) {
279
288
  if (args.schema === void 0 && args.schema_id === void 0) {
@@ -461,6 +470,70 @@ function registerFilter(server, getTalonic) {
461
470
  );
462
471
  }
463
472
  var DESCRIPTION3 = [
473
+ "STATUS: stable.",
474
+ "",
475
+ "Read the user's current Talonic credit balance, EUR value, 30-day burn rate,",
476
+ "projected runway, tier, and next-tier-reset timestamp. Use this to make budget-",
477
+ "aware decisions before kicking off large batches or re-extractions.",
478
+ "",
479
+ "USE WHEN:",
480
+ "- The user asks how many credits or how much budget they have left.",
481
+ "- You are about to run a large or expensive operation (batch extract, re-extract",
482
+ " many documents) and want to confirm budget headroom first.",
483
+ "- The user asks how long their balance will last at the current rate.",
484
+ "",
485
+ "DO NOT USE WHEN:",
486
+ "- The user just wants the per-call cost of a single extraction (that is already",
487
+ " on the talonic_extract response under `cost`).",
488
+ "- The user wants to top up credits (route them to the dashboard; auto top-up is",
489
+ " guarded by a separate scope).",
490
+ "",
491
+ "RESPONSE SHAPE:",
492
+ "- balance_credits: current credit balance.",
493
+ "- balance_eur: current balance in EUR (rounded to two decimals).",
494
+ "- burn_rate_30d_credits: total credits consumed in the trailing 30 days.",
495
+ "- projected_runway_days: days of runway at the current 30-day average burn.",
496
+ " `-1` indicates no consumption in the trailing window (cannot compute runway).",
497
+ "- tier: API tier of the workspace (`free`, `pro`, `enterprise`, etc.).",
498
+ "- tier_resets_at: ISO 8601 timestamp of the next monthly tier reset."
499
+ ].join("\n");
500
+ var inputSchema3 = {};
501
+ var outputSchema3 = {
502
+ balance_credits: z.number().describe("Current credit balance."),
503
+ balance_eur: z.number().describe("Current balance in EUR (two decimals)."),
504
+ burn_rate_30d_credits: z.number().describe("Total credits consumed in the trailing 30 days."),
505
+ projected_runway_days: z.number().describe(
506
+ "Projected days of runway at the current 30-day average burn. `-1` when burn is zero (cannot compute)."
507
+ ),
508
+ tier: z.string().describe("API tier of the workspace."),
509
+ tier_resets_at: z.string().describe("ISO 8601 timestamp of the next monthly tier reset.")
510
+ };
511
+ async function handleGetBalance(talonic) {
512
+ try {
513
+ const result = await talonic.credits.getBalance();
514
+ return jsonOk(result);
515
+ } catch (err) {
516
+ return toolError(err);
517
+ }
518
+ }
519
+ function registerGetBalance(server, getTalonic) {
520
+ server.registerTool(
521
+ "talonic_get_balance",
522
+ {
523
+ title: "Get Talonic Credit Balance",
524
+ description: DESCRIPTION3,
525
+ inputSchema: inputSchema3,
526
+ outputSchema: outputSchema3,
527
+ annotations: {
528
+ title: "Get Talonic Credit Balance",
529
+ readOnlyHint: true,
530
+ openWorldHint: true
531
+ }
532
+ },
533
+ async () => handleGetBalance(getTalonic())
534
+ );
535
+ }
536
+ var DESCRIPTION4 = [
464
537
  "STATUS: stable.",
465
538
  "",
466
539
  "Fetch full metadata for a single document already in the user's Talonic workspace.",
@@ -477,12 +550,12 @@ var DESCRIPTION3 = [
477
550
  "- The user wants extracted structured data (use talonic_extract with a schema, or fetch the extraction by id).",
478
551
  "- The user has a file but no document_id yet (call talonic_extract first to ingest the document)."
479
552
  ].join("\n");
480
- var inputSchema3 = {
553
+ var inputSchema4 = {
481
554
  document_id: z.string().min(1).describe(
482
555
  "The Talonic document ID. Get this from a previous talonic_extract or talonic_search response."
483
556
  )
484
557
  };
485
- var outputSchema3 = {
558
+ var outputSchema4 = {
486
559
  id: z.string(),
487
560
  filename: z.string().optional(),
488
561
  pages: z.number().optional(),
@@ -537,9 +610,9 @@ function registerGetDocument(server, getTalonic) {
537
610
  "talonic_get_document",
538
611
  {
539
612
  title: "Get Talonic Document",
540
- description: DESCRIPTION3,
541
- inputSchema: inputSchema3,
542
- outputSchema: outputSchema3,
613
+ description: DESCRIPTION4,
614
+ inputSchema: inputSchema4,
615
+ outputSchema: outputSchema4,
543
616
  annotations: {
544
617
  title: "Get Talonic Document",
545
618
  readOnlyHint: true,
@@ -549,7 +622,7 @@ function registerGetDocument(server, getTalonic) {
549
622
  async (args) => handleGetDocument(getTalonic(), args)
550
623
  );
551
624
  }
552
- var DESCRIPTION4 = [
625
+ var DESCRIPTION5 = [
553
626
  "STATUS: stable.",
554
627
  "",
555
628
  "List all saved schemas in the user's Talonic workspace.",
@@ -586,7 +659,7 @@ var schemaItem = z.object({
586
659
  dashboard: z.string().optional()
587
660
  }).optional()
588
661
  });
589
- var outputSchema4 = {
662
+ var outputSchema5 = {
590
663
  data: z.array(schemaItem).describe("Saved schemas in the workspace."),
591
664
  pagination: z.object({
592
665
  total: z.number().optional(),
@@ -608,9 +681,9 @@ function registerListSchemas(server, getTalonic) {
608
681
  "talonic_list_schemas",
609
682
  {
610
683
  title: "List Talonic Schemas",
611
- description: DESCRIPTION4,
684
+ description: DESCRIPTION5,
612
685
  inputSchema: {},
613
- outputSchema: outputSchema4,
686
+ outputSchema: outputSchema5,
614
687
  annotations: {
615
688
  title: "List Talonic Schemas",
616
689
  readOnlyHint: true,
@@ -620,7 +693,7 @@ function registerListSchemas(server, getTalonic) {
620
693
  async () => handleListSchemas(getTalonic())
621
694
  );
622
695
  }
623
- var DESCRIPTION5 = [
696
+ var DESCRIPTION6 = [
624
697
  "STATUS: stable.",
625
698
  "",
626
699
  "Save a schema definition to the user's Talonic workspace so it can be reused",
@@ -641,14 +714,14 @@ var DESCRIPTION5 = [
641
714
  "",
642
715
  "TIP: After saving, call talonic_extract with `schema_id` set to the returned id (UUID or SCH- short id) for consistent results."
643
716
  ].join("\n");
644
- var inputSchema4 = {
717
+ var inputSchema5 = {
645
718
  name: z.string().min(1).describe("Human-readable name for the schema, e.g. 'Standard Invoice'."),
646
719
  definition: z.record(z.string(), z.unknown()).describe(
647
720
  "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."
648
721
  ),
649
722
  description: z.string().optional().describe("Optional description of what this schema extracts and when to use it.")
650
723
  };
651
- var outputSchema5 = {
724
+ var outputSchema6 = {
652
725
  id: z.string().describe("UUID of the newly saved schema."),
653
726
  short_id: z.string().optional().describe("Human-readable short id (SCH-XXXXXXXX)."),
654
727
  name: z.string(),
@@ -683,9 +756,9 @@ function registerSaveSchema(server, getTalonic) {
683
756
  "talonic_save_schema",
684
757
  {
685
758
  title: "Save Talonic Schema",
686
- description: DESCRIPTION5,
687
- inputSchema: inputSchema4,
688
- outputSchema: outputSchema5,
759
+ description: DESCRIPTION6,
760
+ inputSchema: inputSchema5,
761
+ outputSchema: outputSchema6,
689
762
  annotations: {
690
763
  title: "Save Talonic Schema",
691
764
  readOnlyHint: false,
@@ -696,7 +769,7 @@ function registerSaveSchema(server, getTalonic) {
696
769
  async (args) => handleSaveSchema(getTalonic(), args)
697
770
  );
698
771
  }
699
- var DESCRIPTION6 = [
772
+ var DESCRIPTION7 = [
700
773
  "STATUS: stable.",
701
774
  "",
702
775
  "Search the user's Talonic workspace for documents, fields, sources, or schemas",
@@ -718,13 +791,13 @@ var DESCRIPTION6 = [
718
791
  "filterable: true can be used with talonic_filter. Fields with filterable: false exist",
719
792
  "in a schema but have no extracted data yet. Pick the entity type the user actually needs."
720
793
  ].join("\n");
721
- var inputSchema5 = {
794
+ var inputSchema6 = {
722
795
  query: z.string().min(1).describe(
723
796
  "Natural-language search query, e.g. 'indemnification clauses' or 'Acme invoices Q4'."
724
797
  ),
725
798
  limit: z.number().int().positive().optional().describe("Maximum results per entity type. Default: 5. Increase for broader exploration.")
726
799
  };
727
- var outputSchema6 = {
800
+ var outputSchema7 = {
728
801
  documents: z.array(
729
802
  z.object({
730
803
  id: z.string(),
@@ -776,9 +849,9 @@ function registerSearch(server, getTalonic) {
776
849
  "talonic_search",
777
850
  {
778
851
  title: "Search Talonic Workspace",
779
- description: DESCRIPTION6,
780
- inputSchema: inputSchema5,
781
- outputSchema: outputSchema6,
852
+ description: DESCRIPTION7,
853
+ inputSchema: inputSchema6,
854
+ outputSchema: outputSchema7,
782
855
  annotations: {
783
856
  title: "Search Talonic Workspace",
784
857
  readOnlyHint: true,
@@ -788,7 +861,7 @@ function registerSearch(server, getTalonic) {
788
861
  async (args) => handleSearch(getTalonic(), args)
789
862
  );
790
863
  }
791
- var DESCRIPTION7 = [
864
+ var DESCRIPTION8 = [
792
865
  "STATUS: stable.",
793
866
  "",
794
867
  "Get the OCR-converted markdown for a document. Accepts an existing document_id,",
@@ -818,7 +891,7 @@ var DESCRIPTION7 = [
818
891
  "- file_url: a URL the Talonic API will fetch directly. Use for documents already on the",
819
892
  " public web. Best path for Claude.ai users dealing with files larger than the parameter cap."
820
893
  ].join("\n");
821
- var inputSchema6 = {
894
+ var inputSchema7 = {
822
895
  document_id: z.string().min(1).optional().describe(
823
896
  "The Talonic document id whose markdown you want. Get this from a previous talonic_extract or talonic_search response."
824
897
  ),
@@ -833,9 +906,18 @@ var inputSchema6 = {
833
906
  ),
834
907
  file_url: z.string().optional().describe("URL to a document file. The Talonic API fetches it server-side.")
835
908
  };
836
- var outputSchema7 = {
909
+ var outputSchema8 = {
837
910
  document_id: z.string().describe("ID of the document the markdown was extracted from."),
838
- markdown: z.string().describe("OCR-converted markdown text content of the document.")
911
+ markdown: z.string().describe("OCR-converted markdown text content of the document."),
912
+ cost: z.object({
913
+ costCredits: z.number(),
914
+ costEur: z.number(),
915
+ balanceCredits: z.number(),
916
+ cellsResolvedRegistry: z.number(),
917
+ cellsResolvedAi: z.number()
918
+ }).nullable().optional().describe(
919
+ "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."
920
+ )
839
921
  };
840
922
  var INGEST_ONLY_SCHEMA = {
841
923
  type: "object",
@@ -887,9 +969,9 @@ function registerToMarkdown(server, getTalonic) {
887
969
  "talonic_to_markdown",
888
970
  {
889
971
  title: "Document to Markdown",
890
- description: DESCRIPTION7,
891
- inputSchema: inputSchema6,
892
- outputSchema: outputSchema7,
972
+ description: DESCRIPTION8,
973
+ inputSchema: inputSchema7,
974
+ outputSchema: outputSchema8,
893
975
  annotations: {
894
976
  title: "Document to Markdown",
895
977
  readOnlyHint: false,
@@ -903,7 +985,7 @@ function registerToMarkdown(server, getTalonic) {
903
985
 
904
986
  // package.json
905
987
  var package_default = {
906
- version: "0.1.23"};
988
+ version: "0.1.24"};
907
989
 
908
990
  // src/version.ts
909
991
  var VERSION = package_default.version;
@@ -973,6 +1055,7 @@ function createServer(options) {
973
1055
  registerFilter(server, getTalonic);
974
1056
  registerToMarkdown(server, getTalonic);
975
1057
  registerExtract(server, getTalonic);
1058
+ registerGetBalance(server, getTalonic);
976
1059
  registerSchemasResource(server, getTalonic);
977
1060
  registerWebhooksResource(server, getToken, baseUrl);
978
1061
  return server;