bkper 3.8.0 → 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 +839 -67
  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 -22
  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
package/lib/mcp/server.js DELETED
@@ -1,161 +0,0 @@
1
- #!/usr/bin/env node
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- import dotenv from 'dotenv';
12
- dotenv.config();
13
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
14
- import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
15
- import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, McpError, } from '@modelcontextprotocol/sdk/types.js';
16
- import { handleGetBook, getBookToolDefinition } from './tools/get_book.js';
17
- import { handleGetBalances, getBalancesToolDefinition } from './tools/get_balances.js';
18
- import { handleListTransactions, listTransactionsToolDefinition } from './tools/list_transactions.js';
19
- import { handleListBooks, listBooksToolDefinition } from './tools/list_books.js';
20
- import { handleCreateTransactions, createTransactionsToolDefinition } from './tools/create_transactions.js';
21
- import { handleMergeTransactions, mergeTransactionsToolDefinition } from './tools/merge_transactions.js';
22
- class BkperMcpServer {
23
- constructor() {
24
- this.server = new Server({
25
- name: 'bkper-mcp-server',
26
- version: '1.0.0',
27
- }, {
28
- capabilities: {
29
- tools: {}
30
- }
31
- });
32
- this.setupToolHandlers();
33
- this.setupErrorHandling();
34
- }
35
- setupToolHandlers() {
36
- this.server.setRequestHandler(ListToolsRequestSchema, () => __awaiter(this, void 0, void 0, function* () {
37
- return {
38
- tools: [
39
- listBooksToolDefinition,
40
- getBookToolDefinition,
41
- getBalancesToolDefinition,
42
- listTransactionsToolDefinition,
43
- createTransactionsToolDefinition,
44
- mergeTransactionsToolDefinition,
45
- ],
46
- };
47
- }));
48
- this.server.setRequestHandler(CallToolRequestSchema, (request) => __awaiter(this, void 0, void 0, function* () {
49
- const toolName = request.params.name;
50
- const toolArgs = request.params.arguments;
51
- let result;
52
- try {
53
- switch (toolName) {
54
- case 'list_books':
55
- result = yield handleListBooks(toolArgs);
56
- break;
57
- case 'get_book':
58
- result = yield handleGetBook(toolArgs);
59
- break;
60
- case 'get_balances':
61
- result = yield handleGetBalances(toolArgs);
62
- break;
63
- case 'list_transactions':
64
- result = yield handleListTransactions(toolArgs);
65
- break;
66
- case 'create_transactions':
67
- result = yield handleCreateTransactions(toolArgs);
68
- break;
69
- case 'merge_transactions':
70
- result = yield handleMergeTransactions(toolArgs);
71
- break;
72
- default:
73
- throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${toolName}`);
74
- }
75
- return result;
76
- }
77
- catch (error) {
78
- // Only log actual errors, not debug info
79
- if (!(error instanceof McpError)) {
80
- // Convert unexpected errors to MCP errors
81
- throw new McpError(ErrorCode.InternalError, `Tool ${toolName} failed: ${error instanceof Error ? error.message : String(error)}`);
82
- }
83
- throw error;
84
- }
85
- }));
86
- }
87
- setupErrorHandling() {
88
- this.server.onerror = (error) => {
89
- // Log critical server errors to a file or syslog in production
90
- // Avoid console output during MCP stdio mode as it contaminates the stream
91
- if (process.env.NODE_ENV !== 'production') {
92
- // In development, log to stderr only if not in MCP mode
93
- const isStdioMode = process.argv.includes('mcp') && process.argv.includes('start');
94
- if (!isStdioMode) {
95
- console.error('[MCP Server Error]:', error instanceof Error ? error.message : String(error));
96
- }
97
- }
98
- // TODO: In production, implement proper logging to file/syslog
99
- // Example: logger.error('MCP Server Error', { error: error.message, stack: error.stack });
100
- };
101
- process.on('SIGINT', () => __awaiter(this, void 0, void 0, function* () {
102
- yield this.server.close();
103
- process.exit(0);
104
- }));
105
- }
106
- run() {
107
- return __awaiter(this, void 0, void 0, function* () {
108
- try {
109
- const transport = new StdioServerTransport();
110
- yield this.server.connect(transport);
111
- // Server is now ready and listening on stdio
112
- }
113
- catch (error) {
114
- // Do not log startup errors as they contaminate stdio stream
115
- throw error;
116
- }
117
- });
118
- }
119
- // Test helper methods for accessing MCP handlers directly
120
- testListTools() {
121
- return __awaiter(this, void 0, void 0, function* () {
122
- // Call the list tools handler directly for testing
123
- const requestHandlers = this.server._requestHandlers;
124
- const handler = requestHandlers.get('tools/list');
125
- if (!handler)
126
- throw new Error('ListTools handler not found');
127
- // Create proper MCP request format
128
- const request = {
129
- method: 'tools/list',
130
- params: {}
131
- };
132
- return yield handler(request);
133
- });
134
- }
135
- testCallTool(name_1) {
136
- return __awaiter(this, arguments, void 0, function* (name, args = {}) {
137
- // Call the call tool handler directly for testing
138
- const requestHandlers = this.server._requestHandlers;
139
- const handler = requestHandlers.get('tools/call');
140
- if (!handler)
141
- throw new Error('CallTool handler not found');
142
- // Create proper MCP request format
143
- const request = {
144
- method: 'tools/call',
145
- params: { name, arguments: args }
146
- };
147
- return yield handler(request);
148
- });
149
- }
150
- }
151
- // Export the class for testing
152
- export { BkperMcpServer };
153
- // Only run the server if this file is executed directly
154
- if (import.meta.url === `file://${process.argv[1]}`) {
155
- const server = new BkperMcpServer();
156
- server.run().catch(() => {
157
- // Exit silently on error to avoid contaminating stdio stream
158
- process.exit(1);
159
- });
160
- }
161
- //# sourceMappingURL=server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":";;;;;;;;;;AAEA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EAErB,SAAS,EACT,sBAAsB,EAEtB,QAAQ,GACT,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,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,IAAY,EAAE,OAAgC,EAAE;YACjE,oDAAoD;YACpD,MAAM,eAAe,GAAI,IAAI,CAAC,MAAc,CAAC,gBAAgB,CAAC;YAC9D,MAAM,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YAClD,IAAI,CAAC,OAAO;gBAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;YAE5D,mCAAmC;YACnC,MAAM,OAAO,GAAG;gBACd,MAAM,EAAE,YAAqB;gBAC7B,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;aAClC,CAAC;YACF,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;KAAA;CAEF;AAED,+BAA+B;AAC/B,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,wDAAwD;AACxD,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACpD,MAAM,MAAM,GAAG,IAAI,cAAc,EAAE,CAAC;IACpC,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;QACtB,6DAA6D;QAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,192 +0,0 @@
1
- # Bkper MCP Usage Guide
2
-
3
- ## Essential Tools
4
-
5
- ### Discovery
6
- - `list_books()` - Find available books
7
- - `get_book({ bookId })` - Book details, structure, and group hierarchies
8
-
9
- ### Analysis
10
- - `get_balances({ bookId, query })` - **THE** tool for all balance analysis
11
- - `list_transactions({ bookId, query })` - Transaction inspection only (never for balance calculations)
12
-
13
- ## Core Rules
14
-
15
- ### 1. Root Group Discovery
16
- **Always discover and use root groups dynamically based on account group types:**
17
- 1. Call `get_book({ bookId })` to see the hierarchy
18
- 2. Look for the top-level group that contains:
19
- - **For Balance Sheet**: Both ASSET and LIABILITY account types
20
- - **For P&L**: Both INCOMING and OUTGOING account types
21
- 3. Use that group name (not its children) in your queries
22
-
23
- **Example**: If you see this structure:
24
- ```
25
- "Total Equity" (root)
26
- ├── "Assets" (type: ASSET)
27
- ├── "Liabilities" (type: LIABILITY)
28
- ```
29
- Then use `group:'Total Equity'` - NOT `group:'Assets'` or `group:'Liabilities'`
30
-
31
- ### 2. Date Filter Matching
32
-
33
- - **Permanent accounts** (ASSET, LIABILITY): Use `before:` dates for point-in-time
34
- - **Non-permanent accounts** (INCOMING, OUTGOING): Use `after:` and `before:` for periods
35
-
36
- - **IMPORTANT:** `after:` is inclusive and `before:` is exclusive, so, for example, to filter the whole 2024 year, the range might be `after:2024-01-01 before:2025-01-01`
37
-
38
- ### 3. Correct Tool Selection
39
- - **Balance analysis**: Always use `get_balances`
40
- - **Transaction inspection**: Use `list_transactions` (never for calculations)
41
-
42
- ### 4. Balance Analysis Query Requirements (MANDATORY)
43
- - **MUST include either `group:` or `account:` operator in EVERY query**
44
- - Never query subgroups directly (Assets, Liabilities, Revenue, Expenses) - use root groups
45
- - When using `account:`, be specific about individual accounts
46
- - Always include appropriate date filters
47
- - Balance analysis queries without group/account operators will be rejected with an error
48
- - Transaction queries can be without group/account operators
49
-
50
- ## Examples
51
-
52
- ### Balance Sheet Analysis
53
- ```javascript
54
- // After discovering root group for ASSET + LIABILITY accounts
55
- get_balances({
56
- bookId: "book-123",
57
- query: "group:'Total Equity' before:$m"
58
- })
59
- ```
60
-
61
- ### P&L Analysis
62
- ```javascript
63
- // After discovering root group for INCOMING + OUTGOING accounts
64
- get_balances({
65
- bookId: "book-123",
66
- query: "group:'Profit & Loss' after:$m-12 before:$m"
67
- })
68
- ```
69
-
70
- ### Complete Financial Statements
71
- ```javascript
72
- // After discovering both root groups
73
- const balanceSheet = await get_balances({
74
- bookId: "book-123",
75
- query: "group:'Total Equity' before:$m+1"
76
- });
77
-
78
- const pnl = await get_balances({
79
- bookId: "book-123",
80
- query: "group:'Profit & Loss' after:$m-1 before:$m"
81
- });
82
- ```
83
-
84
- ### Transaction Inspection
85
- ```javascript
86
- // Recent transactions (inspection only)
87
- list_transactions({
88
- bookId: "book-123",
89
- query: "after:$d-30"
90
- })
91
-
92
- // Large transactions
93
- list_transactions({
94
- bookId: "book-123",
95
- query: "amount>1000 after:$m-1 before:$m"
96
- })
97
- ```
98
-
99
- ## Account Structure Reference
100
-
101
- ### Account Types
102
- | Type | Nature | Examples |
103
- |------|--------|----------|
104
- | **ASSET** | Permanent | Cash, Accounts Receivable |
105
- | **LIABILITY** | Permanent | Accounts Payable, Loans |
106
- | **INCOMING** | Non-permanent | Sales, Interest Income |
107
- | **OUTGOING** | Non-permanent | Rent, Utilities |
108
-
109
- ### Example Group Hierarchies
110
-
111
- **Example 1: Permanent Accounts (Balance Sheet Analysis)**
112
- ```
113
- "Total Equity"
114
- ├── Assets
115
- │ ├── Current Assets
116
- │ └── Fixed Assets
117
- └── Liabilities
118
- ├── Current Liabilities
119
- └── Long-term Liabilities
120
- ```
121
-
122
- **Example 2: Non-Permanent Accounts (Profit & Loss Analysis)**
123
- ```
124
- "Profit & Loss"
125
- ├── Revenue
126
- │ ├── Product Sales
127
- │ └── Service Revenue
128
- └── Expenses
129
- ├── Operating Expenses
130
- └── Administrative Expenses
131
- ```
132
-
133
- **Note**: Root group names vary by book. Always discover the actual names using `get_book()` which includes group hierarchies.
134
-
135
- ## Quick Reference
136
-
137
- ### Date Variables
138
- - `$d` - Today
139
- - `$m` - Current month end
140
- - `$y` - Current year end
141
- - `$d-N` - N days ago
142
- - `$m-N` - N months ago
143
-
144
- ### Query Patterns
145
- ```
146
- group:'[ROOT_GROUP_NAME]' before:$m // Balance sheet (permanent accounts)
147
- group:'[ROOT_GROUP_NAME]' after:$m-1 before:$m // P&L (non-permanent accounts)
148
- after:2024-01-01 before:2025-01-01 // Date range
149
- amount>1000 // Amount filter (transactions only)
150
- ```
151
-
152
- ### Analysis Workflow
153
- 1. **Discover**: `list_books()` → `get_book()` (includes groups)
154
- 2. **Identify Root Groups**: Find groups containing the group types you need
155
- 3. **Analyze**: `get_balances()` with discovered root groups
156
- 4. **Inspect**: `list_transactions()` for transaction details
157
-
158
- ## Reports and Insights Formatting
159
-
160
- ### Markdown Output Preference
161
- When generating financial insights, reports, or analysis, **strongly prefer well-structured Markdown** for better readability across platforms (cloud, desktop, mobile). Use tables for financial data, clear headers for sections, bold formatting for totals and key metrics, and icons to enhance visual appeal.
162
-
163
-
164
- ## Common Mistakes to Avoid
165
-
166
- ❌ **Wrong**: `get_balances({ query: "before:$m" })` - Missing group/account operator!
167
- ✅ **Right**: `get_balances({ query: "group:'[ROOT_GROUP]' before:$m" })`
168
-
169
- ❌ **Wrong**: `get_balances({ query: "after:2024-01-01" })` - Missing group/account operator!
170
- ✅ **Right**: `get_balances({ query: "group:'[ROOT_GROUP]' after:2024-01-01 before:2025-01-01" })`
171
-
172
- ❌ **Wrong**: `get_balances({ query: "group:'Assets'" })` - Using subgroup instead of root group
173
- ✅ **Right**: `get_balances({ query: "group:'[ROOT_GROUP_WITH_ASSETS]' before:$m" })`
174
-
175
- ❌ **Wrong**: Query without any filtering
176
- ✅ **Right**: Always include `group:` or `account:` operator for focused analysis
177
-
178
- ❌ **Wrong**: Using `list_transactions` for balance calculations
179
- ✅ **Right**: Use `get_balances` for all balance analysis
180
-
181
- ❌ **Wrong**: Using `before:` without `after:` dates with non-permanent accounts
182
- ✅ **Right**: Use `after:` and `before:` with INCOMING/OUTGOING accounts
183
-
184
- ❌ **Wrong**: Using different date variables on same query. E.g.`after:$y-1` and `before:$d`
185
- ✅ **Right**: Use same date variables on same query. E.g. `after:$y-1` and `before:$y`
186
-
187
- ❌ **Wrong**: Assuming fixed root group names
188
- ✅ **Right**: Always discover root groups using `get_book()` then navigate its `groups` property
189
-
190
- ## CRITICAL REQUIREMENT
191
-
192
- **⚠️ ALL get_balances queries MUST include either `group:` or `account:` operator.**
@@ -1,59 +0,0 @@
1
- import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
- interface TransactionInput {
3
- date: string;
4
- amount: number;
5
- from_account?: string;
6
- to_account?: string;
7
- description: string;
8
- }
9
- interface CreateTransactionsParams {
10
- bookId: string;
11
- transactions: TransactionInput[];
12
- }
13
- export declare function handleCreateTransactions(params: CreateTransactionsParams): Promise<CallToolResult>;
14
- export declare const createTransactionsToolDefinition: {
15
- name: string;
16
- description: string;
17
- inputSchema: {
18
- type: string;
19
- properties: {
20
- bookId: {
21
- type: string;
22
- description: string;
23
- };
24
- transactions: {
25
- type: string;
26
- items: {
27
- type: string;
28
- properties: {
29
- date: {
30
- type: string;
31
- description: string;
32
- };
33
- amount: {
34
- type: string;
35
- description: string;
36
- };
37
- from_account: {
38
- type: string;
39
- description: string;
40
- };
41
- to_account: {
42
- type: string;
43
- description: string;
44
- };
45
- description: {
46
- type: string;
47
- description: string;
48
- };
49
- };
50
- required: string[];
51
- };
52
- description: string;
53
- };
54
- };
55
- required: string[];
56
- };
57
- };
58
- export {};
59
- //# sourceMappingURL=create_transactions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create_transactions.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/create_transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,oCAAoC,CAAC;AAIzF,UAAU,gBAAgB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,wBAAwB;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,gBAAgB,EAAE,CAAC;CACpC;AAMD,wBAAsB,wBAAwB,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,cAAc,CAAC,CAiJxG;AAED,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2C5C,CAAC"}
@@ -1,163 +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
- import { Transaction } from 'bkper-js';
24
- export function handleCreateTransactions(params) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- try {
27
- // Debug logging removed to prevent stdio contamination
28
- // Validate required parameters
29
- if (!params.bookId) {
30
- throw new McpError(ErrorCode.InvalidParams, 'Missing required parameter: bookId');
31
- }
32
- if (!params.transactions) {
33
- throw new McpError(ErrorCode.InvalidParams, 'Missing required parameter: transactions');
34
- }
35
- if (!Array.isArray(params.transactions)) {
36
- throw new McpError(ErrorCode.InvalidParams, 'Parameter transactions must be an array');
37
- }
38
- // Handle empty array case
39
- if (params.transactions.length === 0) {
40
- return {
41
- content: [
42
- {
43
- type: 'text',
44
- text: JSON.stringify({ transactions: [] }, null, 2),
45
- },
46
- ],
47
- };
48
- }
49
- // Validate each transaction
50
- params.transactions.forEach((tx, index) => {
51
- if (!tx.date || typeof tx.date !== 'string' || tx.date.trim() === '') {
52
- throw new McpError(ErrorCode.InvalidParams, `Transaction at index ${index}: Missing or empty required field 'date'`);
53
- }
54
- if (tx.amount === undefined || tx.amount === null || typeof tx.amount !== 'number') {
55
- throw new McpError(ErrorCode.InvalidParams, `Transaction at index ${index}: Missing or invalid required field 'amount'`);
56
- }
57
- if (!tx.description || typeof tx.description !== 'string' || tx.description.trim() === '') {
58
- throw new McpError(ErrorCode.InvalidParams, `Transaction at index ${index}: Missing or empty required field 'description'`);
59
- }
60
- });
61
- // Get configured Bkper instance
62
- const bkperInstance = getBkperInstance();
63
- // Get the book
64
- const book = yield bkperInstance.getBook(params.bookId);
65
- if (!book) {
66
- throw new McpError(ErrorCode.InvalidParams, `Book not found: ${params.bookId}`);
67
- }
68
- // Create Transaction objects with description built from structured data
69
- const bkperTransactions = params.transactions.map((tx) => {
70
- const transaction = new Transaction(book);
71
- // Build description with optional accounts
72
- const parts = [];
73
- if (tx.from_account && tx.from_account.trim()) {
74
- parts.push(tx.from_account.trim());
75
- }
76
- if (tx.to_account && tx.to_account.trim()) {
77
- parts.push(tx.to_account.trim());
78
- }
79
- parts.push(tx.description);
80
- const fullDescription = parts.join(' ');
81
- transaction.setDate(tx.date);
82
- transaction.setAmount(tx.amount);
83
- transaction.setDescription(fullDescription);
84
- return transaction;
85
- });
86
- // Batch create transactions
87
- const createdTransactions = yield book.batchCreateTransactions(bkperTransactions);
88
- // Clean response by removing internal fields and ensure JSON serializable
89
- const transactions = createdTransactions.map((transaction) => {
90
- const transactionJson = transaction.json();
91
- const { agentId, agentName, agentLogo, agentLogoDark, createdAt, createdBy, updatedAt, dateValue } = transactionJson, cleanTransaction = __rest(transactionJson, ["agentId", "agentName", "agentLogo", "agentLogoDark", "createdAt", "createdBy", "updatedAt", "dateValue"]);
92
- // Ensure all values are JSON serializable
93
- return JSON.parse(JSON.stringify(cleanTransaction));
94
- });
95
- // Build response
96
- const response = {
97
- transactions
98
- };
99
- const responseText = JSON.stringify(response, null, 2);
100
- return {
101
- content: [
102
- {
103
- type: 'text',
104
- text: responseText,
105
- },
106
- ],
107
- };
108
- }
109
- catch (error) {
110
- // Re-throw MCP errors as-is
111
- if (error instanceof McpError) {
112
- throw error;
113
- }
114
- // Handle other errors
115
- throw new McpError(ErrorCode.InternalError, `Failed to create transactions: ${error instanceof Error ? error.message : String(error)}`);
116
- }
117
- });
118
- }
119
- export const createTransactionsToolDefinition = {
120
- name: 'create_transactions',
121
- description: 'Create transactions in batch from structured data. Accounts are specified by name and resolved by Bkper.',
122
- inputSchema: {
123
- type: 'object',
124
- properties: {
125
- bookId: {
126
- type: 'string',
127
- description: 'The unique identifier of the book'
128
- },
129
- transactions: {
130
- type: 'array',
131
- items: {
132
- type: 'object',
133
- properties: {
134
- date: {
135
- type: 'string',
136
- description: 'Transaction date in ISO format (YYYY-MM-DD) or book date format'
137
- },
138
- amount: {
139
- type: 'number',
140
- description: 'Transaction amount'
141
- },
142
- from_account: {
143
- type: 'string',
144
- description: 'Origin/Credit account name'
145
- },
146
- to_account: {
147
- type: 'string',
148
- description: 'Destination/Debit account name'
149
- },
150
- description: {
151
- type: 'string',
152
- description: 'Transaction description (can include #hashtags)'
153
- }
154
- },
155
- required: ['date', 'amount', 'description']
156
- },
157
- description: 'Array of transactions to create'
158
- }
159
- },
160
- required: ['bookId', 'transactions']
161
- }
162
- };
163
- //# sourceMappingURL=create_transactions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create_transactions.js","sourceRoot":"","sources":["../../../src/mcp/tools/create_transactions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAkB,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AA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AAC;KACvC;CACJ,CAAC"}
@@ -1,26 +0,0 @@
1
- import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
- interface GetBalancesParams {
3
- bookId: string;
4
- query: string;
5
- }
6
- export declare function handleGetBalances(params: GetBalancesParams): Promise<CallToolResult>;
7
- export declare const getBalancesToolDefinition: {
8
- name: string;
9
- description: string;
10
- inputSchema: {
11
- type: string;
12
- properties: {
13
- bookId: {
14
- type: string;
15
- description: string;
16
- };
17
- query: {
18
- type: string;
19
- description: string;
20
- };
21
- };
22
- required: string[];
23
- };
24
- };
25
- export {};
26
- //# sourceMappingURL=get_balances.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get_balances.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/get_balances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,oCAAoC,CAAC;AAIzF,UAAU,iBAAiB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AASD,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAoG1F;AAED,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;CAiBrC,CAAC"}