bkper 3.8.1 → 4.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.
Files changed (343) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/README.md +217 -183
  3. package/lib/auth/auth-page.d.ts +14 -0
  4. package/lib/auth/auth-page.d.ts.map +1 -0
  5. package/lib/auth/auth-page.js +110 -0
  6. package/lib/auth/auth-page.js.map +1 -0
  7. package/lib/auth/local-auth-service.d.ts.map +1 -1
  8. package/lib/auth/local-auth-service.js +135 -17
  9. package/lib/auth/local-auth-service.js.map +1 -1
  10. package/lib/bkper-factory.d.ts.map +1 -0
  11. package/lib/{mcp/bkper-factory.js → bkper-factory.js} +5 -2
  12. package/lib/bkper-factory.js.map +1 -0
  13. package/lib/cli.d.ts +1 -1
  14. package/lib/cli.d.ts.map +1 -1
  15. package/lib/cli.js +851 -47
  16. package/lib/cli.js.map +1 -1
  17. package/lib/commands/accounts/create.d.ts +10 -0
  18. package/lib/commands/accounts/create.d.ts.map +1 -0
  19. package/lib/commands/accounts/create.js +42 -0
  20. package/lib/commands/accounts/create.js.map +1 -0
  21. package/lib/commands/accounts/delete.d.ts +3 -0
  22. package/lib/commands/accounts/delete.d.ts.map +1 -0
  23. package/lib/commands/accounts/delete.js +22 -0
  24. package/lib/commands/accounts/delete.js.map +1 -0
  25. package/lib/commands/accounts/get.d.ts +3 -0
  26. package/lib/commands/accounts/get.d.ts.map +1 -0
  27. package/lib/commands/accounts/get.js +22 -0
  28. package/lib/commands/accounts/get.js.map +1 -0
  29. package/lib/commands/accounts/index.d.ts +6 -0
  30. package/lib/commands/accounts/index.d.ts.map +1 -0
  31. package/lib/commands/accounts/index.js +6 -0
  32. package/lib/commands/accounts/index.js.map +1 -0
  33. package/lib/commands/accounts/list.d.ts +3 -0
  34. package/lib/commands/accounts/list.d.ts.map +1 -0
  35. package/lib/commands/accounts/list.js +19 -0
  36. package/lib/commands/accounts/list.js.map +1 -0
  37. package/lib/commands/accounts/update.d.ts +9 -0
  38. package/lib/commands/accounts/update.d.ts.map +1 -0
  39. package/lib/commands/accounts/update.js +40 -0
  40. package/lib/commands/accounts/update.js.map +1 -0
  41. package/lib/commands/apps/build.d.ts +11 -0
  42. package/lib/commands/apps/build.d.ts.map +1 -0
  43. package/lib/commands/apps/build.js +144 -0
  44. package/lib/commands/apps/build.js.map +1 -0
  45. package/lib/commands/apps/bundler.d.ts +34 -0
  46. package/lib/commands/apps/bundler.d.ts.map +1 -0
  47. package/lib/commands/apps/bundler.js +112 -0
  48. package/lib/commands/apps/bundler.js.map +1 -0
  49. package/lib/commands/apps/config.d.ts +51 -0
  50. package/lib/commands/apps/config.d.ts.map +1 -0
  51. package/lib/commands/apps/config.js +146 -0
  52. package/lib/commands/apps/config.js.map +1 -0
  53. package/lib/commands/apps/deploy.d.ts +23 -0
  54. package/lib/commands/apps/deploy.d.ts.map +1 -0
  55. package/lib/commands/apps/deploy.js +344 -0
  56. package/lib/commands/apps/deploy.js.map +1 -0
  57. package/lib/commands/apps/dev.d.ts +28 -0
  58. package/lib/commands/apps/dev.d.ts.map +1 -0
  59. package/lib/commands/apps/dev.js +393 -0
  60. package/lib/commands/apps/dev.js.map +1 -0
  61. package/lib/commands/apps/index.d.ts +12 -0
  62. package/lib/commands/apps/index.d.ts.map +1 -0
  63. package/lib/commands/apps/index.js +24 -0
  64. package/lib/commands/apps/index.js.map +1 -0
  65. package/lib/commands/apps/init.d.ts +7 -0
  66. package/lib/commands/apps/init.d.ts.map +1 -0
  67. package/lib/commands/apps/init.js +249 -0
  68. package/lib/commands/apps/init.js.map +1 -0
  69. package/lib/commands/apps/install.d.ts +3 -0
  70. package/lib/commands/apps/install.d.ts.map +1 -0
  71. package/lib/commands/apps/install.js +18 -0
  72. package/lib/commands/apps/install.js.map +1 -0
  73. package/lib/commands/apps/list.d.ts +7 -0
  74. package/lib/commands/apps/list.d.ts.map +1 -0
  75. package/lib/commands/apps/list.js +23 -0
  76. package/lib/commands/apps/list.js.map +1 -0
  77. package/lib/commands/apps/secrets.d.ts +22 -0
  78. package/lib/commands/apps/secrets.d.ts.map +1 -0
  79. package/lib/commands/apps/secrets.js +209 -0
  80. package/lib/commands/apps/secrets.js.map +1 -0
  81. package/lib/commands/{apps.d.ts → apps/sync.d.ts} +8 -7
  82. package/lib/commands/apps/sync.d.ts.map +1 -0
  83. package/lib/commands/apps/sync.js +76 -0
  84. package/lib/commands/apps/sync.js.map +1 -0
  85. package/lib/commands/apps/types.d.ts +54 -0
  86. package/lib/commands/apps/types.d.ts.map +1 -0
  87. package/lib/commands/apps/types.js +2 -0
  88. package/lib/commands/apps/types.js.map +1 -0
  89. package/lib/commands/apps/uninstall.d.ts +3 -0
  90. package/lib/commands/apps/uninstall.d.ts.map +1 -0
  91. package/lib/commands/apps/uninstall.js +23 -0
  92. package/lib/commands/apps/uninstall.js.map +1 -0
  93. package/lib/commands/balances/get.d.ts +12 -0
  94. package/lib/commands/balances/get.d.ts.map +1 -0
  95. package/lib/commands/balances/get.js +32 -0
  96. package/lib/commands/balances/get.js.map +1 -0
  97. package/lib/commands/balances/index.d.ts +2 -0
  98. package/lib/commands/balances/index.d.ts.map +1 -0
  99. package/lib/commands/balances/index.js +2 -0
  100. package/lib/commands/balances/index.js.map +1 -0
  101. package/lib/commands/books/create.d.ts +12 -0
  102. package/lib/commands/books/create.d.ts.map +1 -0
  103. package/lib/commands/books/create.js +37 -0
  104. package/lib/commands/books/create.js.map +1 -0
  105. package/lib/commands/books/get.d.ts +3 -0
  106. package/lib/commands/books/get.d.ts.map +1 -0
  107. package/lib/commands/books/get.js +17 -0
  108. package/lib/commands/books/get.js.map +1 -0
  109. package/lib/commands/books/index.d.ts +5 -0
  110. package/lib/commands/books/index.d.ts.map +1 -0
  111. package/lib/commands/books/index.js +5 -0
  112. package/lib/commands/books/index.js.map +1 -0
  113. package/lib/commands/books/list.d.ts +3 -0
  114. package/lib/commands/books/list.d.ts.map +1 -0
  115. package/lib/commands/books/list.js +17 -0
  116. package/lib/commands/books/list.js.map +1 -0
  117. package/lib/commands/books/update.d.ts +14 -0
  118. package/lib/commands/books/update.d.ts.map +1 -0
  119. package/lib/commands/books/update.js +46 -0
  120. package/lib/commands/books/update.js.map +1 -0
  121. package/lib/commands/collections/add-book.d.ts +3 -0
  122. package/lib/commands/collections/add-book.d.ts.map +1 -0
  123. package/lib/commands/collections/add-book.js +27 -0
  124. package/lib/commands/collections/add-book.js.map +1 -0
  125. package/lib/commands/collections/create.d.ts +6 -0
  126. package/lib/commands/collections/create.d.ts.map +1 -0
  127. package/lib/commands/collections/create.js +19 -0
  128. package/lib/commands/collections/create.js.map +1 -0
  129. package/lib/commands/collections/delete.d.ts +3 -0
  130. package/lib/commands/collections/delete.d.ts.map +1 -0
  131. package/lib/commands/collections/delete.js +22 -0
  132. package/lib/commands/collections/delete.js.map +1 -0
  133. package/lib/commands/collections/get.d.ts +3 -0
  134. package/lib/commands/collections/get.d.ts.map +1 -0
  135. package/lib/commands/collections/get.js +22 -0
  136. package/lib/commands/collections/get.js.map +1 -0
  137. package/lib/commands/collections/index.d.ts +8 -0
  138. package/lib/commands/collections/index.d.ts.map +1 -0
  139. package/lib/commands/collections/index.js +8 -0
  140. package/lib/commands/collections/index.js.map +1 -0
  141. package/lib/commands/collections/list.d.ts +3 -0
  142. package/lib/commands/collections/list.d.ts.map +1 -0
  143. package/lib/commands/collections/list.js +18 -0
  144. package/lib/commands/collections/list.js.map +1 -0
  145. package/lib/commands/collections/remove-book.d.ts +3 -0
  146. package/lib/commands/collections/remove-book.d.ts.map +1 -0
  147. package/lib/commands/collections/remove-book.js +27 -0
  148. package/lib/commands/collections/remove-book.js.map +1 -0
  149. package/lib/commands/collections/update.d.ts +6 -0
  150. package/lib/commands/collections/update.d.ts.map +1 -0
  151. package/lib/commands/collections/update.js +24 -0
  152. package/lib/commands/collections/update.js.map +1 -0
  153. package/lib/commands/groups/create.d.ts +9 -0
  154. package/lib/commands/groups/create.d.ts.map +1 -0
  155. package/lib/commands/groups/create.js +40 -0
  156. package/lib/commands/groups/create.js.map +1 -0
  157. package/lib/commands/groups/delete.d.ts +3 -0
  158. package/lib/commands/groups/delete.d.ts.map +1 -0
  159. package/lib/commands/groups/delete.js +22 -0
  160. package/lib/commands/groups/delete.js.map +1 -0
  161. package/lib/commands/groups/get.d.ts +3 -0
  162. package/lib/commands/groups/get.d.ts.map +1 -0
  163. package/lib/commands/groups/get.js +22 -0
  164. package/lib/commands/groups/get.js.map +1 -0
  165. package/lib/commands/groups/index.d.ts +6 -0
  166. package/lib/commands/groups/index.d.ts.map +1 -0
  167. package/lib/commands/groups/index.js +6 -0
  168. package/lib/commands/groups/index.js.map +1 -0
  169. package/lib/commands/groups/list.d.ts +3 -0
  170. package/lib/commands/groups/list.d.ts.map +1 -0
  171. package/lib/commands/groups/list.js +19 -0
  172. package/lib/commands/groups/list.js.map +1 -0
  173. package/lib/commands/groups/update.d.ts +8 -0
  174. package/lib/commands/groups/update.d.ts.map +1 -0
  175. package/lib/commands/groups/update.js +38 -0
  176. package/lib/commands/groups/update.js.map +1 -0
  177. package/lib/commands/skills.d.ts +17 -0
  178. package/lib/commands/skills.d.ts.map +1 -0
  179. package/lib/commands/skills.js +248 -0
  180. package/lib/commands/skills.js.map +1 -0
  181. package/lib/commands/transactions/check.d.ts +3 -0
  182. package/lib/commands/transactions/check.d.ts.map +1 -0
  183. package/lib/commands/transactions/check.js +22 -0
  184. package/lib/commands/transactions/check.js.map +1 -0
  185. package/lib/commands/transactions/create.d.ts +13 -0
  186. package/lib/commands/transactions/create.d.ts.map +1 -0
  187. package/lib/commands/transactions/create.js +55 -0
  188. package/lib/commands/transactions/create.js.map +1 -0
  189. package/lib/commands/transactions/index.d.ts +8 -0
  190. package/lib/commands/transactions/index.d.ts.map +1 -0
  191. package/lib/commands/transactions/index.js +8 -0
  192. package/lib/commands/transactions/index.js.map +1 -0
  193. package/lib/commands/transactions/list.d.ts +14 -0
  194. package/lib/commands/transactions/list.d.ts.map +1 -0
  195. package/lib/commands/transactions/list.js +26 -0
  196. package/lib/commands/transactions/list.js.map +1 -0
  197. package/lib/commands/transactions/merge.d.ts +8 -0
  198. package/lib/commands/transactions/merge.d.ts.map +1 -0
  199. package/lib/commands/transactions/merge.js +44 -0
  200. package/lib/commands/transactions/merge.js.map +1 -0
  201. package/lib/commands/transactions/post.d.ts +3 -0
  202. package/lib/commands/transactions/post.d.ts.map +1 -0
  203. package/lib/commands/transactions/post.js +22 -0
  204. package/lib/commands/transactions/post.js.map +1 -0
  205. package/lib/commands/transactions/trash.d.ts +3 -0
  206. package/lib/commands/transactions/trash.d.ts.map +1 -0
  207. package/lib/commands/transactions/trash.js +22 -0
  208. package/lib/commands/transactions/trash.js.map +1 -0
  209. package/lib/commands/transactions/update.d.ts +12 -0
  210. package/lib/commands/transactions/update.d.ts.map +1 -0
  211. package/lib/commands/transactions/update.js +53 -0
  212. package/lib/commands/transactions/update.js.map +1 -0
  213. package/lib/dev/auth-middleware.d.ts +18 -0
  214. package/lib/dev/auth-middleware.d.ts.map +1 -0
  215. package/lib/dev/auth-middleware.js +113 -0
  216. package/lib/dev/auth-middleware.js.map +1 -0
  217. package/lib/dev/cleanup.d.ts +10 -0
  218. package/lib/dev/cleanup.d.ts.map +1 -0
  219. package/lib/dev/cleanup.js +36 -0
  220. package/lib/dev/cleanup.js.map +1 -0
  221. package/lib/dev/cloudflared/constants.d.ts +35 -0
  222. package/lib/dev/cloudflared/constants.d.ts.map +1 -0
  223. package/lib/dev/cloudflared/constants.js +48 -0
  224. package/lib/dev/cloudflared/constants.js.map +1 -0
  225. package/lib/dev/cloudflared/index.d.ts +11 -0
  226. package/lib/dev/cloudflared/index.d.ts.map +1 -0
  227. package/lib/dev/cloudflared/index.js +10 -0
  228. package/lib/dev/cloudflared/index.js.map +1 -0
  229. package/lib/dev/cloudflared/install.d.ts +15 -0
  230. package/lib/dev/cloudflared/install.d.ts.map +1 -0
  231. package/lib/dev/cloudflared/install.js +140 -0
  232. package/lib/dev/cloudflared/install.js.map +1 -0
  233. package/lib/dev/cloudflared/tunnel.d.ts +64 -0
  234. package/lib/dev/cloudflared/tunnel.d.ts.map +1 -0
  235. package/lib/dev/cloudflared/tunnel.js +109 -0
  236. package/lib/dev/cloudflared/tunnel.js.map +1 -0
  237. package/lib/dev/esbuild.d.ts +28 -0
  238. package/lib/dev/esbuild.d.ts.map +1 -0
  239. package/lib/dev/esbuild.js +83 -0
  240. package/lib/dev/esbuild.js.map +1 -0
  241. package/lib/dev/logger.d.ts +51 -0
  242. package/lib/dev/logger.d.ts.map +1 -0
  243. package/lib/dev/logger.js +102 -0
  244. package/lib/dev/logger.js.map +1 -0
  245. package/lib/dev/miniflare.d.ts +32 -0
  246. package/lib/dev/miniflare.d.ts.map +1 -0
  247. package/lib/dev/miniflare.js +111 -0
  248. package/lib/dev/miniflare.js.map +1 -0
  249. package/lib/dev/preflight.d.ts +7 -0
  250. package/lib/dev/preflight.d.ts.map +1 -0
  251. package/lib/dev/preflight.js +61 -0
  252. package/lib/dev/preflight.js.map +1 -0
  253. package/lib/dev/shared.d.ts +7 -0
  254. package/lib/dev/shared.d.ts.map +1 -0
  255. package/lib/dev/shared.js +99 -0
  256. package/lib/dev/shared.js.map +1 -0
  257. package/lib/dev/tunnel.d.ts +31 -0
  258. package/lib/dev/tunnel.d.ts.map +1 -0
  259. package/lib/dev/tunnel.js +110 -0
  260. package/lib/dev/tunnel.js.map +1 -0
  261. package/lib/dev/types.d.ts +53 -0
  262. package/lib/dev/types.d.ts.map +1 -0
  263. package/lib/dev/types.js +223 -0
  264. package/lib/dev/types.js.map +1 -0
  265. package/lib/dev/vite.d.ts +50 -0
  266. package/lib/dev/vite.d.ts.map +1 -0
  267. package/lib/dev/vite.js +114 -0
  268. package/lib/dev/vite.js.map +1 -0
  269. package/lib/dev/webhook-dev.d.ts +9 -0
  270. package/lib/dev/webhook-dev.d.ts.map +1 -0
  271. package/lib/dev/webhook-dev.js +28 -0
  272. package/lib/dev/webhook-dev.js.map +1 -0
  273. package/lib/domain/transaction/merge-operation.d.ts.map +1 -0
  274. package/lib/{mcp/domain → domain}/transaction/merge-operation.js +10 -11
  275. package/lib/domain/transaction/merge-operation.js.map +1 -0
  276. package/lib/domain/transaction/merge-types.d.ts.map +1 -0
  277. package/lib/domain/transaction/merge-types.js.map +1 -0
  278. package/lib/index.d.ts.map +1 -1
  279. package/lib/index.js.map +1 -1
  280. package/lib/platform/client.d.ts +37 -0
  281. package/lib/platform/client.d.ts.map +1 -0
  282. package/lib/platform/client.js +37 -0
  283. package/lib/platform/client.js.map +1 -0
  284. package/lib/render/index.d.ts +3 -0
  285. package/lib/render/index.d.ts.map +1 -0
  286. package/lib/render/index.js +3 -0
  287. package/lib/render/index.js.map +1 -0
  288. package/lib/render/output.d.ts +15 -0
  289. package/lib/render/output.d.ts.map +1 -0
  290. package/lib/render/output.js +30 -0
  291. package/lib/render/output.js.map +1 -0
  292. package/lib/render/table-formatter.d.ts +34 -0
  293. package/lib/render/table-formatter.d.ts.map +1 -0
  294. package/lib/render/table-formatter.js +221 -0
  295. package/lib/render/table-formatter.js.map +1 -0
  296. package/lib/utils/properties.d.ts +12 -0
  297. package/lib/utils/properties.d.ts.map +1 -0
  298. package/lib/utils/properties.js +23 -0
  299. package/lib/utils/properties.js.map +1 -0
  300. package/package.json +23 -23
  301. package/lib/auth/keys.json +0 -12
  302. package/lib/commands/apps.d.ts.map +0 -1
  303. package/lib/commands/apps.js +0 -93
  304. package/lib/commands/apps.js.map +0 -1
  305. package/lib/mcp/bkper-factory.d.ts.map +0 -1
  306. package/lib/mcp/bkper-factory.js.map +0 -1
  307. package/lib/mcp/domain/transaction/merge-operation.d.ts.map +0 -1
  308. package/lib/mcp/domain/transaction/merge-operation.js.map +0 -1
  309. package/lib/mcp/domain/transaction/merge-types.d.ts.map +0 -1
  310. package/lib/mcp/domain/transaction/merge-types.js.map +0 -1
  311. package/lib/mcp/server.d.ts +0 -13
  312. package/lib/mcp/server.d.ts.map +0 -1
  313. package/lib/mcp/server.js +0 -161
  314. package/lib/mcp/server.js.map +0 -1
  315. package/lib/mcp/system-prompt.md +0 -192
  316. package/lib/mcp/tools/create_transactions.d.ts +0 -59
  317. package/lib/mcp/tools/create_transactions.d.ts.map +0 -1
  318. package/lib/mcp/tools/create_transactions.js +0 -163
  319. package/lib/mcp/tools/create_transactions.js.map +0 -1
  320. package/lib/mcp/tools/get_balances.d.ts +0 -26
  321. package/lib/mcp/tools/get_balances.d.ts.map +0 -1
  322. package/lib/mcp/tools/get_balances.js +0 -106
  323. package/lib/mcp/tools/get_balances.js.map +0 -1
  324. package/lib/mcp/tools/get_book.d.ts +0 -21
  325. package/lib/mcp/tools/get_book.d.ts.map +0 -1
  326. package/lib/mcp/tools/get_book.js +0 -126
  327. package/lib/mcp/tools/get_book.js.map +0 -1
  328. package/lib/mcp/tools/list_books.d.ts +0 -21
  329. package/lib/mcp/tools/list_books.d.ts.map +0 -1
  330. package/lib/mcp/tools/list_books.js +0 -67
  331. package/lib/mcp/tools/list_books.js.map +0 -1
  332. package/lib/mcp/tools/list_transactions.d.ts +0 -38
  333. package/lib/mcp/tools/list_transactions.d.ts.map +0 -1
  334. package/lib/mcp/tools/list_transactions.js +0 -109
  335. package/lib/mcp/tools/list_transactions.js.map +0 -1
  336. package/lib/mcp/tools/merge_transactions.d.ts +0 -40
  337. package/lib/mcp/tools/merge_transactions.d.ts.map +0 -1
  338. package/lib/mcp/tools/merge_transactions.js +0 -120
  339. package/lib/mcp/tools/merge_transactions.js.map +0 -1
  340. /package/lib/{mcp/bkper-factory.d.ts → bkper-factory.d.ts} +0 -0
  341. /package/lib/{mcp/domain → domain}/transaction/merge-operation.d.ts +0 -0
  342. /package/lib/{mcp/domain → domain}/transaction/merge-types.d.ts +0 -0
  343. /package/lib/{mcp/domain → domain}/transaction/merge-types.js +0 -0
@@ -1,106 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
11
- import { getBkperInstance } from '../bkper-factory.js';
12
- import { BalanceType } from 'bkper-js';
13
- export function handleGetBalances(params) {
14
- return __awaiter(this, void 0, void 0, function* () {
15
- try {
16
- // Validate required parameters
17
- if (!params.bookId) {
18
- throw new McpError(ErrorCode.InvalidParams, 'Missing required parameter: bookId');
19
- }
20
- if (!params.query) {
21
- throw new McpError(ErrorCode.InvalidParams, 'Missing required parameter: query');
22
- }
23
- // Validate query contains either group: or account: operator
24
- if (!params.query.includes('group:') && !params.query.includes('account:')) {
25
- throw new McpError(ErrorCode.InvalidParams, 'Query must include either \'group:\' or \'account:\' operator for proper balance filtering. Example: "group:\'Assets\' before:$m" or "account:\'Cash\' before:$m"');
26
- }
27
- // Get configured Bkper instance
28
- const bkper = getBkperInstance();
29
- // Get the book first
30
- const book = yield bkper.getBook(params.bookId, true);
31
- if (!book) {
32
- throw new McpError(ErrorCode.InvalidParams, `Book not found: ${params.bookId}`);
33
- }
34
- // Get balances from the book with query (required by bkper-js)
35
- let actualQuery = params.query;
36
- // Enforce monthly periodicity by modifying query
37
- if (actualQuery.includes('by:d')) {
38
- // Replace daily periodicity with monthly
39
- actualQuery = actualQuery.replace(/by:d/g, 'by:m');
40
- }
41
- else if (actualQuery.includes('by:y')) {
42
- // Replace yearly periodicity with monthly
43
- actualQuery = actualQuery.replace(/by:y/g, 'by:m');
44
- }
45
- else if (!actualQuery.includes('by:')) {
46
- // Append monthly periodicity if no by: operator present
47
- actualQuery = actualQuery + ' by:m';
48
- }
49
- // If by:m is already present, keep it unchanged
50
- // Get the first container to access createDataTable
51
- const balancesReport = yield book.getBalancesReport(actualQuery);
52
- // Determine balance type based on presence of after: operator
53
- const type = actualQuery.includes('after:') ? BalanceType.PERIOD : BalanceType.CUMULATIVE;
54
- // Use BalancesDataTableBuilder to generate matrix
55
- let matrix;
56
- // Get the first container to access createDataTable
57
- const dataTableBuilder = balancesReport.createDataTable()
58
- .formatValues(false) // Raw numbers for LLMs
59
- .formatDates(true) // YYYY-MM-DD dates
60
- .raw(true) // Raw balances
61
- .expanded(4)
62
- .type(type); //
63
- matrix = dataTableBuilder.build();
64
- // Build response with matrix format
65
- const response = {
66
- matrix,
67
- query: actualQuery
68
- };
69
- return {
70
- content: [
71
- {
72
- type: 'text',
73
- text: JSON.stringify(response, null, 2),
74
- },
75
- ],
76
- };
77
- }
78
- catch (error) {
79
- // Re-throw MCP errors as-is
80
- if (error instanceof McpError) {
81
- throw error;
82
- }
83
- // Handle other errors
84
- throw new McpError(ErrorCode.InternalError, `Failed to get balances: ${error instanceof Error ? error.message : String(error)}`);
85
- }
86
- });
87
- }
88
- export const getBalancesToolDefinition = {
89
- name: 'get_balances',
90
- description: 'Get account balances with query filtering. Use get_book first to understand group hierarchy and usage rules.',
91
- inputSchema: {
92
- type: 'object',
93
- properties: {
94
- bookId: {
95
- type: 'string',
96
- description: 'The unique identifier of the book'
97
- },
98
- query: {
99
- type: 'string',
100
- description: 'Required query to filter balances (e.g., "account:\'Cash\'", "group:\'Assets\'", "before:2024-01-31")'
101
- }
102
- },
103
- required: ['bookId', 'query']
104
- }
105
- };
106
- //# sourceMappingURL=get_balances.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get_balances.js","sourceRoot":"","sources":["../../../src/mcp/tools/get_balances.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAkB,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;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AI,KAAK,YAAY,QAAQ,EAAE,CAAC;gBAC9B,MAAM,KAAK,CAAC;YACd,CAAC;YAED,sBAAsB;YACtB,MAAM,IAAI,QAAQ,CAChB,SAAS,CAAC,aAAa,EACvB,2BAA2B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACpF,CAAC;QACJ,CAAC;IACH,CAAC;CAAA;AAED,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,8GAA8G;IAC3H,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,mCAAmC;aACjD;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uGAAuG;aACrH;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;KAC9B;CACF,CAAC"}
@@ -1,21 +0,0 @@
1
- import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
- interface GetBookParams {
3
- bookId: string;
4
- }
5
- export declare function handleGetBook(params: GetBookParams): Promise<CallToolResult>;
6
- export declare const getBookToolDefinition: {
7
- name: string;
8
- description: string;
9
- inputSchema: {
10
- type: string;
11
- properties: {
12
- bookId: {
13
- type: string;
14
- description: string;
15
- };
16
- };
17
- required: string[];
18
- };
19
- };
20
- export {};
21
- //# sourceMappingURL=get_book.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get_book.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/get_book.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,oCAAoC,CAAC;AAOzF,UAAU,aAAa;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AAkED,wBAAsB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAqElF;AAED,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;CAajC,CAAC"}
@@ -1,126 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
11
- import { getBkperInstance } from '../bkper-factory.js';
12
- import { readFileSync } from 'fs';
13
- import { join, dirname } from 'path';
14
- import { fileURLToPath } from 'url';
15
- function buildHierarchicalStructure(groups) {
16
- const groupMap = new Map();
17
- const rootGroups = [];
18
- // First pass: create all group nodes
19
- groups.forEach(group => {
20
- const node = {
21
- id: group.getId() || '',
22
- name: group.getName() || '',
23
- type: group.getType() || '',
24
- hidden: group.isHidden() || false,
25
- permanent: group.isPermanent() || false,
26
- properties: group.getProperties() || {},
27
- children: []
28
- };
29
- groupMap.set(node.id, node);
30
- });
31
- // Second pass: build hierarchy
32
- groups.forEach(group => {
33
- const node = groupMap.get(group.getId() || '');
34
- if (!node)
35
- return;
36
- const parent = group.getParent();
37
- if (parent) {
38
- const parentNode = groupMap.get(parent.getId() || '');
39
- if (parentNode) {
40
- parentNode.children.push(node);
41
- }
42
- }
43
- else {
44
- // No parent = root group
45
- rootGroups.push(node);
46
- }
47
- });
48
- return rootGroups;
49
- }
50
- function loadSystemPrompt() {
51
- try {
52
- // Get the directory where this file is located and navigate to the parent mcp directory
53
- const __filename = fileURLToPath(import.meta.url);
54
- const __dirname = dirname(__filename);
55
- const mcpPath = join(__dirname, '..');
56
- const systemPrompt = readFileSync(join(mcpPath, 'system-prompt.md'), 'utf-8');
57
- return systemPrompt;
58
- }
59
- catch (error) {
60
- return `# Bkper MCP System Prompt\n\nDocumentation not available.\nError: ${error instanceof Error ? error.message : String(error)}\nPath attempted: ${join(dirname(fileURLToPath(import.meta.url)), '..', 'system-prompt.md')}`;
61
- }
62
- }
63
- export function handleGetBook(params) {
64
- return __awaiter(this, void 0, void 0, function* () {
65
- try {
66
- // Validate required parameters
67
- if (!params.bookId) {
68
- throw new McpError(ErrorCode.InvalidParams, 'Missing required parameter: bookId');
69
- }
70
- // Get configured Bkper instance
71
- const bkperInstance = getBkperInstance();
72
- // Get the specific book
73
- const book = yield bkperInstance.getBook(params.bookId, false, true);
74
- if (!book) {
75
- throw new McpError(ErrorCode.InvalidParams, `Book not found: ${params.bookId}`);
76
- }
77
- // Get book JSON data
78
- const bookJson = book.json();
79
- // Get groups from the book
80
- const groups = yield book.getGroups();
81
- // Build hierarchical structure
82
- const hierarchicalGroups = buildHierarchicalStructure(groups || []);
83
- bookJson.groups = hierarchicalGroups;
84
- // Build response with book data and groups
85
- const response = {
86
- book: bookJson,
87
- readme: loadSystemPrompt()
88
- };
89
- return {
90
- content: [
91
- {
92
- type: 'text',
93
- text: JSON.stringify(response, null, 2),
94
- },
95
- ],
96
- };
97
- }
98
- catch (error) {
99
- // Handle specific book not found errors
100
- if (error instanceof Error && error.message.includes('not found')) {
101
- throw new McpError(ErrorCode.InvalidParams, `Book not found: ${params.bookId}`);
102
- }
103
- // Re-throw MCP errors as-is
104
- if (error instanceof McpError) {
105
- throw error;
106
- }
107
- // Handle other errors
108
- throw new McpError(ErrorCode.InternalError, `Failed to get book: ${error instanceof Error ? error.message : String(error)}`);
109
- }
110
- });
111
- }
112
- export const getBookToolDefinition = {
113
- name: 'get_book',
114
- description: 'Retrieve detailed information about a specific book including its group hierarchy and system prompt',
115
- inputSchema: {
116
- type: 'object',
117
- properties: {
118
- bookId: {
119
- type: 'string',
120
- description: 'The unique identifier of the book to retrieve'
121
- }
122
- },
123
- required: ['bookId']
124
- }
125
- };
126
- //# sourceMappingURL=get_book.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get_book.js","sourceRoot":"","sources":["../../../src/mcp/tools/get_book.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAkB,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAgBpC,SAAS,0BAA0B,CAAC,MAAe;IACjD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAqB,CAAC;IAC9C,MAAM,UAAU,GAAgB,EAAE,CAAC;IAEnC,qCAAqC;IACrC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACrB,MAAM,IAAI,GAAc;YACtB,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE;YACvB,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE;YAC3B,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE;YAC3B,MAAM,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI,KAAK;YACjC,SAAS,EAAE,KAAK,CAAC,WAAW,EAAE,IAAI,KAAK;YACvC,UAAU,EAAE,KAAK,CAAC,aAAa,EAAE,IAAI,EAAE;YACvC,QAAQ,EAAE,EAAE;SACb,CAAC;QAEF,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,+BAA+B;IAC/B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACrB,MAAM,IAAI,GAAG,QAAQ,CAAC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E,CAAC;gBAClE,MAAM,IAAI,QAAQ,CAChB,SAAS,CAAC,aAAa,EACvB,mBAAmB,MAAM,CAAC,MAAM,EAAE,CACnC,CAAC;YACJ,CAAC;YAED,4BAA4B;YAC5B,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;gBAC9B,MAAM,KAAK,CAAC;YACd,CAAC;YAED,sBAAsB;YACtB,MAAM,IAAI,QAAQ,CAChB,SAAS,CAAC,aAAa,EACvB,uBAAuB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAChF,CAAC;QACJ,CAAC;IACH,CAAC;CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,qGAAqG;IAClH,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,+CAA+C;aAC7D;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;KACrB;CACF,CAAC"}
@@ -1,21 +0,0 @@
1
- import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
- interface ListBooksParams {
3
- filter: string;
4
- }
5
- export declare function handleListBooks(params: ListBooksParams): Promise<CallToolResult>;
6
- export declare const listBooksToolDefinition: {
7
- name: string;
8
- description: string;
9
- inputSchema: {
10
- type: string;
11
- properties: {
12
- filter: {
13
- type: string;
14
- description: string;
15
- };
16
- };
17
- required: string[];
18
- };
19
- };
20
- export {};
21
- //# sourceMappingURL=list_books.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"list_books.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/list_books.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,oCAAoC,CAAC;AAGzF,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAsBD,wBAAsB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CA+BtF;AAED,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;CAanC,CAAC"}
@@ -1,67 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
11
- import { getBkperInstance } from '../bkper-factory.js';
12
- function fetchBooks(filter) {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- // Get configured Bkper instance
15
- const bkperInstance = getBkperInstance();
16
- // Get books using high-level wrapper with required filter
17
- const bkperBooks = yield bkperInstance.getBooks(filter);
18
- // Return full book JSON data - no filtering, no transforming
19
- const books = bkperBooks.map((book) => book.json());
20
- const total = books.length;
21
- return { books, total };
22
- });
23
- }
24
- export function handleListBooks(params) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- try {
27
- // Fetch all books with required filter
28
- const { books, total } = yield fetchBooks(params.filter);
29
- // Build response
30
- const response = {
31
- total,
32
- books
33
- };
34
- return {
35
- content: [
36
- {
37
- type: 'text',
38
- text: JSON.stringify(response, null, 2),
39
- },
40
- ],
41
- };
42
- }
43
- catch (error) {
44
- // Re-throw MCP errors as-is
45
- if (error instanceof McpError) {
46
- throw error;
47
- }
48
- // Handle other errors
49
- throw new McpError(ErrorCode.InternalError, `Failed to list books: ${error instanceof Error ? error.message : String(error)}`);
50
- }
51
- });
52
- }
53
- export const listBooksToolDefinition = {
54
- name: 'list_books',
55
- description: 'List books with mandatory filtering by name or property',
56
- inputSchema: {
57
- type: 'object',
58
- properties: {
59
- filter: {
60
- type: 'string',
61
- description: 'Required filter to search books by name or property (case-insensitive substring match)'
62
- }
63
- },
64
- required: ['filter']
65
- }
66
- };
67
- //# sourceMappingURL=list_books.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"list_books.js","sourceRoot":"","sources":["../../../src/mcp/tools/list_books.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAkB,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAWvD,SAAe,UAAU,CAAC,MAAc;;QACtC,gCAAgC;QAChC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;QAEzC,0DAA0D;QAC1D,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAExD,6DAA6D;QAC7D,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAEzD,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;QAE3B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC1B,CAAC;CAAA;AAED,MAAM,UAAgB,eAAe,CAAC,MAAuB;;QAC3D,IAAI,CAAC;YACH,uCAAuC;YACvC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAEzD,iBAAiB;YACjB,MAAM,QAAQ,GAAkB;gBAC9B,KAAK;gBACL,KAAK;aACN,CAAC;YAEF,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;qBACxC;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,4BAA4B;YAC5B,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;gBAC9B,MAAM,KAAK,CAAC;YACd,CAAC;YAED,sBAAsB;YACtB,MAAM,IAAI,QAAQ,CAChB,SAAS,CAAC,aAAa,EACvB,yBAAyB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAClF,CAAC;QACJ,CAAC;IACH,CAAC;CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,yDAAyD;IACtE,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,wFAAwF;aACtG;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;KACrB;CACF,CAAC"}
@@ -1,38 +0,0 @@
1
- import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
- interface ListTransactionsParams {
3
- bookId: string;
4
- cursor?: string;
5
- query: string;
6
- limit?: number;
7
- }
8
- export declare function handleListTransactions(params: ListTransactionsParams): Promise<CallToolResult>;
9
- export declare const listTransactionsToolDefinition: {
10
- name: string;
11
- description: string;
12
- inputSchema: {
13
- type: string;
14
- properties: {
15
- bookId: {
16
- type: string;
17
- description: string;
18
- };
19
- cursor: {
20
- type: string;
21
- description: string;
22
- };
23
- query: {
24
- type: string;
25
- description: string;
26
- };
27
- limit: {
28
- type: string;
29
- description: string;
30
- minimum: number;
31
- maximum: number;
32
- };
33
- };
34
- required: string[];
35
- };
36
- };
37
- export {};
38
- //# sourceMappingURL=list_transactions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"list_transactions.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/list_transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,oCAAoC,CAAC;AAGzF,UAAU,sBAAsB;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAUD,wBAAsB,sBAAsB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,cAAc,CAAC,CAuFpG;AAED,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B1C,CAAC"}
@@ -1,109 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __rest = (this && this.__rest) || function (s, e) {
11
- var t = {};
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
- t[p] = s[p];
14
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
- t[p[i]] = s[p[i]];
18
- }
19
- return t;
20
- };
21
- import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
22
- import { getBkperInstance } from '../bkper-factory.js';
23
- export function handleListTransactions(params) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- try {
26
- // Validate required parameters
27
- if (!params.bookId) {
28
- throw new McpError(ErrorCode.InvalidParams, 'Missing required parameter: bookId');
29
- }
30
- if (!params.query) {
31
- throw new McpError(ErrorCode.InvalidParams, 'Missing required parameter: query');
32
- }
33
- // Get configured Bkper instance
34
- const bkperInstance = getBkperInstance();
35
- // Get the book first
36
- const book = yield bkperInstance.getBook(params.bookId);
37
- if (!book) {
38
- throw new McpError(ErrorCode.InvalidParams, `Book not found: ${params.bookId}`);
39
- }
40
- // Set up pagination parameters
41
- const limit = Math.min(params.limit || 25, 100); // Default 25, max 100
42
- // Get transactions using native API pagination
43
- const transactionList = yield book.listTransactions(params.query, limit, params.cursor);
44
- // Get transactions from list
45
- const transactionItems = transactionList.getItems();
46
- const transactions = transactionItems.map((transaction) => {
47
- const _a = transaction.json(), { agentId, agentName, agentLogo, agentLogoDark, createdAt, createdBy, updatedAt, dateValue } = _a, cleanTransaction = __rest(_a, ["agentId", "agentName", "agentLogo", "agentLogoDark", "createdAt", "createdBy", "updatedAt", "dateValue"]);
48
- return cleanTransaction;
49
- });
50
- // Get pagination info from list
51
- const hasMore = transactionItems.length > 0;
52
- const nextCursor = transactionList.getCursor() || null;
53
- // Build response
54
- const response = {
55
- transactions,
56
- hasMore,
57
- cursor: nextCursor,
58
- limit
59
- };
60
- // Include query in response (now always provided)
61
- response.query = params.query;
62
- return {
63
- content: [
64
- {
65
- type: 'text',
66
- text: JSON.stringify(response, null, 2),
67
- },
68
- ],
69
- };
70
- }
71
- catch (error) {
72
- // Re-throw MCP errors as-is
73
- if (error instanceof McpError) {
74
- throw error;
75
- }
76
- // Handle other errors
77
- throw new McpError(ErrorCode.InternalError, `Failed to list transactions: ${error instanceof Error ? error.message : String(error)}`);
78
- }
79
- });
80
- }
81
- export const listTransactionsToolDefinition = {
82
- name: 'list_transactions',
83
- description: 'List transactions with native API cursor-based pagination and query filtering. Use get_book first to understand query syntax and usage rules.',
84
- inputSchema: {
85
- type: 'object',
86
- properties: {
87
- bookId: {
88
- type: 'string',
89
- description: 'The unique identifier of the book'
90
- },
91
- cursor: {
92
- type: 'string',
93
- description: 'Pagination cursor for next page (provided by previous response)'
94
- },
95
- query: {
96
- type: 'string',
97
- description: 'Required query string to filter transactions using comprehensive syntax (account:, from:, to:, group:, on:, after:, before:, amount:, text search, logical operators, etc.)'
98
- },
99
- limit: {
100
- type: 'number',
101
- description: 'Number of transactions per page (default: 25, maximum: 100)',
102
- minimum: 1,
103
- maximum: 100
104
- }
105
- },
106
- required: ['bookId', 'query']
107
- }
108
- };
109
- //# sourceMappingURL=list_transactions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"list_transactions.js","sourceRoot":"","sources":["../../../src/mcp/tools/list_transactions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAkB,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAiBvD,MAAM,UAAgB,sBAAsB,CAAC,MAA8B;;QACzE,IAAI,CAAC;YACH,+BAA+B;YAC/B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACnB,MAAM,IAAI,QAAQ,CAChB,SAAS,CAAC,aAAa,EACvB,oCAAoC,CACrC,CAAC;YACJ,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;gBAClB,MAAM,IAAI,QAAQ,CAChB,SAAS,CAAC,aAAa,EACvB,mCAAmC,CACpC,CAAC;YACJ,CAAC;YAED,gCAAgC;YAChC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;YAEzC,qBAAqB;YACrB,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACxD,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,IAAI,QAAQ,CAChB,SAAS,CAAC,aAAa,EACvB,mBAAmB,MAAM,CAAC,MAAM,EAAE,CACnC,CAAC;YACJ,CAAC;YAED,+BAA+B;Y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E,CAAC;gBAC9B,MAAM,KAAK,CAAC;YACd,CAAC;YAED,sBAAsB;YACtB,MAAM,IAAI,QAAQ,CAChB,SAAS,CAAC,aAAa,EACvB,gCAAgC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACzF,CAAC;QACJ,CAAC;IACH,CAAC;CAAA;AAED,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,+IAA+I;IAC5J,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,mCAAmC;aACjD;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iEAAiE;aAC/E;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,6KAA6K;aAC3L;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,6DAA6D;gBAC1E,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,GAAG;aACb;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;KAC9B;CACF,CAAC"}
@@ -1,40 +0,0 @@
1
- /**
2
- * MCP Tool: merge_transactions
3
- *
4
- * Thin adapter that handles MCP protocol concerns (validation, error handling, response formatting)
5
- * and delegates business logic to the domain layer.
6
- */
7
- import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
8
- /**
9
- * MCP-specific request parameters
10
- */
11
- interface MergeTransactionsParams {
12
- bookId: string;
13
- transactionId1: string;
14
- transactionId2: string;
15
- }
16
- export declare function handleMergeTransactions(params: MergeTransactionsParams): Promise<CallToolResult>;
17
- export declare const mergeTransactionsToolDefinition: {
18
- name: string;
19
- description: string;
20
- inputSchema: {
21
- type: string;
22
- properties: {
23
- bookId: {
24
- type: string;
25
- description: string;
26
- };
27
- transactionId1: {
28
- type: string;
29
- description: string;
30
- };
31
- transactionId2: {
32
- type: string;
33
- description: string;
34
- };
35
- };
36
- required: string[];
37
- };
38
- };
39
- export {};
40
- //# sourceMappingURL=merge_transactions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"merge_transactions.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/merge_transactions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAuB,MAAM,oCAAoC,CAAC;AAKzF;;GAEG;AACH,UAAU,uBAAuB;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CAC1B;AAWD,wBAAsB,uBAAuB,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,cAAc,CAAC,CA6GtG;AAED,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;CAqB3C,CAAC"}