@bbookmind/mcp 1.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/.claude-plugin/marketplace.json +27 -0
- package/.claude-plugin/plugin.json +18 -0
- package/.env.example +15 -0
- package/.github/workflows/validate.yml +55 -0
- package/CEO_QUICKSTART.md +161 -0
- package/CLAUDE.md +30 -0
- package/CNAME +1 -0
- package/LAUNCH_CONTENT.md +210 -0
- package/LICENSE +21 -0
- package/README.md +196 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +283 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/db.d.ts +6 -0
- package/dist/lib/db.d.ts.map +1 -0
- package/dist/lib/db.js +209 -0
- package/dist/lib/db.js.map +1 -0
- package/dist/lib/llm.d.ts +14 -0
- package/dist/lib/llm.d.ts.map +1 -0
- package/dist/lib/llm.js +110 -0
- package/dist/lib/llm.js.map +1 -0
- package/dist/lib/qbo.d.ts +35 -0
- package/dist/lib/qbo.d.ts.map +1 -0
- package/dist/lib/qbo.js +157 -0
- package/dist/lib/qbo.js.map +1 -0
- package/dist/tools/anomalies.d.ts +3 -0
- package/dist/tools/anomalies.d.ts.map +1 -0
- package/dist/tools/anomalies.js +142 -0
- package/dist/tools/anomalies.js.map +1 -0
- package/dist/tools/approveCategories.d.ts +3 -0
- package/dist/tools/approveCategories.d.ts.map +1 -0
- package/dist/tools/approveCategories.js +41 -0
- package/dist/tools/approveCategories.js.map +1 -0
- package/dist/tools/categorize.d.ts +3 -0
- package/dist/tools/categorize.d.ts.map +1 -0
- package/dist/tools/categorize.js +160 -0
- package/dist/tools/categorize.js.map +1 -0
- package/dist/tools/chaseEmail.d.ts +3 -0
- package/dist/tools/chaseEmail.d.ts.map +1 -0
- package/dist/tools/chaseEmail.js +29 -0
- package/dist/tools/chaseEmail.js.map +1 -0
- package/dist/tools/fetchTransactions.d.ts +3 -0
- package/dist/tools/fetchTransactions.d.ts.map +1 -0
- package/dist/tools/fetchTransactions.js +72 -0
- package/dist/tools/fetchTransactions.js.map +1 -0
- package/dist/tools/learnRules.d.ts +3 -0
- package/dist/tools/learnRules.d.ts.map +1 -0
- package/dist/tools/learnRules.js +72 -0
- package/dist/tools/learnRules.js.map +1 -0
- package/dist/tools/listCompanies.d.ts +3 -0
- package/dist/tools/listCompanies.d.ts.map +1 -0
- package/dist/tools/listCompanies.js +26 -0
- package/dist/tools/listCompanies.js.map +1 -0
- package/dist/tools/monthlyClose.d.ts +3 -0
- package/dist/tools/monthlyClose.d.ts.map +1 -0
- package/dist/tools/monthlyClose.js +92 -0
- package/dist/tools/monthlyClose.js.map +1 -0
- package/dist/tools/reconcile.d.ts +3 -0
- package/dist/tools/reconcile.d.ts.map +1 -0
- package/dist/tools/reconcile.js +86 -0
- package/dist/tools/reconcile.js.map +1 -0
- package/dist/tools/rejectCategories.d.ts +3 -0
- package/dist/tools/rejectCategories.d.ts.map +1 -0
- package/dist/tools/rejectCategories.js +36 -0
- package/dist/tools/rejectCategories.js.map +1 -0
- package/dist/tools/selectCompany.d.ts +3 -0
- package/dist/tools/selectCompany.d.ts.map +1 -0
- package/dist/tools/selectCompany.js +28 -0
- package/dist/tools/selectCompany.js.map +1 -0
- package/dist/tools/syncToQbo.d.ts +3 -0
- package/dist/tools/syncToQbo.d.ts.map +1 -0
- package/dist/tools/syncToQbo.js +53 -0
- package/dist/tools/syncToQbo.js.map +1 -0
- package/dist/tools/undoCategories.d.ts +3 -0
- package/dist/tools/undoCategories.d.ts.map +1 -0
- package/dist/tools/undoCategories.js +50 -0
- package/dist/tools/undoCategories.js.map +1 -0
- package/dist/tools/vendorSearch.d.ts +3 -0
- package/dist/tools/vendorSearch.d.ts.map +1 -0
- package/dist/tools/vendorSearch.js +39 -0
- package/dist/tools/vendorSearch.js.map +1 -0
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/index.html +403 -0
- package/install/claude-desktop.json +14 -0
- package/install/cline.json +16 -0
- package/install/continue.json +14 -0
- package/install/cursor.json +14 -0
- package/install/goose.yaml +10 -0
- package/install/lm-studio.json +14 -0
- package/install/vscode-copilot.json +14 -0
- package/install/windsurf.json +14 -0
- package/mcp-server.toml +30 -0
- package/package.json +49 -0
- package/server.json +136 -0
- package/src/index.ts +313 -0
- package/src/lib/db.ts +212 -0
- package/src/lib/llm.ts +140 -0
- package/src/lib/qbo.ts +187 -0
- package/src/tools/anomalies.ts +144 -0
- package/src/tools/approveCategories.ts +46 -0
- package/src/tools/categorize.ts +166 -0
- package/src/tools/chaseEmail.ts +30 -0
- package/src/tools/fetchTransactions.ts +79 -0
- package/src/tools/learnRules.ts +71 -0
- package/src/tools/listCompanies.ts +30 -0
- package/src/tools/monthlyClose.ts +95 -0
- package/src/tools/reconcile.ts +86 -0
- package/src/tools/rejectCategories.ts +43 -0
- package/src/tools/selectCompany.ts +33 -0
- package/src/tools/syncToQbo.ts +56 -0
- package/src/tools/undoCategories.ts +50 -0
- package/src/tools/vendorSearch.ts +32 -0
- package/src/types.ts +11 -0
- package/tsconfig.json +23 -0
package/README.md
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License">
|
|
3
|
+
<img src="https://img.shields.io/github/stars/bookmind/mcp" alt="Stars">
|
|
4
|
+
<img src="https://img.shields.io/npm/v/@bbookmind/mcp" alt="npm">
|
|
5
|
+
<img src="https://img.shields.io/badge/MCP-Compatible-6366f1" alt="MCP Compatible">
|
|
6
|
+
<br>
|
|
7
|
+
<h1>BookMind</h1>
|
|
8
|
+
<p><strong>AI bookkeeping for QuickBooks Online. Use any model, any provider.</strong></p>
|
|
9
|
+
<p>Auto-categorize · Reconcile · Monthly Close · Anomaly Detection · Chase Emails</p>
|
|
10
|
+
<p>
|
|
11
|
+
<a href="#install">Install</a> ·
|
|
12
|
+
<a href="#tools">Tools</a> ·
|
|
13
|
+
<a href="#pricing">Pricing</a> ·
|
|
14
|
+
<a href="https://bookmind.dev">Website</a>
|
|
15
|
+
</p>
|
|
16
|
+
<br>
|
|
17
|
+
<pre><code>npx @bbookmind/mcp</code></pre>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## What is BookMind?
|
|
23
|
+
|
|
24
|
+
BookMind is an **open-source MCP server** that brings intelligent bookkeeping to QuickBooks Online. Unlike Intuit's official MCP server (a raw API wrapper), BookMind is an **intelligent bookkeeping layer** — you speak naturally, it handles the rest.
|
|
25
|
+
|
|
26
|
+
### Why BookMind?
|
|
27
|
+
|
|
28
|
+
| Problem | Solution |
|
|
29
|
+
|---------|----------|
|
|
30
|
+
| Manual transaction categorization | Auto-categorize with 90%+ accuracy using learned rules + any LLM |
|
|
31
|
+
| Month-end close takes hours | One prompt → full close package (P&L, BS, CF, action items) |
|
|
32
|
+
| Bank reconciliation is tedious | Automatic fuzzy matching by amount, date, vendor |
|
|
33
|
+
| Duplicate payments slip through | Statistical anomaly detection catches them |
|
|
34
|
+
| Chasing overdue invoices | Professional emails in friendly/firm/escalation tones |
|
|
35
|
+
| Vendor research is slow | Natural language search: "What did we pay AWS last quarter?" |
|
|
36
|
+
| Locked into one AI provider | Works with OpenAI, Anthropic, Google, Groq, Mistral, NVIDIA, Ollama — or no provider at all |
|
|
37
|
+
|
|
38
|
+
### Architecture
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
QuickBooks Online ──► BookMind (this MCP) ──► Local SQLite
|
|
42
|
+
│
|
|
43
|
+
┌─────────┼─────────┐
|
|
44
|
+
▼ ▼ ▼
|
|
45
|
+
Rules Engine Memory Anomaly Detector
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- **Zero cloud dependency** — your data stays in local SQLite
|
|
49
|
+
- **Learns from you** — every correction becomes a persistent rule
|
|
50
|
+
- **Model-agnostic** — works with 7+ LLM providers (or rules-only mode)
|
|
51
|
+
- **Agent-agnostic** — works with Claude, Cursor, Cline, Continue, Windsurf, VS Code Copilot, Goose
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Install
|
|
56
|
+
|
|
57
|
+
### One command (any MCP client)
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npx @bbookmind/mcp
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Pre-built configs
|
|
64
|
+
|
|
65
|
+
| Agent | Config | Location |
|
|
66
|
+
|-------|--------|----------|
|
|
67
|
+
| Claude Desktop | `install/claude-desktop.json` | `%APPDATA%\Claude\claude_desktop_config.json` (Windows) |
|
|
68
|
+
| Cursor | `install/cursor.json` | `~/.cursor/mcp.json` |
|
|
69
|
+
| Cline | `install/cline.json` | VS Code → Extensions → Cline → MCP |
|
|
70
|
+
| Continue | `install/continue.json` | `~/.continue/config.json` |
|
|
71
|
+
| Windsurf | `install/windsurf.json` | `~/.codeium/windsurf/mcp_config.json` |
|
|
72
|
+
| VS Code Copilot | `install/vscode-copilot.json` | VS Code → GitHub Copilot → MCP |
|
|
73
|
+
|
|
74
|
+
### Environment (optional)
|
|
75
|
+
|
|
76
|
+
BookMind runs in **rules-only mode** by default (no API key needed). To enable AI categorization, add one provider key:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Pick ONE:
|
|
80
|
+
export GROQ_API_KEY=... # Free tier available
|
|
81
|
+
export NVIDIA_API_KEY=... # Free tier available
|
|
82
|
+
export GOOGLE_API_KEY=... # Free tier available
|
|
83
|
+
export OPENAI_API_KEY=...
|
|
84
|
+
export ANTHROPIC_API_KEY=...
|
|
85
|
+
export MISTRAL_API_KEY=...
|
|
86
|
+
export OLLAMA_BASE_URL=http://localhost:11434
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Tools
|
|
92
|
+
|
|
93
|
+
BookMind exposes **14 tools** that your AI agent discovers automatically:
|
|
94
|
+
|
|
95
|
+
| Category | Tool | Description |
|
|
96
|
+
|----------|------|-------------|
|
|
97
|
+
| **Categorization** | `bookmind.categorize` | Auto-categorize uncategorized transactions |
|
|
98
|
+
| | `bookmind.approve_categorizations` | Approve pending categorizations in batch |
|
|
99
|
+
| | `bookmind.reject_categorizations` | Reject with feedback, auto-create rules |
|
|
100
|
+
| | `bookmind.undo_categorize` | Rollback from audit log |
|
|
101
|
+
| **Data** | `bookmind.fetch_transactions` | Pull transactions, invoices, bills from QBO |
|
|
102
|
+
| | `bookmind.sync_to_qbo` | Push approved changes back to QuickBooks |
|
|
103
|
+
| **Reconciliation** | `bookmind.reconcile` | Match bank feed ↔ invoices/bills |
|
|
104
|
+
| **Intelligence** | `bookmind.anomalies` | Duplicate, drift, outlier detection |
|
|
105
|
+
| | `bookmind.monthly_close` | Full close package (P&L, BS, CF) |
|
|
106
|
+
| | `bookmind.vendor_search` | Natural language vendor search |
|
|
107
|
+
| **Communications** | `bookmind.chase_email` | Overdue invoice email generator |
|
|
108
|
+
| **Learning** | `bookmind.learn_rules` | Create rules from user corrections |
|
|
109
|
+
| **Multi-company** | `bookmind.select_company` | Switch between QBO companies |
|
|
110
|
+
| | `bookmind.list_companies` | List connected companies |
|
|
111
|
+
|
|
112
|
+
### Example prompts
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
"Categorize my uncategorized transactions from last month"
|
|
116
|
+
"Reconcile my bank feed against open invoices"
|
|
117
|
+
"Generate March close package"
|
|
118
|
+
"Any duplicate payments to vendors?"
|
|
119
|
+
"What did we pay AWS last quarter?"
|
|
120
|
+
"Draft friendly chase emails for invoices over 30 days overdue"
|
|
121
|
+
"Remember: Stripe transactions → Payment Processing Fees"
|
|
122
|
+
"Switch to Acme Corp company"
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Pricing
|
|
128
|
+
|
|
129
|
+
| Tier | Price | Transactions | Companies | Features |
|
|
130
|
+
|------|-------|-------------|-----------|----------|
|
|
131
|
+
| **Free** | $0 | 50/mo | 1 | Rules-only categorization, basic vendor search |
|
|
132
|
+
| **Pro** | $29/mo | 1,000/mo | 3 | AI categorize, reconcile, anomalies, vendor search |
|
|
133
|
+
| **Firm** | $149/mo | Unlimited | Unlimited | Monthly close, chase emails, white-label PDFs, team seats |
|
|
134
|
+
|
|
135
|
+
14-day Pro trial — no credit card required.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Development
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
git clone https://github.com/bbookmind/mcp
|
|
143
|
+
cd bookmind
|
|
144
|
+
npm install
|
|
145
|
+
npm run dev # watch mode
|
|
146
|
+
npm run build # production build
|
|
147
|
+
npm test # vitest
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Project structure
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
src/
|
|
154
|
+
├── index.ts # MCP server entry
|
|
155
|
+
├── tools/ # 14 bookkeeping tools
|
|
156
|
+
│ ├── categorize.ts
|
|
157
|
+
│ ├── approveCategories.ts
|
|
158
|
+
│ ├── rejectCategories.ts
|
|
159
|
+
│ ├── undoCategories.ts
|
|
160
|
+
│ ├── fetchTransactions.ts
|
|
161
|
+
│ ├── syncToQbo.ts
|
|
162
|
+
│ ├── reconcile.ts
|
|
163
|
+
│ ├── anomalies.ts
|
|
164
|
+
│ ├── monthlyClose.ts
|
|
165
|
+
│ ├── vendorSearch.ts
|
|
166
|
+
│ ├── chaseEmail.ts
|
|
167
|
+
│ ├── learnRules.ts
|
|
168
|
+
│ ├── selectCompany.ts
|
|
169
|
+
│ └── listCompanies.ts
|
|
170
|
+
└── lib/
|
|
171
|
+
├── qbo.ts # QuickBooks OAuth + API client
|
|
172
|
+
├── db.ts # SQLite schema + migrations
|
|
173
|
+
└── llm.ts # Multi-provider LLM interface
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Distribution channels
|
|
179
|
+
|
|
180
|
+
- **npm**: `npx @bbookmind/mcp`
|
|
181
|
+
- **MCP Registry**: `registry.modelcontextprotocol.io`
|
|
182
|
+
- **Claude Marketplace**: `/plugin install bookmind`
|
|
183
|
+
- **GitHub**: [github.com/bbookmind/mcp](https://github.com/bbookmind/mcp)
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## License
|
|
188
|
+
|
|
189
|
+
MIT — free to use, modify, and distribute.
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Support
|
|
194
|
+
|
|
195
|
+
- [GitHub Issues](https://github.com/bbookmind/mcp/issues)
|
|
196
|
+
- [Email](mailto:support@bookmind.dev)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, ErrorCode, McpError, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
import { getDb, saveDb, getCurrentCompanyId } from "./lib/db.js";
|
|
6
|
+
import { activeCompanyId } from "./types.js";
|
|
7
|
+
import { categorizeTool } from "./tools/categorize.js";
|
|
8
|
+
import { reconcileTool } from "./tools/reconcile.js";
|
|
9
|
+
import { anomaliesTool } from "./tools/anomalies.js";
|
|
10
|
+
import { monthlyCloseTool } from "./tools/monthlyClose.js";
|
|
11
|
+
import { vendorSearchTool } from "./tools/vendorSearch.js";
|
|
12
|
+
import { chaseEmailTool } from "./tools/chaseEmail.js";
|
|
13
|
+
import { learnRulesTool } from "./tools/learnRules.js";
|
|
14
|
+
import { approveCategoriesTool } from "./tools/approveCategories.js";
|
|
15
|
+
import { rejectCategoriesTool } from "./tools/rejectCategories.js";
|
|
16
|
+
import { undoCategoriesTool } from "./tools/undoCategories.js";
|
|
17
|
+
import { fetchTransactionsTool } from "./tools/fetchTransactions.js";
|
|
18
|
+
import { syncToQboTool } from "./tools/syncToQbo.js";
|
|
19
|
+
import { selectCompanyTool } from "./tools/selectCompany.js";
|
|
20
|
+
import { listCompaniesTool } from "./tools/listCompanies.js";
|
|
21
|
+
const server = new Server({
|
|
22
|
+
name: "bookmind",
|
|
23
|
+
version: "1.0.0",
|
|
24
|
+
}, {
|
|
25
|
+
capabilities: {
|
|
26
|
+
tools: {},
|
|
27
|
+
resources: {},
|
|
28
|
+
prompts: {},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
const tools = [
|
|
32
|
+
categorizeTool,
|
|
33
|
+
reconcileTool,
|
|
34
|
+
anomaliesTool,
|
|
35
|
+
monthlyCloseTool,
|
|
36
|
+
vendorSearchTool,
|
|
37
|
+
chaseEmailTool,
|
|
38
|
+
learnRulesTool,
|
|
39
|
+
approveCategoriesTool,
|
|
40
|
+
rejectCategoriesTool,
|
|
41
|
+
undoCategoriesTool,
|
|
42
|
+
fetchTransactionsTool,
|
|
43
|
+
syncToQboTool,
|
|
44
|
+
selectCompanyTool,
|
|
45
|
+
listCompaniesTool,
|
|
46
|
+
];
|
|
47
|
+
const resourceTemplates = [
|
|
48
|
+
{
|
|
49
|
+
uriTemplate: "bookmind://rules",
|
|
50
|
+
name: "Categorization Rules",
|
|
51
|
+
description: "List all categorization rules for the current company",
|
|
52
|
+
mimeType: "application/json",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
uriTemplate: "bookmind://accounts",
|
|
56
|
+
name: "QBO Accounts",
|
|
57
|
+
description: "List QuickBooks Online accounts",
|
|
58
|
+
mimeType: "application/json",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
uriTemplate: "bookmind://anomalies/{id}",
|
|
62
|
+
name: "Anomaly Details",
|
|
63
|
+
description: "Get details of a specific anomaly by ID",
|
|
64
|
+
mimeType: "application/json",
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
const prompts = [
|
|
68
|
+
{
|
|
69
|
+
name: "monthly-close",
|
|
70
|
+
description: "Generate a monthly close report with reconciliation and anomaly review",
|
|
71
|
+
arguments: [
|
|
72
|
+
{ name: "month", description: "Month to close (YYYY-MM)", required: true },
|
|
73
|
+
{ name: "year", description: "Year (optional, defaults to current year)", required: false },
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "categorize",
|
|
78
|
+
description: "Interactive transaction categorization workflow",
|
|
79
|
+
arguments: [
|
|
80
|
+
{ name: "transaction_ids", description: "Comma-separated list of transaction IDs, or 'all' for pending", required: true },
|
|
81
|
+
{ name: "auto_approve", description: "Auto-approve high-confidence suggestions", required: false },
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "reconcile",
|
|
86
|
+
description: "Reconcile transactions with bank statements",
|
|
87
|
+
arguments: [
|
|
88
|
+
{ name: "start_date", description: "Start date (YYYY-MM-DD)", required: true },
|
|
89
|
+
{ name: "end_date", description: "End date (YYYY-MM-DD)", required: true },
|
|
90
|
+
{ name: "account_id", description: "Account ID to reconcile", required: false },
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
95
|
+
tools: tools.map((t) => ({
|
|
96
|
+
name: t.name,
|
|
97
|
+
description: t.description,
|
|
98
|
+
inputSchema: t.schema,
|
|
99
|
+
})),
|
|
100
|
+
}));
|
|
101
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => ({
|
|
102
|
+
resources: resourceTemplates.map((rt) => ({
|
|
103
|
+
uri: rt.uriTemplate.replace("{id}", "*"),
|
|
104
|
+
name: rt.name,
|
|
105
|
+
description: rt.description,
|
|
106
|
+
mimeType: rt.mimeType,
|
|
107
|
+
})),
|
|
108
|
+
}));
|
|
109
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
110
|
+
const uri = request.params.uri;
|
|
111
|
+
const db = await getDb();
|
|
112
|
+
const coId = getCurrentCompanyId();
|
|
113
|
+
if (uri === "bookmind://rules") {
|
|
114
|
+
const rows = db.exec(`SELECT id, vendor_pattern, description_pattern, category, confidence, priority, uses FROM categorization_rules WHERE company_id='${coId}' OR company_id='default' ORDER BY priority DESC`);
|
|
115
|
+
const rules = rows[0]?.values || [];
|
|
116
|
+
return {
|
|
117
|
+
contents: [
|
|
118
|
+
{
|
|
119
|
+
uri,
|
|
120
|
+
mimeType: "application/json",
|
|
121
|
+
text: JSON.stringify(rules.map(([id, vp, dp, cat, conf, pri, uses]) => ({ id, vendor_pattern: vp, description_pattern: dp, category: cat, confidence: conf, priority: pri, uses })), null, 2),
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
if (uri === "bookmind://accounts") {
|
|
127
|
+
try {
|
|
128
|
+
const { qboClient } = await import("./lib/qbo.js");
|
|
129
|
+
if (!qboClient.isAuthenticated()) {
|
|
130
|
+
return { contents: [{ uri, mimeType: "application/json", text: JSON.stringify({ error: "QBO not connected" }, null, 2) }] };
|
|
131
|
+
}
|
|
132
|
+
const accounts = await qboClient.getAccounts();
|
|
133
|
+
const accList = accounts.QueryResponse?.Account || [];
|
|
134
|
+
return {
|
|
135
|
+
contents: [
|
|
136
|
+
{
|
|
137
|
+
uri,
|
|
138
|
+
mimeType: "application/json",
|
|
139
|
+
text: JSON.stringify(accList.map((a) => ({ id: a.Id, name: a.Name, type: a.AccountType, balance: a.CurrentBalance })), null, 2),
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
return { contents: [{ uri, mimeType: "application/json", text: JSON.stringify({ error: e.message }, null, 2) }] };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const anomalyMatch = uri.match(/^bookmind:\/\/anomalies\/(.+)$/);
|
|
149
|
+
if (anomalyMatch) {
|
|
150
|
+
const anomalyId = anomalyMatch[1];
|
|
151
|
+
const rows = db.exec(`SELECT id, type, severity, description, transaction_id, vendor, amount, detected_at FROM anomalies WHERE id='${anomalyId.replace(/'/g, "''")}' AND company_id='${coId}'`);
|
|
152
|
+
const anomaly = rows[0]?.values?.[0];
|
|
153
|
+
if (!anomaly) {
|
|
154
|
+
return { contents: [{ uri, mimeType: "application/json", text: JSON.stringify({ error: "Anomaly not found" }, null, 2) }] };
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
contents: [
|
|
158
|
+
{
|
|
159
|
+
uri,
|
|
160
|
+
mimeType: "application/json",
|
|
161
|
+
text: JSON.stringify({ id: anomaly[0], type: anomaly[1], severity: anomaly[2], description: anomaly[3], transaction_id: anomaly[4], vendor: anomaly[5], amount: anomaly[6], detected_at: anomaly[7] }, null, 2),
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
throw new McpError(ErrorCode.MethodNotFound, `Unknown resource: ${uri}`);
|
|
167
|
+
});
|
|
168
|
+
server.setRequestHandler(ListPromptsRequestSchema, async () => ({
|
|
169
|
+
prompts: prompts.map((p) => ({
|
|
170
|
+
name: p.name,
|
|
171
|
+
description: p.description,
|
|
172
|
+
arguments: p.arguments,
|
|
173
|
+
})),
|
|
174
|
+
}));
|
|
175
|
+
server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
176
|
+
const { name, arguments: args } = request.params;
|
|
177
|
+
const db = await getDb();
|
|
178
|
+
const coId = getCurrentCompanyId();
|
|
179
|
+
if (name === "monthly-close") {
|
|
180
|
+
const month = args?.month;
|
|
181
|
+
if (!month)
|
|
182
|
+
throw new McpError(ErrorCode.InvalidParams, "Missing required argument: month");
|
|
183
|
+
const [year, mon] = month.split("-");
|
|
184
|
+
const startDate = `${year}-${mon}-01`;
|
|
185
|
+
const endDate = new Date(parseInt(year), parseInt(mon), 0).toISOString().split("T")[0];
|
|
186
|
+
const rows = db.exec(`SELECT COUNT(*), SUM(amount), SUM(CASE WHEN status='categorized' THEN 1 ELSE 0 END), SUM(CASE WHEN status='uncategorized' THEN 1 ELSE 0 END) FROM transactions WHERE company_id='${coId}' AND date >= '${startDate}' AND date <= '${endDate}'`);
|
|
187
|
+
const stats = rows[0]?.values?.[0] || [0, 0, 0, 0];
|
|
188
|
+
const anomalyRows = db.exec(`SELECT COUNT(*), SUM(CASE WHEN acknowledged=0 THEN 1 ELSE 0 END) FROM anomalies WHERE company_id='${coId}' AND detected_at >= '${startDate}'`);
|
|
189
|
+
const anomalies = anomalyRows[0]?.values?.[0] || [0, 0];
|
|
190
|
+
return {
|
|
191
|
+
description: `Monthly close for ${month}`,
|
|
192
|
+
messages: [
|
|
193
|
+
{
|
|
194
|
+
role: "user",
|
|
195
|
+
content: {
|
|
196
|
+
type: "text",
|
|
197
|
+
text: `Generate monthly close report for ${month}:
|
|
198
|
+
- Total transactions: ${stats[0]}
|
|
199
|
+
- Total volume: $${parseFloat(stats[1] || 0).toLocaleString(undefined, { minimumFractionDigits: 2 })}
|
|
200
|
+
- Categorized: ${stats[2]}
|
|
201
|
+
- Uncategorized: ${stats[3]}
|
|
202
|
+
- Anomalies detected: ${anomalies[0]}
|
|
203
|
+
- Unacknowledged anomalies: ${anomalies[1]}
|
|
204
|
+
|
|
205
|
+
Run reconcile, review anomalies, then generate close report.`,
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
if (name === "categorize") {
|
|
212
|
+
const txIds = args?.transaction_ids;
|
|
213
|
+
if (!txIds)
|
|
214
|
+
throw new McpError(ErrorCode.InvalidParams, "Missing required argument: transaction_ids");
|
|
215
|
+
const autoApprove = args?.auto_approve === "true";
|
|
216
|
+
return {
|
|
217
|
+
description: "Categorize transactions",
|
|
218
|
+
messages: [
|
|
219
|
+
{
|
|
220
|
+
role: "user",
|
|
221
|
+
content: {
|
|
222
|
+
type: "text",
|
|
223
|
+
text: `Categorize transactions: ${txIds}
|
|
224
|
+
Auto-approve high-confidence suggestions: ${autoApprove}
|
|
225
|
+
|
|
226
|
+
1. Run bookmind.categorize with the transaction IDs
|
|
227
|
+
2. Review suggestions
|
|
228
|
+
3. Run bookmind.approve_categorizations or bookmind.reject_categorizations as needed
|
|
229
|
+
4. Optionally run bookmind.learn_rules to create rules from corrections`,
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
if (name === "reconcile") {
|
|
236
|
+
const startDate = args?.start_date;
|
|
237
|
+
const endDate = args?.end_date;
|
|
238
|
+
if (!startDate || !endDate)
|
|
239
|
+
throw new McpError(ErrorCode.InvalidParams, "Missing required arguments: start_date, end_date");
|
|
240
|
+
return {
|
|
241
|
+
description: "Reconcile transactions",
|
|
242
|
+
messages: [
|
|
243
|
+
{
|
|
244
|
+
role: "user",
|
|
245
|
+
content: {
|
|
246
|
+
type: "text",
|
|
247
|
+
text: `Reconcile transactions from ${startDate} to ${endDate}
|
|
248
|
+
Account: ${args?.account_id || "all"}
|
|
249
|
+
|
|
250
|
+
1. Run bookmind.fetch_transactions with the date range
|
|
251
|
+
2. Run bookmind.reconcile with the fetched transactions
|
|
252
|
+
3. Review matches and exceptions
|
|
253
|
+
4. Approve reconciliations`,
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
],
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
throw new McpError(ErrorCode.MethodNotFound, `Unknown prompt: ${name}`);
|
|
260
|
+
});
|
|
261
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
262
|
+
const tool = tools.find((t) => t.name === request.params.name);
|
|
263
|
+
if (!tool) {
|
|
264
|
+
throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}`);
|
|
265
|
+
}
|
|
266
|
+
try {
|
|
267
|
+
const db = await getDb();
|
|
268
|
+
const result = await tool.handler(request.params.arguments ?? {}, db);
|
|
269
|
+
await saveDb();
|
|
270
|
+
return {
|
|
271
|
+
content: [{ type: "text", text: typeof result === "string" ? result : JSON.stringify(result, null, 2) }],
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
catch (error) {
|
|
275
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
276
|
+
throw new McpError(ErrorCode.InternalError, message);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
const transport = new StdioServerTransport();
|
|
280
|
+
await server.connect(transport);
|
|
281
|
+
console.error(`BookMind v1.0.0 — ${tools.length} tools, ${resourceTemplates.length} resources, ${prompts.length} prompts registered`);
|
|
282
|
+
console.error(`Active company: ${activeCompanyId.current || "default"}`);
|
|
283
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,EACtB,SAAS,EACT,QAAQ,GACT,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,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C,CAAC"}
|
package/dist/lib/db.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Database } from "sql.js";
|
|
2
|
+
export declare function getDb(): Promise<Database>;
|
|
3
|
+
export declare function getCurrentCompanyId(): string;
|
|
4
|
+
export declare function saveDb(): Promise<void>;
|
|
5
|
+
export declare function auditChange(db: Database, entityType: string, entityId: string, field: string, oldValue: string | null, newValue: string, source: string): void;
|
|
6
|
+
//# sourceMappingURL=db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/lib/db.ts"],"names":[],"mappings":"AAAA,OAAkB,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAkB7C,wBAAsB,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC,CAqB/C;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAyID,wBAAsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAQ5C;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAIvJ"}
|