@talonic/mcp 0.1.24 → 0.1.25

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
@@ -7,6 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+
12
+ - **`talonic_get_balance`** tool. Wraps `GET /v1/credits/balance` from the API and returns the enriched balance (`balance_credits`, `balance_eur`, `burn_rate_30d_credits`, `projected_runway_days`, `tier`, `tier_resets_at`). Lets agents make budget-aware decisions before kicking off large batches. Tool count goes 7 → 8.
13
+ - **`cost` field on `talonic_extract` and `talonic_to_markdown` outputSchemas.** Surfaces the per-call cost (`costCredits`, `costEur`), post-call balance (`balanceCredits`), and the registry-vs-AI cell-resolution split (`cellsResolvedRegistry`, `cellsResolvedAi`). Parsed by `@talonic/node@0.1.10` from the API's `X-Talonic-Cost-*` and `X-Talonic-Balance-*` response headers and threaded through the SDK's `WithRateLimit<T>` wrapper. `null` on the `talonic_to_markdown` `document_id` path because no extract call runs there.
14
+
15
+ ### Fixed
16
+
17
+ - Three QA-reported MCP `-32602 Output validation error` failures, all with the same shape: outputSchema declared a non-null string where the API legitimately returns `null`. Fixed and locked in with regression tests.
18
+ - `talonic_list_schemas` and `talonic_save_schema`: `data[].description` / `description` accept `null`.
19
+ - `talonic_extract` and `talonic_get_document`: `document.mime_type` / `mime_type` accept `null`.
20
+ - `talonic_search`: `fields[].id` accepts `null` (set by the API for "schema-only" field entries that have not yet been materialized into the field-registry index).
21
+ - Hosted MCP root discovery `docs` URL was advertising `https://docs.talonic.com` (not a live subdomain). Now points at `https://talonic.com/docs/mcp`.
22
+ - `talonic_to_markdown` description now mirrors the Claude.ai parameter-cap warning from `talonic_extract` so chat clients and Claude.ai connector users get consistent guidance on `file_data`.
23
+ - Symlink test in `tests/server-symlink.test.ts` now skips with a console warning when `dist/server.js` is older than `package.json` (avoids confusing "expected '0.1.x' to contain '0.1.y'" failures during local dev).
24
+
25
+ ### Changed
26
+
27
+ - Hosted MCP (`mcp.talonic.com`) is now token-rotation aware. The bearer token is extracted on every incoming MCP request and the SDK is rebuilt per request when the token changes; previously the credential was captured at session-init time and reused. Required for OAuth 2.1 access-token rotation across requests in the same session.
28
+ - `WWW-Authenticate: Bearer resource_metadata="..."` header on 401 responses, per RFC 9728. Lets OAuth clients (Claude.ai connector, MCP Inspector) discover the authorization server.
29
+ - `/.well-known/oauth-protected-resource` endpoint on the hosted MCP per RFC 9728. Advertises `https://api.talonic.com` as the authorization server and the three scopes the connector actually exercises (`extract:write`, `documents:read`, `schemas:read`).
30
+ - All seven existing tool registrations now take a `() => Talonic` getter rather than a `Talonic` instance. Internal refactor; no consumer-visible change beyond the OAuth token-rotation behaviour above.
31
+
10
32
  ## [0.1.16] - 2026-05-05
11
33
 
12
34
  ### Added
package/README.md CHANGED
@@ -5,13 +5,13 @@ Official Talonic MCP server. Lets AI agents extract structured, schema-validated
5
5
  [![talonic-mcp MCP server](https://glama.ai/mcp/servers/talonicdev/talonic-mcp/badges/score.svg)](https://glama.ai/mcp/servers/talonicdev/talonic-mcp)
6
6
  [![smithery badge](https://smithery.ai/badge/talonic/talonic)](https://smithery.ai/servers/talonic/talonic)
7
7
 
8
- > **Status:** Listed on the [official MCP Registry](https://registry.modelcontextprotocol.io/) as `io.github.talonicdev/talonic-mcp`. Seven tools and one resource live: `talonic_extract`, `talonic_search`, `talonic_filter`, `talonic_get_document`, `talonic_to_markdown`, `talonic_list_schemas`, `talonic_save_schema`, plus the `talonic://schemas` resource. Verified end-to-end against production.
8
+ > **Status:** Listed on the [official MCP Registry](https://registry.modelcontextprotocol.io/) as `io.github.talonicdev/talonic-mcp`. Eight tools and two resources live: `talonic_extract`, `talonic_search`, `talonic_filter`, `talonic_get_document`, `talonic_to_markdown`, `talonic_list_schemas`, `talonic_save_schema`, `talonic_get_balance`, plus the `talonic://schemas` and `talonic://webhooks/reference` resources. Verified end-to-end against production.
9
9
 
10
10
  ## Why an agent should use this
11
11
 
12
12
  When an agent needs to pull structured data out of a PDF, scan, image, or messy document, the usual approach is raw OCR plus an LLM call. Results are unreliable; tables get mangled, dates get misread, totals drift.
13
13
 
14
- With this MCP server installed, the agent has a `talonic_extract` tool that returns schema-validated JSON with per-field confidence scores, a detected document type, and stable IDs for follow-up calls. Six other tools cover the rest of the workflow: searching the workspace, filtering by extracted field values, fetching a document's metadata, getting OCR markdown, listing saved schemas, and saving new ones.
14
+ With this MCP server installed, the agent has a `talonic_extract` tool that returns schema-validated JSON with per-field confidence scores, a detected document type, and stable IDs for follow-up calls. Seven other tools cover the rest of the workflow: searching the workspace, filtering by extracted field values, fetching a document's metadata, getting OCR markdown, listing saved schemas, saving new ones, and reading the workspace credit balance for budget-aware behaviour.
15
15
 
16
16
  ## Get an API key (30 seconds)
17
17
 
@@ -61,7 +61,7 @@ Edit `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) o
61
61
  }
62
62
  ```
63
63
 
64
- Fully restart Claude Desktop (Cmd+Q on macOS, not just close the window). Talonic appears in the connected servers list with all seven tools.
64
+ Fully restart Claude Desktop (Cmd+Q on macOS, not just close the window). Talonic appears in the connected servers list with all eight tools.
65
65
 
66
66
  ### Cursor
67
67
 
@@ -111,7 +111,7 @@ Claude.ai's "Add custom connector" flow uses a remote MCP URL instead of a local
111
111
  1. Open https://claude.ai/settings/connectors.
112
112
  2. Click "Add custom connector".
113
113
  3. URL: `https://mcp.talonic.com/mcp?apiKey=tlnc_your_key_here`
114
- 4. Click Add. The 7 tools appear.
114
+ 4. Click Add. The 8 tools appear.
115
115
 
116
116
  Claude.ai's UI does not currently accept a custom `Authorization` header on connectors, so the API key is passed as a `?apiKey=...` query parameter. Less secure than the Bearer header pattern (the key is persisted in the connector store and may appear in Anthropic-side logs), so rotate the key in your Talonic dashboard if you remove the connector. IDE-style clients (Cursor, Cline, Continue) that accept custom headers should use the Bearer header instead.
117
117
 
@@ -121,13 +121,14 @@ Claude.ai's UI does not currently accept a custom `Authorization` header on conn
121
121
 
122
122
  Each tool's description is written for an LLM, with explicit USE WHEN / DO NOT USE WHEN sections. Agents pick the right tool reliably without further prompting. Briefly:
123
123
 
124
- - **`talonic_extract`**, status: stable. Extract structured, schema-validated data from a document. Inputs: one of `file_data` + `filename` (recommended for chat clients, see below), `file_path`, `file_url`, or `document_id`, plus a `schema` or `schema_id`. Returns JSON with `data`, per-field `confidence`, and document metadata. Schema is required; the MCP layer rejects schema-less calls.
124
+ - **`talonic_extract`**, status: stable. Extract structured, schema-validated data from a document. Inputs: one of `file_data` + `filename` (recommended for chat clients, see below), `file_path`, `file_url`, or `document_id`, plus a `schema` or `schema_id`. Returns JSON with `data`, per-field `confidence`, document metadata, and a `cost` block (per-call credits / EUR / post-call balance) parsed from the API's `X-Talonic-Cost-*` response headers. Schema is required; the MCP layer rejects schema-less calls.
125
125
  - **`talonic_search`**, status: stable. Omnisearch across documents, fields, sources, and schemas in the workspace. Use for conceptual or fuzzy queries.
126
126
  - **`talonic_filter`**, status: stable. Filter documents by extracted field values using composable conditions (`eq`, `gt`, `between`, `contains`, `is_empty`, etc.). Accepts canonical field names (e.g. `vendor.name`) which the Talonic API resolves to ids server-side, or UUIDs directly. `is_not_empty` is intentionally not exposed in v0.1; see [Known limitations](#known-limitations-v01).
127
127
  - **`talonic_get_document`**, status: stable. Fetch full metadata for a single document by id, including processing log and link URLs.
128
- - **`talonic_to_markdown`**, status: stable. Get OCR-converted markdown for a document. Accepts `document_id` (cheapest), `file_data` + `filename`, `file_path`, or `file_url`.
128
+ - **`talonic_to_markdown`**, status: stable. Get OCR-converted markdown for a document. Accepts `document_id` (cheapest), `file_data` + `filename`, `file_path`, or `file_url`. Returns the same `cost` block as `talonic_extract` when an extract step ran (i.e., on the file inputs); `null` on the `document_id` path.
129
129
  - **`talonic_list_schemas`**, status: stable. List all saved schemas with their definitions. Returns both UUID and SCH-XXXXXXXX short id; either is accepted by `talonic_extract`.
130
130
  - **`talonic_save_schema`**, status: stable. Save a schema definition to the workspace for reuse.
131
+ - **`talonic_get_balance`**, status: stable. Read the workspace credit balance, EUR value, 30-day burn rate, projected runway, tier, and next-tier-reset timestamp. Use it for budget-aware decisions before kicking off large batches.
131
132
 
132
133
  Two resources are also exposed for clients that browse them separately (Claude Desktop and Cowork render these in the UI):
133
134
  - `talonic://schemas`: saved-schemas list.
package/dist/content.js CHANGED
@@ -100,7 +100,7 @@ var sections = [
100
100
  },
101
101
  {
102
102
  type: "paragraph",
103
- text: "Seven tools and one resource: `talonic_extract`, `talonic_search`, `talonic_filter`, `talonic_get_document`, `talonic_to_markdown`, `talonic_list_schemas`, `talonic_save_schema`, plus the `talonic://schemas` resource."
103
+ text: "Eight tools and two resources: `talonic_extract`, `talonic_search`, `talonic_filter`, `talonic_get_document`, `talonic_to_markdown`, `talonic_list_schemas`, `talonic_save_schema`, `talonic_get_balance`, plus the `talonic://schemas` and `talonic://webhooks/reference` resources."
104
104
  },
105
105
  {
106
106
  type: "paragraph",
@@ -137,7 +137,7 @@ var sections = [
137
137
  },
138
138
  {
139
139
  type: "paragraph",
140
- text: "With this MCP server installed, the agent has a `talonic_extract` tool that returns schema-validated JSON with per-field confidence scores, a detected document type, and stable IDs for follow-up calls. Six other tools cover the rest of the workflow: searching the workspace, filtering by extracted field values, fetching a document's metadata, getting OCR markdown, listing saved schemas, and saving new ones."
140
+ text: "With this MCP server installed, the agent has a `talonic_extract` tool that returns schema-validated JSON with per-field confidence scores, a detected document type, and stable IDs for follow-up calls. Seven other tools cover the rest of the workflow: searching the workspace, filtering by extracted field values, fetching a document's metadata, getting OCR markdown, listing saved schemas, saving new ones, and reading the workspace credit balance for budget-aware behaviour."
141
141
  }
142
142
  ],
143
143
  related: [
@@ -393,7 +393,7 @@ var sections2 = [
393
393
  { type: "code", language: "json", code: MCP_CONFIG_SNIPPET },
394
394
  {
395
395
  type: "paragraph",
396
- text: "Fully restart Claude Desktop (Cmd+Q on macOS, not just close the window). Talonic appears in the connected servers list with all seven tools."
396
+ text: "Fully restart Claude Desktop (Cmd+Q on macOS, not just close the window). Talonic appears in the connected servers list with all eight tools."
397
397
  }
398
398
  ],
399
399
  related: [
@@ -1213,6 +1213,97 @@ Payment terms: Net 30`
1213
1213
  }
1214
1214
  ],
1215
1215
  mentions: ["save schema", "JSON Schema", "reuse"]
1216
+ },
1217
+ {
1218
+ slug: "talonic-get-balance",
1219
+ parentSlug: "tools",
1220
+ title: "talonic_get_balance",
1221
+ seoTitle: "talonic_get_balance Tool \u2014 Talonic MCP",
1222
+ description: "MCP tool that returns the current Talonic credit balance, EUR value, 30-day burn rate, projected runway, tier, and next monthly tier-reset timestamp.",
1223
+ content: [
1224
+ {
1225
+ type: "paragraph",
1226
+ text: "Returns the workspace's current credit balance, EUR value, 30-day burn rate, projected runway in days, API tier, and the timestamp of the next monthly tier reset. Use it for budget-aware behaviour: read the balance before scheduling a large batch, or after a sequence of extractions to track spend."
1227
+ },
1228
+ {
1229
+ type: "heading",
1230
+ level: 3,
1231
+ id: "use-when",
1232
+ text: "When to use"
1233
+ },
1234
+ {
1235
+ type: "list",
1236
+ items: [
1237
+ "The user asks how many credits or how much budget they have left.",
1238
+ "Before kicking off a large or expensive operation (batch extract, re-extract many documents), to confirm budget headroom.",
1239
+ "The user asks how long the balance will last at the current rate."
1240
+ ]
1241
+ },
1242
+ {
1243
+ type: "heading",
1244
+ level: 3,
1245
+ id: "do-not-use",
1246
+ text: "When not to use"
1247
+ },
1248
+ {
1249
+ type: "list",
1250
+ items: [
1251
+ "For per-call cost of a single extraction: that is already on every `talonic_extract` response under `cost`.",
1252
+ "To top up credits: route the user to the dashboard. Auto top-up is guarded by a separate scope and is intentionally not exposed at the MCP layer."
1253
+ ]
1254
+ },
1255
+ {
1256
+ type: "heading",
1257
+ level: 3,
1258
+ id: "response-shape",
1259
+ text: "Response shape"
1260
+ },
1261
+ {
1262
+ type: "list",
1263
+ items: [
1264
+ "`balance_credits`: current credit balance (integer).",
1265
+ "`balance_eur`: current balance expressed in EUR (rounded to two decimals).",
1266
+ "`burn_rate_30d_credits`: total credits consumed in the trailing 30 days.",
1267
+ "`projected_runway_days`: days of runway at the current 30-day average burn rate. `-1` indicates no consumption in the trailing window (cannot compute a meaningful runway).",
1268
+ "`tier`: API tier of the workspace (`free`, `pro`, `enterprise`, etc.).",
1269
+ "`tier_resets_at`: ISO 8601 timestamp of the next monthly tier reset."
1270
+ ]
1271
+ },
1272
+ {
1273
+ type: "code",
1274
+ language: "json",
1275
+ title: "Tool input",
1276
+ code: `{}`
1277
+ },
1278
+ {
1279
+ type: "code",
1280
+ language: "json",
1281
+ title: "Tool response",
1282
+ code: `{
1283
+ "balance_credits": 1888,
1284
+ "balance_eur": 9.44,
1285
+ "burn_rate_30d_credits": 360,
1286
+ "projected_runway_days": 157,
1287
+ "tier": "pro",
1288
+ "tier_resets_at": "2026-06-01T00:00:00.000Z"
1289
+ }`
1290
+ }
1291
+ ],
1292
+ related: [
1293
+ { label: "talonic_extract", slug: "talonic-extract" },
1294
+ { label: "Pricing", slug: "pricing" }
1295
+ ],
1296
+ faq: [
1297
+ {
1298
+ question: "How do I check my Talonic credit balance from an agent?",
1299
+ answer: "Call talonic_get_balance with no arguments. Returns balance_credits, balance_eur, burn_rate_30d_credits, projected_runway_days, tier, and tier_resets_at. Read-only; safe to call at any time."
1300
+ },
1301
+ {
1302
+ question: "What does projected_runway_days = -1 mean?",
1303
+ answer: "It means the workspace has had zero credit consumption in the trailing 30 days, so a meaningful runway projection cannot be computed. Treat -1 as 'unknown' rather than '0 days'."
1304
+ }
1305
+ ],
1306
+ mentions: ["credits", "balance", "EUR", "burn rate", "runway", "tier", "budget"]
1216
1307
  }
1217
1308
  ];
1218
1309