@talonic/mcp 0.1.82 → 0.1.83

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.d.ts CHANGED
@@ -59,6 +59,12 @@ interface CreateServerOptions {
59
59
  * never lists tools that would 404. Listing visibility only.
60
60
  */
61
61
  includeContractsTools?: boolean;
62
+ /**
63
+ * Register the `talonic_ap_*` tools. Callers set this only after
64
+ * `probeApAccess` passed, so a deployment without the AP app never lists
65
+ * tools that would 404. Listing visibility only.
66
+ */
67
+ includeApTools?: boolean;
62
68
  /**
63
69
  * Whether the seven decision-task tools are listed as invocable. The hosted
64
70
  * entrypoint sets this from `tokenHasDecideScope`: an OAuth token that
package/dist/index.js CHANGED
@@ -3383,6 +3383,236 @@ function registerContractsTools(server, getToken, baseUrl) {
3383
3383
  );
3384
3384
  }
3385
3385
  }
3386
+ var readOnly2 = {
3387
+ readOnlyHint: true,
3388
+ destructiveHint: false,
3389
+ idempotentHint: true,
3390
+ openWorldHint: false
3391
+ };
3392
+ var write2 = (idempotent, destructive = false) => ({
3393
+ readOnlyHint: false,
3394
+ destructiveHint: destructive,
3395
+ idempotentHint: idempotent,
3396
+ openWorldHint: false
3397
+ });
3398
+ var OVERVIEW_DESCRIPTION = [
3399
+ "AP totals for the workspace: invoices ready to post and held (count and dollars), dollars at stake above contract, duplicates, missing PO, per entity with its system of record, and the last simulated NetSuite run.",
3400
+ 'USE WHEN: the headline ("how much is ready to post, how much is held and why").',
3401
+ "NOT FOR: the invoices themselves (talonic_ap_bills); the held worklist (talonic_ap_issues).",
3402
+ "",
3403
+ "ARGS: none.",
3404
+ "RETURNS: { as_of, currency, configured, gaps[], totals { bills, ready, held { at_stake, above_contract, duplicates, missing_po, vendor_unknown } }, entities[], sources[], last_run }."
3405
+ ].join("\n");
3406
+ function handleOverview(getToken, baseUrl) {
3407
+ return runTool(() => apiJson(getToken, baseUrl, "GET", "/v1/ap/overview"));
3408
+ }
3409
+ var BILLS_DESCRIPTION = [
3410
+ "List AP invoices as posting-ready vendor bills, each with vendor, invoice number, dates, amount (as invoiced and in the ledger currency), entity, status, holds with dollars and evidence, NetSuite mapping and lines.",
3411
+ "USE WHEN: looking up invoices by vendor or number, or listing the ready or held ones.",
3412
+ "NOT FOR: totals (talonic_ap_overview).",
3413
+ "",
3414
+ "ARGS: `status` ready|held, `entity` (entity code), `reason` above_contract|duplicate|missing_po|vendor_unknown, `query` (vendor, number, filename or contract contains), `limit` (default 500).",
3415
+ "RETURNS: { currency, total, data[] }."
3416
+ ].join("\n");
3417
+ var billsInputSchema = {
3418
+ status: z.enum(["ready", "held"]).optional().describe("Only ready or only held invoices."),
3419
+ entity: z.string().optional().describe("Entity code, e.g. 'HRL'."),
3420
+ reason: z.enum(["above_contract", "duplicate", "missing_po", "vendor_unknown"]).optional().describe("Only invoices held for this reason."),
3421
+ query: z.string().optional().describe("Vendor, invoice number, filename or contract contains."),
3422
+ limit: z.number().int().min(1).max(5e3).optional().describe("Maximum invoices returned.")
3423
+ };
3424
+ function handleBills(getToken, baseUrl, args) {
3425
+ return runTool(
3426
+ () => apiJson(getToken, baseUrl, "GET", "/v1/ap/bills", {
3427
+ params: {
3428
+ status: args.status,
3429
+ entity: args.entity,
3430
+ reason: args.reason,
3431
+ q: args.query,
3432
+ limit: args.limit
3433
+ }
3434
+ })
3435
+ );
3436
+ }
3437
+ var ISSUES_DESCRIPTION2 = [
3438
+ "The AP worklist: every held invoice, why (each hold with its reason, finding, explanation and dollars), and the dollars at stake.",
3439
+ "USE WHEN: deciding what to dispute or fix before posting.",
3440
+ "NOT FOR: invoices ready to post (talonic_ap_bills with status=ready).",
3441
+ "",
3442
+ "ARGS: none.",
3443
+ "RETURNS: { currency, data[] { key, vendor, invoice_number, entity, document_id, filename, amount, at_stake, holds[] } }."
3444
+ ].join("\n");
3445
+ function handleIssues2(getToken, baseUrl) {
3446
+ return runTool(() => apiJson(getToken, baseUrl, "GET", "/v1/ap/issues"));
3447
+ }
3448
+ var CONFIG_DESCRIPTION = [
3449
+ "Read the AP configuration: which captured document kinds are bills, the contract register used for entity and cost centre, entities with their system and NetSuite subsidiary, the NetSuite mapping (accounts, departments, terms, currencies, vendors).",
3450
+ "USE WHEN: before changing the configuration, or to explain why an invoice maps the way it does.",
3451
+ "NOT FOR: invoices (talonic_ap_bills).",
3452
+ "",
3453
+ "ARGS: none.",
3454
+ "RETURNS: { config, saved, updated_at }."
3455
+ ].join("\n");
3456
+ function handleConfig(getToken, baseUrl) {
3457
+ return runTool(() => apiJson(getToken, baseUrl, "GET", "/v1/ap/config"));
3458
+ }
3459
+ var SAVE_CONFIG_DESCRIPTION = [
3460
+ "Replace the AP configuration with a complete new one (validated by the platform). Run with dry_run first.",
3461
+ "USE WHEN: setting up AP for a workspace or changing the NetSuite mapping.",
3462
+ "NOT FOR: partial edits; read talonic_ap_config, change it, and send the whole object.",
3463
+ "",
3464
+ "ARGS: `config` (the whole configuration object), `dry_run` (validate only).",
3465
+ "RETURNS: { config, saved }. A broken config returns the list of problems."
3466
+ ].join("\n");
3467
+ var saveConfigInputSchema = {
3468
+ config: z.record(z.string(), z.unknown()).describe("The whole AP configuration object (see talonic_ap_config)."),
3469
+ dry_run: z.boolean().optional().describe("Validate only; nothing is saved.")
3470
+ };
3471
+ function handleSaveConfig(getToken, baseUrl, args) {
3472
+ return runTool(
3473
+ () => apiJson(getToken, baseUrl, "PUT", "/v1/ap/config", {
3474
+ body: { config: args.config, dry_run: args.dry_run ?? false }
3475
+ })
3476
+ );
3477
+ }
3478
+ var PREVIEW_DESCRIPTION = [
3479
+ "The exact NetSuite vendor bill records a posting would send (REST Record API `vendorBill` bodies: entity, subsidiary, tranId, tranDate, dueDate, terms, currency, expense / item sublists, memo naming the source document and page), and the invoices left out with the reason. The NetSuite target is a simulated sandbox.",
3480
+ "USE WHEN: showing or checking what would be exported to NetSuite.",
3481
+ "NOT FOR: posting (talonic_ap_netsuite_post).",
3482
+ "",
3483
+ "ARGS: `include_held` (also send held invoices, on payment hold; duplicates are never sent).",
3484
+ "RETURNS: { adapter { mode: 'simulated_sandbox' }, records[] { bill_key, method, path, body }, skipped[], totals }."
3485
+ ].join("\n");
3486
+ var previewInputSchema = {
3487
+ include_held: z.boolean().optional().describe("Send held invoices too, with paymentHold true.")
3488
+ };
3489
+ function handlePreview(getToken, baseUrl, args) {
3490
+ return runTool(
3491
+ () => apiJson(getToken, baseUrl, "GET", "/v1/ap/netsuite/preview", {
3492
+ params: { include_held: args.include_held ? 1 : 0 }
3493
+ })
3494
+ );
3495
+ }
3496
+ var POST_DESCRIPTION = [
3497
+ "Post the vendor bills to the SIMULATED NetSuite sandbox: each record is answered as NetSuite's REST API answers a created record (204 with the new internal id), and the run's posting log is kept. Nothing is sent to any NetSuite account; say so when reporting the result.",
3498
+ "USE WHEN: the user asks to run the NetSuite export or a shadow posting.",
3499
+ "NOT FOR: looking at the payload (talonic_ap_netsuite_preview).",
3500
+ "",
3501
+ "ARGS: `include_held` (held invoices on payment hold), `dry_run` (answer without keeping the run), `limit`.",
3502
+ "RETURNS: { id, records, amount, results[] { bill_key, external_id, internal_id, status, location, payment_hold }, skipped[], log[] }."
3503
+ ].join("\n");
3504
+ var postInputSchema = {
3505
+ include_held: z.boolean().optional().describe("Send held invoices too, with paymentHold true."),
3506
+ dry_run: z.boolean().optional().describe("Do not keep the run."),
3507
+ limit: z.number().int().min(1).max(5e3).optional().describe("At most this many records.")
3508
+ };
3509
+ function handlePost(getToken, baseUrl, args) {
3510
+ return runTool(
3511
+ () => apiJson(getToken, baseUrl, "POST", "/v1/ap/netsuite/post", {
3512
+ body: {
3513
+ include_held: args.include_held ?? false,
3514
+ dry_run: args.dry_run ?? false,
3515
+ ...args.limit ? { limit: args.limit } : {}
3516
+ }
3517
+ })
3518
+ );
3519
+ }
3520
+ var RUNS_DESCRIPTION = [
3521
+ "Simulated NetSuite posting runs: the list, or one run with its internal ids and posting log.",
3522
+ "USE WHEN: checking what an earlier export posted.",
3523
+ "NOT FOR: posting (talonic_ap_netsuite_post).",
3524
+ "",
3525
+ "ARGS: `run_id` (one run; omit for the list).",
3526
+ "RETURNS: { data[] } or one run { results[], skipped[], log[] }."
3527
+ ].join("\n");
3528
+ var runsInputSchema = {
3529
+ run_id: z.string().uuid().optional().describe("One run (from the list).")
3530
+ };
3531
+ function handleRuns(getToken, baseUrl, args) {
3532
+ return runTool(
3533
+ () => apiJson(
3534
+ getToken,
3535
+ baseUrl,
3536
+ "GET",
3537
+ args.run_id ? `/v1/ap/netsuite/runs/${args.run_id}` : "/v1/ap/netsuite/runs"
3538
+ )
3539
+ );
3540
+ }
3541
+ function registerApTools(server, getToken, baseUrl) {
3542
+ const tools = [
3543
+ [
3544
+ "talonic_ap_overview",
3545
+ "AP totals",
3546
+ OVERVIEW_DESCRIPTION,
3547
+ {},
3548
+ readOnly2,
3549
+ () => handleOverview(getToken, baseUrl)
3550
+ ],
3551
+ [
3552
+ "talonic_ap_bills",
3553
+ "List AP invoices",
3554
+ BILLS_DESCRIPTION,
3555
+ billsInputSchema,
3556
+ readOnly2,
3557
+ (a) => handleBills(getToken, baseUrl, a)
3558
+ ],
3559
+ [
3560
+ "talonic_ap_issues",
3561
+ "Held AP invoices",
3562
+ ISSUES_DESCRIPTION2,
3563
+ {},
3564
+ readOnly2,
3565
+ () => handleIssues2(getToken, baseUrl)
3566
+ ],
3567
+ [
3568
+ "talonic_ap_config",
3569
+ "Read the AP configuration",
3570
+ CONFIG_DESCRIPTION,
3571
+ {},
3572
+ readOnly2,
3573
+ () => handleConfig(getToken, baseUrl)
3574
+ ],
3575
+ [
3576
+ "talonic_ap_save_config",
3577
+ "Save the AP configuration",
3578
+ SAVE_CONFIG_DESCRIPTION,
3579
+ saveConfigInputSchema,
3580
+ write2(true, true),
3581
+ (a) => handleSaveConfig(getToken, baseUrl, a)
3582
+ ],
3583
+ [
3584
+ "talonic_ap_netsuite_preview",
3585
+ "NetSuite vendor bill payload",
3586
+ PREVIEW_DESCRIPTION,
3587
+ previewInputSchema,
3588
+ readOnly2,
3589
+ (a) => handlePreview(getToken, baseUrl, a)
3590
+ ],
3591
+ [
3592
+ "talonic_ap_netsuite_post",
3593
+ "Post to the simulated NetSuite sandbox",
3594
+ POST_DESCRIPTION,
3595
+ postInputSchema,
3596
+ write2(true),
3597
+ (a) => handlePost(getToken, baseUrl, a)
3598
+ ],
3599
+ [
3600
+ "talonic_ap_netsuite_runs",
3601
+ "NetSuite posting runs",
3602
+ RUNS_DESCRIPTION,
3603
+ runsInputSchema,
3604
+ readOnly2,
3605
+ (a) => handleRuns(getToken, baseUrl, a)
3606
+ ]
3607
+ ];
3608
+ for (const [name, title, description, inputSchema11, annotations, handler] of tools) {
3609
+ server.registerTool(
3610
+ name,
3611
+ { title, description, inputSchema: inputSchema11, annotations: { title, ...annotations } },
3612
+ async (args) => handler(args)
3613
+ );
3614
+ }
3615
+ }
3386
3616
  var DEFAULT_BASE3 = "https://api.talonic.com";
3387
3617
  var TASK_STATUSES = ["available", "claimed", "submitted", "timed_out", "cancelled"];
3388
3618
  var taskId = z.string().uuid().describe("Agent task UUID.");
@@ -4897,7 +5127,7 @@ function registerAskTools(server, getToken, baseUrl) {
4897
5127
 
4898
5128
  // package.json
4899
5129
  var package_default = {
4900
- version: "0.1.82"};
5130
+ version: "0.1.83"};
4901
5131
 
4902
5132
  // src/version.ts
4903
5133
  var VERSION = package_default.version;
@@ -5053,6 +5283,9 @@ function createServer(options) {
5053
5283
  if (options.includeContractsTools) {
5054
5284
  registerContractsTools(server, rawToken, baseUrl);
5055
5285
  }
5286
+ if (options.includeApTools) {
5287
+ registerApTools(server, rawToken, baseUrl);
5288
+ }
5056
5289
  registerSchemasResource(server, getTalonic);
5057
5290
  registerWebhooksResource(server, rawToken, baseUrl);
5058
5291
  registerWidgets(server);