@hvgllc/hvgerp-mcp 3.0.0

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/README.md ADDED
@@ -0,0 +1,304 @@
1
+ English | [繁體中文](README.zh-TW.md)
2
+
3
+ # @hvgllc/hvgerp-mcp
4
+
5
+ [![JSR](https://jsr.io/badges/@hvgllc/hvgerp-mcp)](https://jsr.io/@hvgllc/hvgerp-mcp)
6
+ [![npm](https://img.shields.io/npm/v/@hvgllc/hvgerp-mcp?logo=npm&color=cb3837)](https://www.npmjs.com/package/@hvgllc/hvgerp-mcp)
7
+ [![CI](https://github.com/hvgllc/hvgerp-mcp/actions/workflows/test.yml/badge.svg)](https://github.com/hvgllc/hvgerp-mcp/actions/workflows/test.yml)
8
+ [![MCP](https://img.shields.io/badge/MCP-server-1f6feb?logo=modelcontextprotocol&logoColor=white)](https://modelcontextprotocol.io)
9
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
10
+
11
+ MCP server for [ERPNext](https://erpnext.com) / Frappe ERP — **125 tools**
12
+ across **14 categories**, with **7 interactive UI viewers**.
13
+
14
+ Connect any MCP-compatible AI agent (Claude Desktop, Claude Code, VS Code
15
+ Copilot, custom) to your ERPNext instance via the
16
+ [Model Context Protocol](https://modelcontextprotocol.io).
17
+
18
+ Works with **self-hosted** and **ERPNext Cloud** (frappe.cloud) instances.
19
+
20
+ > Built on **[@casys/mcp-server](https://github.com/Casys-AI/mcp-server)** — the
21
+ > MCP server framework (concurrency, auth, MCP Apps, observability) that powers
22
+ > this project.
23
+
24
+ > Forked from **[@casys/mcp-erpnext](https://github.com/Casys-AI/mcp-erpnext)**
25
+ > by Casys AI, MIT licensed. Everything up to 2.6.0 is their work; this fork
26
+ > renames the package and adds tools of its own.
27
+
28
+ ## Screenshots
29
+
30
+ Interactive viewers rendered inside an MCP host, driven entirely by tool
31
+ results.
32
+
33
+ <table>
34
+ <tr>
35
+ <td width="50%" align="center">
36
+ <img src="docs/assets/doclist-viewer.png" alt="Document list viewer with chip filters and inline detail" width="100%"><br>
37
+ <sub><b>doclist-viewer</b> — any DocType as a sortable table with chip filters and an inline detail panel</sub>
38
+ </td>
39
+ <td width="50%" align="center">
40
+ <img src="docs/assets/invoice-viewer.png" alt="Invoice viewer with line items and actions" width="100%"><br>
41
+ <sub><b>invoice-viewer</b> — invoice with parties, line items, item drill-down and Submit/Cancel/Payments</sub>
42
+ </td>
43
+ </tr>
44
+ <tr>
45
+ <td width="50%" align="center">
46
+ <img src="docs/assets/funnel-viewer.png" alt="Sales funnel viewer" width="100%"><br>
47
+ <sub><b>funnel-viewer</b> — Lead → Opportunity → Quotation → Order with conversion rates</sub>
48
+ </td>
49
+ <td width="50%" align="center">
50
+ <img src="docs/assets/kpi-viewer.png" alt="KPI viewer with sparkline" width="100%"><br>
51
+ <sub><b>kpi-viewer</b> — big-number KPI with delta vs last period and a sparkline</sub>
52
+ </td>
53
+ </tr>
54
+ <tr>
55
+ <td width="50%" align="center">
56
+ <img src="docs/assets/chart-viewer.png" alt="Chart viewer" width="100%"><br>
57
+ <sub><b>chart-viewer</b> — universal Recharts renderer (here: stock levels)</sub>
58
+ </td>
59
+ <td width="50%" align="center">
60
+ <img src="docs/assets/stock-viewer.png" alt="Stock balance viewer" width="100%"><br>
61
+ <sub><b>stock-viewer</b> — stock balance with color-coded quantity badges</sub>
62
+ </td>
63
+ </tr>
64
+ <tr>
65
+ <td width="50%" align="center">
66
+ <img src="docs/assets/kanban-viewer.png" alt="Read-write kanban board" width="100%"><br>
67
+ <sub><b>kanban-viewer</b> — read-write board (Task / Opportunity / Issue) with inline edit</sub>
68
+ </td>
69
+ <td width="50%" align="center">
70
+ <img src="docs/assets/profit-loss.png" alt="Profit and loss composed chart" width="100%"><br>
71
+ <sub><b>chart-viewer</b> — composed dual-axis chart (here: profit &amp; loss)</sub>
72
+ </td>
73
+ </tr>
74
+ </table>
75
+
76
+ ## What's New
77
+
78
+ See the [CHANGELOG](CHANGELOG.md) for the full release history, or the
79
+ [latest release](https://github.com/hvgllc/hvgerp-mcp/releases/latest) for the
80
+ current version's highlights.
81
+
82
+ ## Documentation
83
+
84
+ Organised by what you are doing, following [Diátaxis](https://diataxis.fr):
85
+
86
+ | | |
87
+ | ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
88
+ | **Learning** — never used this before | [Your first tool call](docs/tutorial-first-tool-call.md) — from nothing to a working response in four steps |
89
+ | **Doing** — you have a specific goal | [Seed a blank ERPNext instance](docs/fresh-instance-setup.md) · [Run the HTTP server](docs/http-deployment.md) · [Set up OAuth](docs/oauth-setup.md) · [Migrate to 2026-07-28](docs/migration-mcp-spec-2026-07-28.md) |
90
+ | **Looking something up** | [Tools](docs/tools.md) · [Environment variables](docs/environment-variables.md) · [DocType coverage](docs/coverage.md) |
91
+ | **Understanding why** | [Concepts](docs/concepts.md) — link resolution, transports, MRTR, and which cache does what · [ERPNext quirks](docs/erpnext-quirks.md) |
92
+
93
+ ## Quick Start
94
+
95
+ ### Prerequisites
96
+
97
+ Generate API credentials in ERPNext:
98
+
99
+ 1. Login to ERPNext → top-right menu → **My Settings**
100
+ 2. Section **API Access** → **Generate Keys**
101
+ 3. Copy `API Key` and `API Secret`
102
+
103
+ ### Claude Desktop / Claude Code (npm)
104
+
105
+ ```json
106
+ {
107
+ "mcpServers": {
108
+ "erpnext": {
109
+ "command": "npx",
110
+ "args": ["-y", "@hvgllc/hvgerp-mcp"],
111
+ "env": {
112
+ "ERPNEXT_URL": "http://localhost:8000",
113
+ "ERPNEXT_API_KEY": "your-api-key",
114
+ "ERPNEXT_API_SECRET": "your-api-secret"
115
+ }
116
+ }
117
+ }
118
+ }
119
+ ```
120
+
121
+ > **Works with ERPNext Cloud** — set `ERPNEXT_URL` to your Frappe Cloud URL
122
+ > (e.g. `https://mycompany.erpnext.com` or `https://mysite.frappe.cloud`). API
123
+ > key authentication works the same way on self-hosted and cloud instances.
124
+
125
+ ### VS Code Copilot
126
+
127
+ Add to `.vscode/mcp.json`:
128
+
129
+ ```json
130
+ {
131
+ "servers": {
132
+ "erpnext": {
133
+ "type": "stdio",
134
+ "command": "npx",
135
+ "args": ["-y", "@hvgllc/hvgerp-mcp"],
136
+ "env": {
137
+ "ERPNEXT_URL": "http://localhost:8000",
138
+ "ERPNEXT_API_KEY": "your-api-key",
139
+ "ERPNEXT_API_SECRET": "your-api-secret"
140
+ }
141
+ }
142
+ }
143
+ }
144
+ ```
145
+
146
+ ### Deno (stdio)
147
+
148
+ ```json
149
+ {
150
+ "mcpServers": {
151
+ "erpnext": {
152
+ "command": "deno",
153
+ "args": ["run", "--allow-all", "server.ts"],
154
+ "env": {
155
+ "ERPNEXT_URL": "http://localhost:8000",
156
+ "ERPNEXT_API_KEY": "your-api-key",
157
+ "ERPNEXT_API_SECRET": "your-api-secret"
158
+ }
159
+ }
160
+ }
161
+ }
162
+ ```
163
+
164
+ ### HTTP mode
165
+
166
+ For a shared, always-on server rather than one process per client:
167
+ [how to run the HTTP server](docs/http-deployment.md). Note it is breaking for
168
+ pre-2026 HTTP clients in 3.0.0.
169
+
170
+ ### Category filtering
171
+
172
+ Load only the categories you need:
173
+
174
+ ```bash
175
+ npx -y @hvgllc/hvgerp-mcp --categories=sales,inventory
176
+ ```
177
+
178
+ ## Fresh Instance Setup
179
+
180
+ A blank ERPNext instance has no master data, so business tools fail validation
181
+ until it exists. See
182
+ [Seed a blank ERPNext instance](docs/fresh-instance-setup.md).
183
+
184
+ ## UI Viewers
185
+
186
+ Seven interactive [MCP Apps](https://github.com/modelcontextprotocol/ext-apps)
187
+ viewers, registered as `ui://hvgerp-mcp/{name}`:
188
+
189
+ | Viewer | Description | Interactive Features |
190
+ | ---------------- | ---------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
191
+ | `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. |
192
+ | `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. |
193
+ | `stock-viewer` | Stock balance table with color-coded qty badges | Row click → item info + recent movements. sendMessage to stock chart, item details, stock entries. |
194
+ | `chart-viewer` | Universal chart renderer (12 types via Recharts) | Click bar/pie/line data points → sendMessage drill-down into underlying documents. |
195
+ | `kanban-viewer` | Read-write kanban for Task, Opportunity, Issue | Drag-and-drop moves, inline edit (priority, progress, dates), sendMessage to Timesheets/Quotations/Related docs. |
196
+ | `kpi-viewer` | Big number card with delta, sparkline, trend | Click number → sendMessage to exception list. Click sparkline → trend chart. |
197
+ | `funnel-viewer` | Trapezoid sales funnel with conversion rates | Click stage → sendMessage to document list at that stage. Stage action buttons. |
198
+
199
+ ### Cross-viewer navigation
200
+
201
+ Viewers communicate via `app.sendMessage()` — clicking a button in one viewer
202
+ injects a message into the conversation, which triggers the AI to call the right
203
+ tool and open the appropriate viewer.
204
+
205
+ The server auto-injects navigation metadata into tool results:
206
+
207
+ - `_rowAction` — which tool to call when a row is clicked
208
+ - `_sendMessageHints` — navigation buttons shown in detail panels (e.g.
209
+ "Orders", "Invoices")
210
+ - `_drillDown` / `_trendDrillDown` — sendMessage templates for KPI and chart
211
+ click-through
212
+
213
+ ### Refresh model
214
+
215
+ All viewers carry a `refreshRequest` payload for safe revalidation via
216
+ `app.callServerTool()`:
217
+
218
+ - `kanban-viewer` revalidates after mutations and on focus
219
+ - All other viewers support focus refresh + manual refresh button
220
+
221
+ ### Building UI viewers
222
+
223
+ ```bash
224
+ cd src/ui
225
+ npm install
226
+ node build-all.mjs
227
+ ```
228
+
229
+ ## Tools (125)
230
+
231
+ 125 tools across 14 categories. Each `_list` tool returns interactive results
232
+ via the doclist-viewer with row click, inline detail, and cross-viewer
233
+ navigation.
234
+
235
+ - **Sales** (17) — Customers, Sales Orders, Invoices, and Quotations with full
236
+ CRUD, Submit, and Cancel.
237
+ - **Purchasing** (11) — Suppliers, Purchase Orders, Purchase Invoices, Receipts,
238
+ and Supplier Quotations.
239
+ - **Inventory** (9) — Items, Stock Balance, Warehouses, and Stock Entries.
240
+ - **Accounting** (6) — Chart of Accounts, Journal Entries, and Payment Entries.
241
+ - **HR** (12) — Employees, Attendance, Leave Applications, Salary Slips, Payroll
242
+ Entries, and Expense Claims.
243
+ - **Project** (9) — Projects, Tasks (with native assignment), and Timesheets.
244
+ - **Delivery** (5) — Delivery Notes and Shipments.
245
+ - **Manufacturing** (7) — BOMs, Work Orders, and Job Cards.
246
+ - **CRM** (8) — Leads, Opportunities, Contacts, and Campaigns.
247
+ - **Assets** (8) — Assets, Movements, Maintenance records, and Categories.
248
+ - **Operations** (11) — Generic CRUD, native assignment, and file upload for any
249
+ DocType (`erpnext_doc_*`, `erpnext_file_upload`), plus `erpnext_method_call`
250
+ for allowlisted whitelisted-method calls.
251
+ - **Kanban** (2) — Read-write boards for Task, Opportunity, and Issue with
252
+ drag-and-drop.
253
+ - **Analytics** (17) — 11 analytics charts (bar, area, treemap, radar, scatter,
254
+ P&L…), 5 KPIs with sparklines, and a sales funnel.
255
+ - **Setup** (3) — Company creation and assignable user listing.
256
+
257
+ Full per-tool reference with parameters: [`docs/tools.md`](docs/tools.md).
258
+
259
+ ## Environment Variables
260
+
261
+ | Variable | Required | Description |
262
+ | -------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
263
+ | `ERPNEXT_URL` | Yes | ERPNext base URL — self-hosted (e.g. `http://localhost:8000`) or cloud (e.g. `https://mycompany.erpnext.com`) |
264
+ | `ERPNEXT_API_KEY` | Yes | API Key from User Settings |
265
+ | `ERPNEXT_API_SECRET` | Yes | API Secret from User Settings |
266
+ | `ERPNEXT_MAX_UPLOAD_BYTES` | No | Maximum decoded file-upload size in bytes (positive integer; default: 10 MiB) |
267
+ | `ERPNEXT_METHOD_ALLOWLIST` | No | Comma-separated dotted paths or `prefix.*` patterns that `erpnext_method_call` may invoke. Unset means no extra restriction beyond the API key's own ERPNext permissions |
268
+ | `MCP_MRTR_SIGNING_KEY` | No | Exactly 64 lowercase hex characters; enables signed ambiguous-link elicitation. **Single-instance deployments only** — see below |
269
+
270
+ MRTR is opt-in. Without this key, or when the client does not advertise
271
+ elicitation, ambiguous links keep returning the existing actionable ambiguity
272
+ error instead of prompting for a selection.
273
+
274
+ > **Do not run MRTR behind a load balancer with this configuration.** The
275
+ > signing key proves a retry token is authentic; it does not make it single-use.
276
+ > That is the job of a replay store, and the default one is process-local. Share
277
+ > the key across two instances and the same signed retry validates on both —
278
+ > creating the purchase order, leave application or expense claim **twice**,
279
+ > irreversibly once submitted.
280
+ >
281
+ > A multi-instance deployment must pass a shared atomic `mrtr.replayStore` to
282
+ > `McpApp` (Redis satisfies the contract with `SET key 1 NX EXAT`). The
283
+ > framework logs a warning at startup whenever MRTR is enabled without one —
284
+ > that warning is not noise, it is this paragraph.
285
+
286
+ ## Architecture
287
+
288
+ Tools are grouped by business domain under `src/tools/`, the Frappe REST client
289
+ is dependency-free, and each UI viewer is a separate build under `src/ui/`. Full
290
+ layout: [repository layout](docs/architecture.md).
291
+
292
+ ## npm Package
293
+
294
+ The npm package (`@hvgllc/hvgerp-mcp`) is a single self-contained bundle with
295
+ zero runtime dependencies. UI viewers are embedded. Requires Node >= 20.
296
+
297
+ ## Contributing
298
+
299
+ Contributions are welcome — see **[CONTRIBUTING.md](CONTRIBUTING.md)** to get
300
+ started, and [AGENTS.md](AGENTS.md) for the full architecture and conventions.
301
+
302
+ ## License
303
+
304
+ MIT