@casys/mcp-erpnext 3.0.4 → 3.1.0-beta.10

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Casys AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -9,6 +9,15 @@ English | [繁體中文](README.zh-TW.md)
9
9
  [![M8ven Score](https://m8ven.ai/badge/mcp/casys-ai-mcp-erpnext-1kev4k)](https://m8ven.ai/mcp/casys-ai-mcp-erpnext-1kev4k)
10
10
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
11
11
 
12
+ > [!IMPORTANT]
13
+ > **Installing the 3.1 beta:** for npm/Node use
14
+ > `npx -y @casys/mcp-erpnext@next`; for Deno use
15
+ > `deno run -A jsr:@casys/mcp-erpnext@^3.1.0-beta/server`. Both follow the
16
+ > current prerelease — JSR has no dist-tags, hence the range there. Exact
17
+ > versions are in the [CHANGELOG](CHANGELOG.md). The beta adds the generic
18
+ > document viewer and attachment workflows, so test it with the MCP host your
19
+ > users actually run before replacing a stable deployment.
20
+
12
21
  Let any MCP-compatible AI agent operate your [ERPNext](https://erpnext.com) /
13
22
  Frappe instance — documents, workflows, and interactive viewers inside the host
14
23
  (Claude Desktop, Claude Code, VS Code Copilot, or custom).
@@ -73,6 +82,14 @@ See the [CHANGELOG](CHANGELOG.md) for the full release history, or the
73
82
  [latest release](https://github.com/Casys-AI/mcp-erpnext/releases/latest) for
74
83
  the current version's highlights.
75
84
 
85
+ > **3.1 beta preview:** the beta keeps the 3.0 tool surface and adds a generic
86
+ > document viewer, child tables, document attachments, in-view navigation, and
87
+ > active context. **3.1.0-beta.10** hardens the read-only Buy capture and
88
+ > immutable recorded-session viewer introduced in beta.9. Features remain
89
+ > capability-gated by the MCP host. In particular, downloads require both
90
+ > proxied server tools and the MCP Apps `downloadFile` capability. Buy evidence
91
+ > does not purchase or qualify a live ERP.
92
+
76
93
  ## Documentation
77
94
 
78
95
  Organised by what you are doing, following [Diátaxis](https://diataxis.fr):
@@ -177,53 +194,106 @@ until it exists. See
177
194
 
178
195
  ## UI Viewers
179
196
 
180
- Seven interactive [MCP Apps](https://github.com/modelcontextprotocol/ext-apps)
197
+ Nine interactive [MCP Apps](https://github.com/modelcontextprotocol/ext-apps)
181
198
  viewers, registered as `ui://mcp-erpnext/{name}`:
182
199
 
183
- | Viewer | Description | Interactive Features |
184
- | ---------------- | ---------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
185
- | `doclist-viewer` | Generic document table with sort, filter, pagination, CSV export | Row click → inline detail panel with Submit/Cancel + sendMessage navigation. Chip filters for status columns. Max 6 columns, rest in detail panel. |
186
- | `invoice-viewer` | Sales/Purchase Invoice with parties, items, totals | Item click → stock balance + item info panel. Submit/Cancel/Payment actions. sendMessage to payment entries and customer invoices. |
187
- | `stock-viewer` | Stock balance table with color-coded qty badges | Row click → item info + recent movements. sendMessage to stock chart, item details, stock entries. |
188
- | `chart-viewer` | Universal chart renderer (12 types via Recharts) | Click bar/pie/line data points → sendMessage drill-down into underlying documents. |
189
- | `kanban-viewer` | Read-write kanban for Task, Opportunity, Issue | Drag-and-drop moves, inline edit (priority, progress, dates), sendMessage to Timesheets/Quotations/Related docs. |
190
- | `kpi-viewer` | Big number card with delta, sparkline, trend | Click number → sendMessage to exception list. Click sparkline → trend chart. |
191
- | `funnel-viewer` | Trapezoid sales funnel with conversion rates | Click stage → sendMessage to document list at that stage. Stage action buttons. |
192
-
193
- ### Cross-viewer navigation
194
-
195
- Viewers communicate via `app.sendMessage()` — clicking a button in one viewer
196
- injects a message into the conversation, which triggers the AI to call the right
197
- tool and open the appropriate viewer.
198
-
199
- The server auto-injects navigation metadata into tool results:
200
-
201
- - `_rowAction` — which tool to call when a row is clicked
202
- - `_sendMessageHints` — navigation buttons shown in detail panels (e.g.
203
- "Orders", "Invoices")
204
- - `_drillDown` / `_trendDrillDown` — sendMessage templates for KPI and chart
205
- click-through
200
+ | Viewer | Description | Interactive Features |
201
+ | --------------------- | ---------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
202
+ | `doc-viewer` | Generic ERPNext document with fields and child tables | Capability-gated attachments, typed navigation, guarded Submit/Cancel, and raw JSON fallback. |
203
+ | `doclist-viewer` | Generic document table with sort, filter, pagination, CSV export | Inline details, typed nested navigation, Submit/Cancel, and compact status filters. |
204
+ | `invoice-viewer` | Sales Orders, Sales Invoices, and Quotations with line totals | Item, stock, party, and payment navigation plus guarded Submit/Cancel actions. |
205
+ | `stock-viewer` | Stock balance table with color-coded qty badges | Item details, recent movements, stock charts, and stock-entry navigation. |
206
+ | `chart-viewer` | Universal chart renderer (12 types via Recharts) | Exact point/series navigation and active-context selection across simple and composed charts. |
207
+ | `kanban-viewer` | Read-write kanban for Task, Opportunity, Issue | Drag-and-drop, inline editing, serialized saves, and typed related-document navigation. |
208
+ | `kpi-viewer` | Big number card with delta, sparkline, trend | Number and trend navigation with bounded active-context selection. |
209
+ | `funnel-viewer` | Trapezoid sales funnel with conversion rates | Period-aware stage navigation and bounded active-context selection. |
210
+ | `buy-evidence-viewer` | Immutable sealed Buy evidence (recorded session only) | Complete, partial, unresolved, and unavailable projections; no live ERP refresh or mutation. |
211
+
212
+ ### Navigation and active context
213
+
214
+ Viewers progressively select the best interaction supported by the host:
215
+
216
+ - `serverTools` opens typed list, record, and chart targets inside the current
217
+ viewer through `app.callServerTool()`. Back and breadcrumb navigation restore
218
+ the state of each level.
219
+ - `downloadFile` lets the host confirm and save an attachment returned as a
220
+ bounded embedded resource. The viewer never opens an ERPNext file URL
221
+ directly.
222
+ - `updateModelContext` lets chart, KPI, and funnel selections join a bounded
223
+ active-context snapshot. The compact context chip keeps up to eight items and
224
+ lets users remove one item or clear them all. The snapshot contains selected
225
+ values, never hidden instructions for the model.
226
+ - `message.text` keeps `app.sendMessage()` as a conversational fallback when
227
+ direct navigation or context replacement is unavailable.
228
+ - Without these capabilities, local inspection remains available and unsupported
229
+ remote actions are omitted.
230
+ - The Buy evidence viewer is recorded-session only. It does not call server
231
+ tools, refresh live documents, or mutate ERP state.
232
+
233
+ The server supplies typed navigation metadata and the exact `_availableTools`
234
+ allowed for each viewer, so category-filtered deployments do not expose tools
235
+ that are not loaded.
206
236
 
207
237
  ### Refresh model
208
238
 
209
- All viewers carry a `refreshRequest` payload for safe revalidation via
210
- `app.callServerTool()`:
211
-
212
- - `kanban-viewer` revalidates after mutations and on focus
213
- - All other viewers support focus refresh + manual refresh button
239
+ Read-only viewers revalidate on focus and through their refresh control.
240
+ Mutations use an explicit read-only request to fetch committed state; a mutating
241
+ tool is never replayed automatically. Overlapping or stale responses are ignored
242
+ when a newer host payload or mutation has already won. A confirmed document
243
+ change marks every potentially derived snapshot in the current navigation stack
244
+ as stale; each marker is removed only when that surface has actually been read
245
+ again. Separate MCP Apps are not synchronized automatically in the 3.1 beta.
214
246
 
215
247
  ### Building UI viewers
216
248
 
217
249
  ```bash
218
250
  cd src/ui
219
- npm install
251
+ npm ci
220
252
  node build-all.mjs
221
253
  ```
222
254
 
255
+ ## Buy evidence capture
256
+
257
+ **One** read-only tool and **one** recorded App. They do not purchase, create a
258
+ BOM/RFQ/PO, refresh live documents, replace generic ERP viewers, or qualify a
259
+ live ERPNext instance.
260
+
261
+ - Tool: `erpnext_buy_capture`. Closed DocTypes only (Item, BOM, Item Price,
262
+ Supplier Quotation, Supplier, Price List, UOM, Currency Exchange). Two
263
+ `skipCache` reads must agree on `modified` and the closed projection
264
+ fingerprint. Return is ephemeral canonical JSON + SHA-256 + byte count. The
265
+ caller cannot pass `sourceInstance`, URL, credentials, `capturedAt`, or a
266
+ digest. Digital Thread stores those bytes in its own CAS; this server does not
267
+ keep a second CAS.
268
+ - App: `io.casys.mcp-erpnext.buy-evidence` `3.1.0-beta.10`, resource
269
+ `ui://mcp-erpnext/buy-evidence-viewer` (`text/html;profile=mcp-app`), manifest
270
+ `ui://mcp-erpnext/buy-evidence-manifest` (`application/json`),
271
+ `acceptedActions` = `viewer.session.apply` only. Complete, partial,
272
+ unresolved, and unavailable projections stay labelled. No live DocViewer
273
+ refresh, mutation, or `app.callServerTool`. Session `anchor` is the sealed
274
+ Digital Thread artefact (`provenance.bundleRef`), not a hash of the displayed
275
+ projection.
276
+ - Schemas: `io.casys.mcp-erpnext.buy-source-capture/1.0`,
277
+ `io.casys.mcp-erpnext.buy-recorded-result/1.0`,
278
+ `io.casys.mcp-erpnext.buy-recorded-session/1.0`.
279
+ - The viewer is built with the other MCP Apps
280
+ (`cd src/ui && npm ci && node
281
+ build-all.mjs`). Published JSR/npm artifacts
282
+ include `src/ui/dist/` and the Buy TypeScript module; the HTML resource and
283
+ generated manifest are what a published installation serves.
284
+
285
+ Digital Thread owns configuration/seal (`buy-configuration/1.0`,
286
+ `buy-cost-bundle/1.0`, `buy.capture-configuration-cost@1`,
287
+ `buy.seal-configuration-cost@1`). A qualified
288
+ `commerce.read-erpnext-buy-source@1` binding is required before dispatch.
289
+
223
290
  ## Tools
224
291
 
225
- Each `_list` tool returns interactive results via the doclist-viewer with row
226
- click, inline detail, and cross-viewer navigation.
292
+ Record `_list` tools return interactive results via the doclist-viewer with row
293
+ click, inline detail, and cross-viewer navigation. The attachment-specific
294
+ `erpnext_file_list` tool does not render doclist-viewer. Generic and dedicated
295
+ document reads use `doc-viewer`, except Sales Order, Sales Invoice, and
296
+ Quotation, which retain the specialized invoice surface.
227
297
 
228
298
  - **Sales** — Customers, Sales Orders, Invoices, and Quotations with full CRUD,
229
299
  Submit, and Cancel.
@@ -238,27 +308,31 @@ click, inline detail, and cross-viewer navigation.
238
308
  - **Manufacturing** — BOMs, Work Orders, and Job Cards.
239
309
  - **CRM** — Leads, Opportunities, Contacts, and Campaigns.
240
310
  - **Assets** — Assets, Movements, Maintenance records, and Categories.
241
- - **Operations** — Generic CRUD, native assignment, file upload, and
242
- deny-by-default Frappe method calls (`erpnext_doc_*`, `erpnext_file_upload`,
243
- `erpnext_method_call`).
311
+ - **Operations** — Generic CRUD, native assignment, attachment listing, upload,
312
+ host-mediated download, and deny-by-default Frappe method calls
313
+ (`erpnext_doc_*`, `erpnext_file_*`, `erpnext_method_call`).
244
314
  - **Kanban** — Read-write boards for Task, Opportunity, and Issue with
245
315
  drag-and-drop.
246
316
  - **Analytics** — Charts (bar, area, treemap, radar, scatter, P&L…), KPIs with
247
317
  sparklines, and a sales funnel.
318
+ - **Buy** — Read-only sealed capture of closed commercial documents
319
+ (`erpnext_buy_capture`) and an immutable recorded-session evidence viewer. Not
320
+ a purchase, BOM/RFQ/PO, or live ERP qualification.
248
321
  - **Setup** — Company creation and assignable user listing.
249
322
 
250
323
  Full per-tool reference with parameters: [`docs/tools.md`](docs/tools.md).
251
324
 
252
325
  ## Environment Variables
253
326
 
254
- | Variable | Required | Description |
255
- | -------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- |
256
- | `ERPNEXT_URL` | Yes | ERPNext base URL — self-hosted (e.g. `http://localhost:8000`) or cloud (e.g. `https://mycompany.erpnext.com`) |
257
- | `ERPNEXT_API_KEY` | Yes | API Key from User Settings |
258
- | `ERPNEXT_API_SECRET` | Yes | API Secret from User Settings |
259
- | `ERPNEXT_MAX_UPLOAD_BYTES` | No | Maximum decoded file-upload size in bytes (positive integer; default: 10 MiB) |
260
- | `ERPNEXT_METHOD_ALLOWLIST` | No | Comma-separated exact method paths or `prefix.*`; unset means `erpnext_method_call` denies every method, while `*` allows all |
261
- | `MCP_MRTR_SIGNING_KEY` | No | Exactly 64 lowercase hex characters; enables signed ambiguous-link elicitation. **Single-instance deployments only** — see below |
327
+ | Variable | Required | Description |
328
+ | ---------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- |
329
+ | `ERPNEXT_URL` | Yes | ERPNext base URL — self-hosted (e.g. `http://localhost:8000`) or cloud (e.g. `https://mycompany.erpnext.com`) |
330
+ | `ERPNEXT_API_KEY` | Yes | API Key from User Settings |
331
+ | `ERPNEXT_API_SECRET` | Yes | API Secret from User Settings |
332
+ | `ERPNEXT_MAX_UPLOAD_BYTES` | No | Maximum decoded file-upload size in bytes (positive integer; default: 10 MiB) |
333
+ | `ERPNEXT_MAX_DOWNLOAD_BYTES` | No | Maximum attachment-download size in bytes (positive integer; default: 10 MiB) |
334
+ | `ERPNEXT_METHOD_ALLOWLIST` | No | Comma-separated exact method paths or `prefix.*`; unset means `erpnext_method_call` denies every method, while `*` allows all |
335
+ | `MCP_MRTR_SIGNING_KEY` | No | Exactly 64 lowercase hex characters; enables signed ambiguous-link elicitation. **Single-instance deployments only** — see below |
262
336
 
263
337
  MRTR is opt-in. Without this key, or when the client does not advertise
264
338
  elicitation, ambiguous links keep returning the existing actionable ambiguity
@@ -295,3 +369,7 @@ started, and [AGENTS.md](AGENTS.md) for the full architecture and conventions.
295
369
  ## License
296
370
 
297
371
  MIT
372
+
373
+ Buy result fields use the host locale (EN/FR/ZH). App-level waiting and
374
+ rejection screens retain English labels in this beta; host-context support for
375
+ those shared surface screens remains an upstream MCP View follow-up.