@talonic/mcp 0.1.81 → 0.1.82

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/CHANGELOG.md CHANGED
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  > The publish workflow assigns the version on release; after the push that publishes it, promote this block to `## [<version>] - <date>` (the changelog lock accepts the current package version living here until then).
11
11
 
12
+ ### Added
13
+
14
+ - **`talonic_contracts_*` tools (13), registered where the platform serves the Contracts app.** Fill and clean the Contracts register over `/v1/contracts/*`: `register`, `contract`, `issues` (cleaning worklist with the documents concerned), `upcoming`, `import_candidates`, `import` (by ids, or every unread candidate with filters, `limit` and `dry_run`), `import_status`, `update_document` (role, exclude, re-key, remove), `merge`, `reread`, `decide`, `key_date`, `set_term` (value plus verbatim quote, verified by the platform). Probe-gated like the growth tools (`GET /v1/contracts/import/status` → 200), so they never appear where they would 404. `apiJson` gains `PUT`.
15
+
16
+ ## [0.1.81] - 2026-09-24
17
+
12
18
  ### Fixed
13
19
 
14
20
  - **`annotations.title` on every public tool.** The six Field Registry / agent-tool registrations (`talonic_list_fields`, `talonic_get_field`, `talonic_field_values`, `talonic_find_data`, `talonic_list_agent_tools`, `talonic_invoke_agent_tool`) set only the top-level `title`; Anthropic's Connectors Directory portal reads `annotations.title` and flagged them ("Missing title annotation"). All 36 tools now carry it, locked by `tests/widgets/tool-annotations.test.ts`.
@@ -2974,6 +2974,455 @@ function registerGrowthTools(server, getToken, baseUrl) {
2974
2974
  async (args) => handleGrowthToolsUsage(getToken, baseUrl, args)
2975
2975
  );
2976
2976
  }
2977
+ var contractIdArg = z.string().uuid().describe("Contract id (from talonic_contracts_register or talonic_contracts_issues).");
2978
+ var rowIdArg = z.string().uuid().describe(
2979
+ "Document row id on the contract: `documents[].id` from talonic_contracts_contract (not the workspace document id)."
2980
+ );
2981
+ var readOnly = {
2982
+ readOnlyHint: true,
2983
+ destructiveHint: false,
2984
+ idempotentHint: true,
2985
+ openWorldHint: false
2986
+ };
2987
+ var write = (idempotent, destructive = false) => ({
2988
+ readOnlyHint: false,
2989
+ destructiveHint: destructive,
2990
+ idempotentHint: idempotent,
2991
+ openWorldHint: false
2992
+ });
2993
+ var ROLES = ["master", "amendment", "renewal", "termination", "price_sheet", "other"];
2994
+ var STATUSES = ["draft", "active", "expired", "terminated", "unknown"];
2995
+ var DECISIONS = ["terminated", "notice_sent", "renewal_declined", "active"];
2996
+ var TERMS = [
2997
+ "title",
2998
+ "counterparty",
2999
+ "our_party",
3000
+ "family",
3001
+ "site",
3002
+ "signed_date",
3003
+ "effective_date",
3004
+ "expiry_date",
3005
+ "initial_term_months",
3006
+ "auto_renewal",
3007
+ "renewal_term_months",
3008
+ "notice_days",
3009
+ "notice_months",
3010
+ "terminated_on",
3011
+ "annual_value",
3012
+ "currency",
3013
+ "escalation_pct",
3014
+ "escalation_date",
3015
+ "min_commitment",
3016
+ "cap_amount",
3017
+ "payment_terms_days",
3018
+ "governing_law",
3019
+ "is_draft"
3020
+ ];
3021
+ var REGISTER_DESCRIPTION = [
3022
+ "List the workspace's contracts: key, title, counterparty, status, start, end in force, notice deadline, document count, next open date, and what Contract Pricing and Money Found report per contract.",
3023
+ "USE WHEN: getting an overview, finding a contract by key/name, or counting by status.",
3024
+ "NOT FOR: one contract's terms and documents (talonic_contracts_contract); what needs cleaning (talonic_contracts_issues).",
3025
+ "",
3026
+ "ARGS: `query` (key, title or counterparty contains), `status`, `key` (exact).",
3027
+ "RETURNS: data[] { id, contract_key, title, counterparty, status, effective_date, expiry_date, notice_deadline, documents, next_date, links }."
3028
+ ].join("\n");
3029
+ var registerInputSchema = {
3030
+ query: z.string().optional().describe("Key, title or counterparty contains."),
3031
+ status: z.enum(STATUSES).optional().describe("Only contracts in this status."),
3032
+ key: z.string().optional().describe("Exact contract key, e.g. '1042460' or '3042-WLV'.")
3033
+ };
3034
+ function handleRegister(getToken, baseUrl, args) {
3035
+ return runTool(
3036
+ () => apiJson(getToken, baseUrl, "GET", "/v1/contracts", {
3037
+ params: { q: args.query, status: args.status, key: args.key }
3038
+ })
3039
+ );
3040
+ }
3041
+ var CONTRACT_DESCRIPTION = [
3042
+ "Read one contract in full: terms in force (each with the document and verbatim quote it rests on), documents in fold order with what each states (unverified values carry their `problem`), key dates, decisions and links to the other apps.",
3043
+ "USE WHEN: checking or cleaning a contract; you need document row ids for talonic_contracts_update_document.",
3044
+ "NOT FOR: the list of contracts (talonic_contracts_register).",
3045
+ "",
3046
+ "ARGS: `contract_id`.",
3047
+ "RETURNS: { contract, documents[] { id, document_id, filename, role, excluded, extract }, key_dates[], links, decision, history }."
3048
+ ].join("\n");
3049
+ var contractInputSchema = { contract_id: contractIdArg };
3050
+ function handleContract(getToken, baseUrl, args) {
3051
+ return runTool(() => apiJson(getToken, baseUrl, "GET", `/v1/contracts/${args.contract_id}`));
3052
+ }
3053
+ var ISSUES_DESCRIPTION = [
3054
+ "The cleaning worklist: contracts that look wrong and why. Codes: several_base_contracts (one key holds several contracts), printed_number_differs, several_counterparties, several_sites, ended_by_message (an email read as the termination), unread_documents, no_dates, unverified_terms.",
3055
+ "USE WHEN: after an import, to decide what to fix; again after fixing, to confirm it is clean.",
3056
+ "NOT FOR: contracts that are fine (talonic_contracts_register).",
3057
+ "",
3058
+ "ARGS: `code` (only contracts with this issue, optional).",
3059
+ "RETURNS: data[] { contract_id, contract_key, title, status, issues[] { code, detail, document_ids } }. document_ids are workspace document ids; match them to documents[].document_id in talonic_contracts_contract."
3060
+ ].join("\n");
3061
+ var issuesInputSchema = {
3062
+ code: z.enum([
3063
+ "several_base_contracts",
3064
+ "printed_number_differs",
3065
+ "several_counterparties",
3066
+ "several_sites",
3067
+ "ended_by_message",
3068
+ "unread_documents",
3069
+ "no_dates",
3070
+ "unverified_terms"
3071
+ ]).optional().describe("Only contracts with this issue.")
3072
+ };
3073
+ async function handleIssues(getToken, baseUrl, args) {
3074
+ return runTool(async () => {
3075
+ const res = await apiJson(
3076
+ getToken,
3077
+ baseUrl,
3078
+ "GET",
3079
+ "/v1/contracts/issues"
3080
+ );
3081
+ return args.code ? { data: res.data.filter((c) => c.issues.some((i) => i.code === args.code)) } : res;
3082
+ });
3083
+ }
3084
+ var UPCOMING_DESCRIPTION = [
3085
+ "Open key dates across all contracts, soonest first: notice deadlines, ends of term, renewals, price changes, terminations, dated obligations. Dates marked handled are left out.",
3086
+ "USE WHEN: what needs someone soon; preparing a renewal or notice decision.",
3087
+ "NOT FOR: one contract's dates (talonic_contracts_contract).",
3088
+ "",
3089
+ "ARGS: `days` (horizon, default the workspace's alert horizon, 90).",
3090
+ "RETURNS: data[] { id, contract_id, contract_key, title, kind, due_date, days_left, label, quote }."
3091
+ ].join("\n");
3092
+ var upcomingInputSchema = {
3093
+ days: z.number().int().min(1).max(3650).optional().describe("Days ahead.")
3094
+ };
3095
+ function handleUpcoming(getToken, baseUrl, args) {
3096
+ return runTool(
3097
+ () => apiJson(getToken, baseUrl, "GET", "/v1/contracts/upcoming", { params: { days: args.days } })
3098
+ );
3099
+ }
3100
+ var CANDIDATES_DESCRIPTION = [
3101
+ "Contract documents whose terms have not been read yet, grouped by the contract key in their filename; keys Contract Pricing already models first.",
3102
+ "USE WHEN: choosing what to read, or checking how the documents will group before importing.",
3103
+ "NOT FOR: reading them (talonic_contracts_import).",
3104
+ "",
3105
+ "ARGS: `query` (filename contains).",
3106
+ "RETURNS: data[] { contract_key, in_price_baseline, documents[] { document_id, filename, import } }."
3107
+ ].join("\n");
3108
+ var candidatesInputSchema = { query: z.string().optional().describe("Filename contains.") };
3109
+ function handleCandidates(getToken, baseUrl, args) {
3110
+ return runTool(
3111
+ () => apiJson(getToken, baseUrl, "GET", "/v1/contracts/import/candidates", {
3112
+ params: { q: args.query }
3113
+ })
3114
+ );
3115
+ }
3116
+ var STATUS_DESCRIPTION = [
3117
+ "Where the read queue stands: counts by status (pending, running, done, failed) and the latest failures with their error.",
3118
+ "USE WHEN: after talonic_contracts_import, poll until pending and running are 0.",
3119
+ "NOT FOR: the contracts themselves (talonic_contracts_register).",
3120
+ "",
3121
+ "ARGS: none.",
3122
+ "RETURNS: { counts, failed[] { document_id, filename, error, attempts } }."
3123
+ ].join("\n");
3124
+ function handleImportStatus(getToken, baseUrl) {
3125
+ return runTool(() => apiJson(getToken, baseUrl, "GET", "/v1/contracts/import/status"));
3126
+ }
3127
+ var IMPORT_DESCRIPTION = [
3128
+ "Queue contract documents to be read; the platform reads them in the background (one model call each) and files each under its contract.",
3129
+ "USE WHEN: filling the app. `all: true` queues every unread candidate (narrow with query, contract_keys, only_priced; `limit` for a first batch); `document_ids` queues exactly those. Always run `all` with `dry_run: true` first and say how many documents it will read.",
3130
+ "NOT FOR: reading a contract again after cleaning (talonic_contracts_reread).",
3131
+ "",
3132
+ "ARGS: `all` or `document_ids`; with all: `query`, `contract_keys`, `only_priced`, `limit`, `dry_run`; with document_ids: `force` (read again even if read).",
3133
+ "RETURNS: all \u2192 { dry_run, contracts, documents, queued, skipped }; document_ids \u2192 { queued, skipped }. Then poll talonic_contracts_import_status."
3134
+ ].join("\n");
3135
+ var importInputSchema = {
3136
+ all: z.boolean().optional().describe("Queue every unread candidate (with the filters below)."),
3137
+ document_ids: z.array(z.string().uuid()).min(1).max(500).optional().describe("Workspace document ids to read."),
3138
+ query: z.string().optional().describe("all: only filenames containing this."),
3139
+ contract_keys: z.array(z.string()).max(2e3).optional().describe("all: only these contract keys."),
3140
+ only_priced: z.boolean().optional().describe("all: only keys Contract Pricing already models."),
3141
+ limit: z.number().int().min(1).max(2e4).optional().describe("all: queue at most this many documents."),
3142
+ dry_run: z.boolean().optional().describe("all: count only, queue nothing."),
3143
+ force: z.boolean().optional().describe("document_ids: read again even when already read.")
3144
+ };
3145
+ function handleImport(getToken, baseUrl, args) {
3146
+ if (!!args.all === !!args.document_ids?.length)
3147
+ return Promise.resolve(validationError("Pass either `all: true` or `document_ids`, not both."));
3148
+ if (args.all) {
3149
+ const { query, contract_keys, only_priced, limit: limit2, dry_run } = args;
3150
+ return runTool(
3151
+ () => apiJson(getToken, baseUrl, "POST", "/v1/contracts/import/all", {
3152
+ body: { query, contract_keys, only_priced, limit: limit2, dry_run }
3153
+ })
3154
+ );
3155
+ }
3156
+ return runTool(
3157
+ () => apiJson(getToken, baseUrl, "POST", "/v1/contracts/import", {
3158
+ body: { document_ids: args.document_ids, force: args.force }
3159
+ })
3160
+ );
3161
+ }
3162
+ var UPDATE_DOCUMENT_DESCRIPTION = [
3163
+ "Fix one document of a contract: set what it is (`role`), leave it out of the fold (`excluded`), file it under another contract key (`contract_key`; a new key creates that contract, null returns it to its derived key), or take it off the contract (`remove`).",
3164
+ "USE WHEN: cleaning \u2014 a key holds several contracts (move each set to its own key, e.g. '1042460-WLV / An der Walze 12'), an email is read as a termination (exclude it), an amendment is read as a base contract (role).",
3165
+ "NOT FOR: moving all documents of a contract at once (talonic_contracts_merge).",
3166
+ "",
3167
+ "ARGS: `contract_id`, `document_row_id`, and one or more of `role`, `excluded`, `contract_key`; or `remove: true` alone.",
3168
+ "RETURNS: the contract the document ends up in, recomputed. A hand-set key and role survive re-reading."
3169
+ ].join("\n");
3170
+ var updateDocumentInputSchema = {
3171
+ contract_id: contractIdArg,
3172
+ document_row_id: rowIdArg,
3173
+ role: z.enum(ROLES).optional().describe("What the document is."),
3174
+ excluded: z.boolean().optional().describe("true = leave it out of the contract's terms."),
3175
+ contract_key: z.string().max(64).nullable().optional().describe("File under this key; null = back to the derived key."),
3176
+ remove: z.boolean().optional().describe("Take the document off the contract (the document stays in the workspace).")
3177
+ };
3178
+ function handleUpdateDocument(getToken, baseUrl, args) {
3179
+ const path = `/v1/contracts/${args.contract_id}/documents/${args.document_row_id}`;
3180
+ if (args.remove) {
3181
+ if (args.role !== void 0 || args.excluded !== void 0 || args.contract_key !== void 0)
3182
+ return Promise.resolve(validationError("`remove` goes alone."));
3183
+ return runTool(() => apiJson(getToken, baseUrl, "DELETE", path));
3184
+ }
3185
+ if (args.role === void 0 && args.excluded === void 0 && args.contract_key === void 0)
3186
+ return Promise.resolve(
3187
+ validationError("Nothing to change: pass role, excluded, contract_key or remove.")
3188
+ );
3189
+ return runTool(
3190
+ () => apiJson(getToken, baseUrl, "PUT", path, {
3191
+ body: { role: args.role, excluded: args.excluded, contract_key: args.contract_key }
3192
+ })
3193
+ );
3194
+ }
3195
+ var MERGE_DESCRIPTION = [
3196
+ "Move every document of one contract under another key (the same contract read under two keys, e.g. '1042460' and '1042460-WLV'). The emptied contract disappears.",
3197
+ "USE WHEN: two register rows are the same contract.",
3198
+ "NOT FOR: moving single documents (talonic_contracts_update_document).",
3199
+ "",
3200
+ "ARGS: `contract_id` (the one to empty), `into_key`.",
3201
+ "RETURNS: { moved, contract } \u2014 the contract under into_key, recomputed."
3202
+ ].join("\n");
3203
+ var mergeInputSchema = {
3204
+ contract_id: contractIdArg,
3205
+ into_key: z.string().min(1).max(64).describe("The key to move everything under.")
3206
+ };
3207
+ function handleMerge(getToken, baseUrl, args) {
3208
+ return runTool(
3209
+ () => apiJson(getToken, baseUrl, "POST", `/v1/contracts/${args.contract_id}/merge`, {
3210
+ body: { into_key: args.into_key }
3211
+ })
3212
+ );
3213
+ }
3214
+ var REREAD_DESCRIPTION = [
3215
+ "Read a contract's documents again (or one of them), e.g. after cleaning or when values did not verify. One model call per document; hand-set values and roles are kept.",
3216
+ "USE WHEN: a contract's terms look wrong and the documents are right.",
3217
+ "NOT FOR: documents never read (talonic_contracts_import).",
3218
+ "",
3219
+ "ARGS: `contract_id`, `document_row_id` (optional, all when omitted).",
3220
+ "RETURNS: { queued, skipped }. Then poll talonic_contracts_import_status."
3221
+ ].join("\n");
3222
+ var rereadInputSchema = {
3223
+ contract_id: contractIdArg,
3224
+ document_row_id: rowIdArg.optional()
3225
+ };
3226
+ function handleReread(getToken, baseUrl, args) {
3227
+ return runTool(
3228
+ () => apiJson(getToken, baseUrl, "POST", `/v1/contracts/${args.contract_id}/reread`, {
3229
+ body: args.document_row_id ? { document_row_id: args.document_row_id } : {}
3230
+ })
3231
+ );
3232
+ }
3233
+ var DECIDE_DESCRIPTION = [
3234
+ "Record a decision on a contract: terminated, notice_sent, renewal_declined, or active (withdraws the earlier one). Recorded as made through the API key, with your note; the contract's status, end and key dates follow.",
3235
+ "USE WHEN: the user states the decision or it is confirmed by a document they point to. Never infer a termination on your own.",
3236
+ "NOT FOR: a termination letter already in the documents (it is read as a fact; check talonic_contracts_contract).",
3237
+ "",
3238
+ "ARGS: `contract_id`, `state`, `note` (say where the decision comes from).",
3239
+ "RETURNS: the contract, recomputed."
3240
+ ].join("\n");
3241
+ var decideInputSchema = {
3242
+ contract_id: contractIdArg,
3243
+ state: z.enum(DECISIONS),
3244
+ note: z.string().max(2e3).optional().describe("Source of the decision, e.g. 'K\xFCndigungsschreiben vom 12.01.2026'.")
3245
+ };
3246
+ function handleDecide(getToken, baseUrl, args) {
3247
+ return runTool(
3248
+ () => apiJson(getToken, baseUrl, "POST", `/v1/contracts/${args.contract_id}/decision`, {
3249
+ body: { state: args.state, note: args.note }
3250
+ })
3251
+ );
3252
+ }
3253
+ var KEY_DATE_DESCRIPTION = [
3254
+ "Mark a key date handled (or open again), e.g. a notice deadline someone has dealt with. Handled dates leave the upcoming list and raise no alert.",
3255
+ "USE WHEN: the user confirms a date is taken care of.",
3256
+ "NOT FOR: changing the date itself (it follows the documents).",
3257
+ "",
3258
+ "ARGS: `key_date_id` (key_dates[].id from talonic_contracts_contract or id from talonic_contracts_upcoming), `handled`, `note`.",
3259
+ "RETURNS: { id, handled }."
3260
+ ].join("\n");
3261
+ var keyDateInputSchema = {
3262
+ key_date_id: z.string().uuid(),
3263
+ handled: z.boolean(),
3264
+ note: z.string().max(2e3).optional()
3265
+ };
3266
+ function handleKeyDate(getToken, baseUrl, args) {
3267
+ return runTool(
3268
+ () => apiJson(getToken, baseUrl, "POST", `/v1/contracts/key-dates/${args.key_date_id}`, {
3269
+ body: { handled: args.handled, note: args.note }
3270
+ })
3271
+ );
3272
+ }
3273
+ var SET_TERM_DESCRIPTION = [
3274
+ "Set one term on one document by hand, with the passage that states it copied verbatim from that document. The platform saves it only when the quote occurs in the document and prints the value.",
3275
+ "USE WHEN: a term was missed or read wrong and you have the exact passage (talonic_get_document or talonic_search to find it).",
3276
+ "NOT FOR: guessing a value; decisions (talonic_contracts_decide).",
3277
+ "",
3278
+ "ARGS: `contract_id`, `document_row_id`, `field`, `value` (ISO date for dates; fraction for escalation_pct; months for *_months), `quote`.",
3279
+ "RETURNS: the contract, recomputed; an error naming the problem when the quote does not verify."
3280
+ ].join("\n");
3281
+ var setTermInputSchema = {
3282
+ contract_id: contractIdArg,
3283
+ document_row_id: rowIdArg,
3284
+ field: z.enum(TERMS),
3285
+ value: z.union([z.string(), z.number(), z.boolean()]),
3286
+ quote: z.string().min(3).max(2e3).describe("Copied character for character from the document.")
3287
+ };
3288
+ function handleSetTerm(getToken, baseUrl, args) {
3289
+ const { field, value, quote } = args;
3290
+ return runTool(
3291
+ () => apiJson(
3292
+ getToken,
3293
+ baseUrl,
3294
+ "POST",
3295
+ `/v1/contracts/${args.contract_id}/documents/${args.document_row_id}/terms`,
3296
+ { body: { field, value, quote } }
3297
+ )
3298
+ );
3299
+ }
3300
+ async function probeContractsAccess(token, baseUrl) {
3301
+ try {
3302
+ const res = await fetch(buildUrl(baseUrl, "/v1/contracts/import/status"), {
3303
+ headers: { Authorization: `Bearer ${token}`, Accept: "application/json" },
3304
+ signal: AbortSignal.timeout(5e3)
3305
+ });
3306
+ return res.ok;
3307
+ } catch {
3308
+ return false;
3309
+ }
3310
+ }
3311
+ function registerContractsTools(server, getToken, baseUrl) {
3312
+ const tools = [
3313
+ [
3314
+ "talonic_contracts_register",
3315
+ "List contracts",
3316
+ REGISTER_DESCRIPTION,
3317
+ registerInputSchema,
3318
+ readOnly,
3319
+ (a) => handleRegister(getToken, baseUrl, a)
3320
+ ],
3321
+ [
3322
+ "talonic_contracts_contract",
3323
+ "Read one contract",
3324
+ CONTRACT_DESCRIPTION,
3325
+ contractInputSchema,
3326
+ readOnly,
3327
+ (a) => handleContract(getToken, baseUrl, a)
3328
+ ],
3329
+ [
3330
+ "talonic_contracts_issues",
3331
+ "Contracts to clean",
3332
+ ISSUES_DESCRIPTION,
3333
+ issuesInputSchema,
3334
+ readOnly,
3335
+ (a) => handleIssues(getToken, baseUrl, a)
3336
+ ],
3337
+ [
3338
+ "talonic_contracts_upcoming",
3339
+ "Upcoming contract dates",
3340
+ UPCOMING_DESCRIPTION,
3341
+ upcomingInputSchema,
3342
+ readOnly,
3343
+ (a) => handleUpcoming(getToken, baseUrl, a)
3344
+ ],
3345
+ [
3346
+ "talonic_contracts_import_candidates",
3347
+ "Unread contract documents",
3348
+ CANDIDATES_DESCRIPTION,
3349
+ candidatesInputSchema,
3350
+ readOnly,
3351
+ (a) => handleCandidates(getToken, baseUrl, a)
3352
+ ],
3353
+ [
3354
+ "talonic_contracts_import_status",
3355
+ "Contract read queue",
3356
+ STATUS_DESCRIPTION,
3357
+ {},
3358
+ readOnly,
3359
+ () => handleImportStatus(getToken, baseUrl)
3360
+ ],
3361
+ [
3362
+ "talonic_contracts_import",
3363
+ "Read contract documents",
3364
+ IMPORT_DESCRIPTION,
3365
+ importInputSchema,
3366
+ write(true),
3367
+ (a) => handleImport(getToken, baseUrl, a)
3368
+ ],
3369
+ [
3370
+ "talonic_contracts_update_document",
3371
+ "Fix a contract document",
3372
+ UPDATE_DOCUMENT_DESCRIPTION,
3373
+ updateDocumentInputSchema,
3374
+ write(false, true),
3375
+ (a) => handleUpdateDocument(getToken, baseUrl, a)
3376
+ ],
3377
+ [
3378
+ "talonic_contracts_merge",
3379
+ "Merge two contracts",
3380
+ MERGE_DESCRIPTION,
3381
+ mergeInputSchema,
3382
+ write(true, true),
3383
+ (a) => handleMerge(getToken, baseUrl, a)
3384
+ ],
3385
+ [
3386
+ "talonic_contracts_reread",
3387
+ "Read a contract again",
3388
+ REREAD_DESCRIPTION,
3389
+ rereadInputSchema,
3390
+ write(true),
3391
+ (a) => handleReread(getToken, baseUrl, a)
3392
+ ],
3393
+ [
3394
+ "talonic_contracts_decide",
3395
+ "Record a contract decision",
3396
+ DECIDE_DESCRIPTION,
3397
+ decideInputSchema,
3398
+ write(true),
3399
+ (a) => handleDecide(getToken, baseUrl, a)
3400
+ ],
3401
+ [
3402
+ "talonic_contracts_key_date",
3403
+ "Mark a key date handled",
3404
+ KEY_DATE_DESCRIPTION,
3405
+ keyDateInputSchema,
3406
+ write(true),
3407
+ (a) => handleKeyDate(getToken, baseUrl, a)
3408
+ ],
3409
+ [
3410
+ "talonic_contracts_set_term",
3411
+ "Set a contract term with its quote",
3412
+ SET_TERM_DESCRIPTION,
3413
+ setTermInputSchema,
3414
+ write(true),
3415
+ (a) => handleSetTerm(getToken, baseUrl, a)
3416
+ ]
3417
+ ];
3418
+ for (const [name, title, description, inputSchema11, annotations, handler] of tools) {
3419
+ server.registerTool(
3420
+ name,
3421
+ { title, description, inputSchema: inputSchema11, annotations: { title, ...annotations } },
3422
+ async (args) => handler(args)
3423
+ );
3424
+ }
3425
+ }
2977
3426
  var DEFAULT_BASE3 = "https://api.talonic.com";
2978
3427
  var TASK_STATUSES = ["available", "claimed", "submitted", "timed_out", "cancelled"];
2979
3428
  var taskId = z.string().uuid().describe("Agent task UUID.");
@@ -4511,7 +4960,7 @@ function registerAskTools(server, getToken, baseUrl) {
4511
4960
 
4512
4961
  // package.json
4513
4962
  var package_default = {
4514
- version: "0.1.81"};
4963
+ version: "0.1.82"};
4515
4964
 
4516
4965
  // src/version.ts
4517
4966
  var VERSION = package_default.version;
@@ -4664,6 +5113,9 @@ function createServer(options) {
4664
5113
  if (options.includeAdminAgentTaskTools) {
4665
5114
  registerAdminAgentTaskTools(server, rawToken, baseUrl);
4666
5115
  }
5116
+ if (options.includeContractsTools) {
5117
+ registerContractsTools(server, rawToken, baseUrl);
5118
+ }
4667
5119
  registerSchemasResource(server, getTalonic);
4668
5120
  registerWebhooksResource(server, rawToken, baseUrl);
4669
5121
  registerWidgets(server);
@@ -4697,6 +5149,15 @@ var FAVICON_BYTES = Buffer.from(FAVICON_BASE64, "base64");
4697
5149
 
4698
5150
  // src/http-server.ts
4699
5151
  var PORT = Number(process.env["PORT"] ?? 3e3);
5152
+ var contractsProbeCache = /* @__PURE__ */ new Map();
5153
+ async function contractsAccessCached(token, probe = (t) => probeContractsAccess(t, process.env["TALONIC_BASE_URL"]), now = Date.now) {
5154
+ const hit = contractsProbeCache.get(token);
5155
+ if (hit && hit.expiresAt > now()) return hit.ok;
5156
+ const ok = await probe(token);
5157
+ if (contractsProbeCache.size >= 1e3) contractsProbeCache.clear();
5158
+ contractsProbeCache.set(token, { ok, expiresAt: now() + GROWTH_PROBE_TTL_MS });
5159
+ return ok;
5160
+ }
4700
5161
  var GROWTH_PROBE_TTL_MS = 5 * 60 * 1e3;
4701
5162
  var growthProbeCache = /* @__PURE__ */ new Map();
4702
5163
  async function growthAccessCached(token, probe = probeGrowthAccess, now = Date.now) {
@@ -4940,7 +5401,7 @@ function createRequestHandler(options = {}) {
4940
5401
  return;
4941
5402
  }
4942
5403
  const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: void 0 });
4943
- const [includeGrowthTools, includeAdminAgentTaskTools] = await Promise.all([
5404
+ const [includeGrowthTools, includeAdminAgentTaskTools, includeContractsTools] = await Promise.all([
4944
5405
  (options.growthAccess ?? ((currentToken) => growthAccessCached(
4945
5406
  currentToken,
4946
5407
  (candidate) => probeGrowthAccess(candidate, process.env["TALONIC_BASE_URL"])
@@ -4948,12 +5409,14 @@ function createRequestHandler(options = {}) {
4948
5409
  (options.adminAgentTaskAccess ?? ((currentToken) => adminAgentTaskAccessCached(
4949
5410
  currentToken,
4950
5411
  (candidate) => probeAgentTaskAdminAccess(candidate, process.env["TALONIC_BASE_URL"])
4951
- )))(token)
5412
+ )))(token),
5413
+ (options.contractsAccess ?? ((currentToken) => contractsAccessCached(currentToken)))(token)
4952
5414
  ]);
4953
5415
  const mcpServer = createServer({
4954
5416
  tokenProvider: () => token,
4955
5417
  includeGrowthTools,
4956
5418
  includeAdminAgentTaskTools,
5419
+ includeContractsTools,
4957
5420
  ...process.env["TALONIC_BASE_URL"] ? { baseUrl: process.env["TALONIC_BASE_URL"] } : {},
4958
5421
  // Listing UX only: an OAuth token that visibly lacks apps:decide gets
4959
5422
  // the decision-task tools marked non-invocable. The platform decides.
@@ -4985,6 +5448,6 @@ if (isDirectInvocation()) {
4985
5448
  });
4986
5449
  }
4987
5450
 
4988
- export { adminAgentTaskAccessCached, createRequestHandler, growthAccessCached };
5451
+ export { adminAgentTaskAccessCached, contractsAccessCached, createRequestHandler, growthAccessCached };
4989
5452
  //# sourceMappingURL=http-server.js.map
4990
5453
  //# sourceMappingURL=http-server.js.map