@hasna/microservices 0.0.3 → 0.0.4

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 (67) hide show
  1. package/bin/index.js +63 -0
  2. package/bin/mcp.js +63 -0
  3. package/dist/index.js +63 -0
  4. package/microservices/microservice-ads/package.json +27 -0
  5. package/microservices/microservice-ads/src/cli/index.ts +407 -0
  6. package/microservices/microservice-ads/src/db/campaigns.ts +493 -0
  7. package/microservices/microservice-ads/src/db/database.ts +93 -0
  8. package/microservices/microservice-ads/src/db/migrations.ts +60 -0
  9. package/microservices/microservice-ads/src/index.ts +39 -0
  10. package/microservices/microservice-ads/src/mcp/index.ts +320 -0
  11. package/microservices/microservice-contracts/package.json +27 -0
  12. package/microservices/microservice-contracts/src/cli/index.ts +383 -0
  13. package/microservices/microservice-contracts/src/db/contracts.ts +496 -0
  14. package/microservices/microservice-contracts/src/db/database.ts +93 -0
  15. package/microservices/microservice-contracts/src/db/migrations.ts +58 -0
  16. package/microservices/microservice-contracts/src/index.ts +43 -0
  17. package/microservices/microservice-contracts/src/mcp/index.ts +308 -0
  18. package/microservices/microservice-domains/package.json +27 -0
  19. package/microservices/microservice-domains/src/cli/index.ts +438 -0
  20. package/microservices/microservice-domains/src/db/database.ts +93 -0
  21. package/microservices/microservice-domains/src/db/domains.ts +551 -0
  22. package/microservices/microservice-domains/src/db/migrations.ts +60 -0
  23. package/microservices/microservice-domains/src/index.ts +44 -0
  24. package/microservices/microservice-domains/src/mcp/index.ts +368 -0
  25. package/microservices/microservice-hiring/package.json +27 -0
  26. package/microservices/microservice-hiring/src/cli/index.ts +431 -0
  27. package/microservices/microservice-hiring/src/db/database.ts +93 -0
  28. package/microservices/microservice-hiring/src/db/hiring.ts +582 -0
  29. package/microservices/microservice-hiring/src/db/migrations.ts +68 -0
  30. package/microservices/microservice-hiring/src/index.ts +51 -0
  31. package/microservices/microservice-hiring/src/mcp/index.ts +464 -0
  32. package/microservices/microservice-payments/package.json +27 -0
  33. package/microservices/microservice-payments/src/cli/index.ts +357 -0
  34. package/microservices/microservice-payments/src/db/database.ts +93 -0
  35. package/microservices/microservice-payments/src/db/migrations.ts +63 -0
  36. package/microservices/microservice-payments/src/db/payments.ts +652 -0
  37. package/microservices/microservice-payments/src/index.ts +51 -0
  38. package/microservices/microservice-payments/src/mcp/index.ts +460 -0
  39. package/microservices/microservice-payroll/package.json +27 -0
  40. package/microservices/microservice-payroll/src/cli/index.ts +374 -0
  41. package/microservices/microservice-payroll/src/db/database.ts +93 -0
  42. package/microservices/microservice-payroll/src/db/migrations.ts +69 -0
  43. package/microservices/microservice-payroll/src/db/payroll.ts +741 -0
  44. package/microservices/microservice-payroll/src/index.ts +48 -0
  45. package/microservices/microservice-payroll/src/mcp/index.ts +420 -0
  46. package/microservices/microservice-shipping/package.json +27 -0
  47. package/microservices/microservice-shipping/src/cli/index.ts +398 -0
  48. package/microservices/microservice-shipping/src/db/database.ts +93 -0
  49. package/microservices/microservice-shipping/src/db/migrations.ts +61 -0
  50. package/microservices/microservice-shipping/src/db/shipping.ts +643 -0
  51. package/microservices/microservice-shipping/src/index.ts +53 -0
  52. package/microservices/microservice-shipping/src/mcp/index.ts +385 -0
  53. package/microservices/microservice-social/package.json +27 -0
  54. package/microservices/microservice-social/src/cli/index.ts +447 -0
  55. package/microservices/microservice-social/src/db/database.ts +93 -0
  56. package/microservices/microservice-social/src/db/migrations.ts +55 -0
  57. package/microservices/microservice-social/src/db/social.ts +672 -0
  58. package/microservices/microservice-social/src/index.ts +46 -0
  59. package/microservices/microservice-social/src/mcp/index.ts +435 -0
  60. package/microservices/microservice-subscriptions/package.json +27 -0
  61. package/microservices/microservice-subscriptions/src/cli/index.ts +400 -0
  62. package/microservices/microservice-subscriptions/src/db/database.ts +93 -0
  63. package/microservices/microservice-subscriptions/src/db/migrations.ts +57 -0
  64. package/microservices/microservice-subscriptions/src/db/subscriptions.ts +692 -0
  65. package/microservices/microservice-subscriptions/src/index.ts +41 -0
  66. package/microservices/microservice-subscriptions/src/mcp/index.ts +365 -0
  67. package/package.json +1 -1
@@ -0,0 +1,460 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
+ import { z } from "zod";
6
+ import {
7
+ createPayment,
8
+ getPayment,
9
+ listPayments,
10
+ updatePayment,
11
+ deletePayment,
12
+ refundPayment,
13
+ searchPayments,
14
+ getRevenueReport,
15
+ getRevenueByCustomer,
16
+ reconcileWithInvoice,
17
+ getPaymentStats,
18
+ getBalanceByProvider,
19
+ listByProvider,
20
+ } from "../db/payments.js";
21
+ import {
22
+ createDispute,
23
+ getDispute,
24
+ listDisputes,
25
+ respondDispute,
26
+ deleteDispute,
27
+ } from "../db/payments.js";
28
+ import {
29
+ createPayout,
30
+ getPayout,
31
+ listPayouts,
32
+ updatePayout,
33
+ deletePayout,
34
+ } from "../db/payments.js";
35
+
36
+ const server = new McpServer({
37
+ name: "microservice-payments",
38
+ version: "0.0.1",
39
+ });
40
+
41
+ // --- Payments ---
42
+
43
+ server.registerTool(
44
+ "create_payment",
45
+ {
46
+ title: "Create Payment",
47
+ description: "Create a new payment record.",
48
+ inputSchema: {
49
+ type: z.enum(["charge", "refund", "transfer", "payout"]),
50
+ amount: z.number(),
51
+ currency: z.string().optional(),
52
+ status: z.enum(["pending", "succeeded", "failed", "disputed", "refunded"]).optional(),
53
+ customer_name: z.string().optional(),
54
+ customer_email: z.string().optional(),
55
+ description: z.string().optional(),
56
+ provider: z.enum(["stripe", "square", "mercury", "manual"]).optional(),
57
+ provider_id: z.string().optional(),
58
+ invoice_id: z.string().optional(),
59
+ },
60
+ },
61
+ async (params) => {
62
+ const payment = createPayment(params);
63
+ return { content: [{ type: "text", text: JSON.stringify(payment, null, 2) }] };
64
+ }
65
+ );
66
+
67
+ server.registerTool(
68
+ "get_payment",
69
+ {
70
+ title: "Get Payment",
71
+ description: "Get a payment by ID.",
72
+ inputSchema: { id: z.string() },
73
+ },
74
+ async ({ id }) => {
75
+ const payment = getPayment(id);
76
+ if (!payment) {
77
+ return { content: [{ type: "text", text: `Payment '${id}' not found.` }], isError: true };
78
+ }
79
+ return { content: [{ type: "text", text: JSON.stringify(payment, null, 2) }] };
80
+ }
81
+ );
82
+
83
+ server.registerTool(
84
+ "list_payments",
85
+ {
86
+ title: "List Payments",
87
+ description: "List payments with optional filters.",
88
+ inputSchema: {
89
+ status: z.enum(["pending", "succeeded", "failed", "disputed", "refunded"]).optional(),
90
+ type: z.enum(["charge", "refund", "transfer", "payout"]).optional(),
91
+ provider: z.enum(["stripe", "square", "mercury", "manual"]).optional(),
92
+ customer_email: z.string().optional(),
93
+ limit: z.number().optional(),
94
+ },
95
+ },
96
+ async (params) => {
97
+ const payments = listPayments(params);
98
+ return {
99
+ content: [
100
+ { type: "text", text: JSON.stringify({ payments, count: payments.length }, null, 2) },
101
+ ],
102
+ };
103
+ }
104
+ );
105
+
106
+ server.registerTool(
107
+ "update_payment",
108
+ {
109
+ title: "Update Payment",
110
+ description: "Update an existing payment.",
111
+ inputSchema: {
112
+ id: z.string(),
113
+ status: z.enum(["pending", "succeeded", "failed", "disputed", "refunded"]).optional(),
114
+ customer_name: z.string().optional(),
115
+ customer_email: z.string().optional(),
116
+ description: z.string().optional(),
117
+ provider: z.enum(["stripe", "square", "mercury", "manual"]).optional(),
118
+ provider_id: z.string().optional(),
119
+ invoice_id: z.string().optional(),
120
+ },
121
+ },
122
+ async ({ id, ...input }) => {
123
+ const payment = updatePayment(id, input);
124
+ if (!payment) {
125
+ return { content: [{ type: "text", text: `Payment '${id}' not found.` }], isError: true };
126
+ }
127
+ return { content: [{ type: "text", text: JSON.stringify(payment, null, 2) }] };
128
+ }
129
+ );
130
+
131
+ server.registerTool(
132
+ "delete_payment",
133
+ {
134
+ title: "Delete Payment",
135
+ description: "Delete a payment by ID.",
136
+ inputSchema: { id: z.string() },
137
+ },
138
+ async ({ id }) => {
139
+ const deleted = deletePayment(id);
140
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
141
+ }
142
+ );
143
+
144
+ server.registerTool(
145
+ "refund_payment",
146
+ {
147
+ title: "Refund Payment",
148
+ description: "Refund a succeeded payment. Creates a refund record and marks the original as refunded.",
149
+ inputSchema: {
150
+ id: z.string(),
151
+ amount: z.number().optional(),
152
+ },
153
+ },
154
+ async ({ id, amount }) => {
155
+ const refund = refundPayment(id, amount);
156
+ if (!refund) {
157
+ return {
158
+ content: [{ type: "text", text: `Cannot refund payment '${id}' — not found or not succeeded.` }],
159
+ isError: true,
160
+ };
161
+ }
162
+ return { content: [{ type: "text", text: JSON.stringify(refund, null, 2) }] };
163
+ }
164
+ );
165
+
166
+ server.registerTool(
167
+ "search_payments",
168
+ {
169
+ title: "Search Payments",
170
+ description: "Search payments by customer name, email, description, provider ID, or invoice ID.",
171
+ inputSchema: { query: z.string() },
172
+ },
173
+ async ({ query }) => {
174
+ const results = searchPayments(query);
175
+ return {
176
+ content: [
177
+ { type: "text", text: JSON.stringify({ results, count: results.length }, null, 2) },
178
+ ],
179
+ };
180
+ }
181
+ );
182
+
183
+ server.registerTool(
184
+ "revenue_report",
185
+ {
186
+ title: "Revenue Report",
187
+ description: "Get revenue report for a date range.",
188
+ inputSchema: {
189
+ start_date: z.string(),
190
+ end_date: z.string(),
191
+ },
192
+ },
193
+ async ({ start_date, end_date }) => {
194
+ const report = getRevenueReport(start_date, end_date);
195
+ return { content: [{ type: "text", text: JSON.stringify(report, null, 2) }] };
196
+ }
197
+ );
198
+
199
+ server.registerTool(
200
+ "revenue_by_customer",
201
+ {
202
+ title: "Revenue by Customer",
203
+ description: "Get revenue breakdown by customer.",
204
+ inputSchema: {},
205
+ },
206
+ async () => {
207
+ const revenue = getRevenueByCustomer();
208
+ return { content: [{ type: "text", text: JSON.stringify(revenue, null, 2) }] };
209
+ }
210
+ );
211
+
212
+ server.registerTool(
213
+ "reconcile_payment",
214
+ {
215
+ title: "Reconcile Payment",
216
+ description: "Link a payment to an invoice ID for reconciliation.",
217
+ inputSchema: {
218
+ payment_id: z.string(),
219
+ invoice_id: z.string(),
220
+ },
221
+ },
222
+ async ({ payment_id, invoice_id }) => {
223
+ const payment = reconcileWithInvoice(payment_id, invoice_id);
224
+ if (!payment) {
225
+ return { content: [{ type: "text", text: `Payment '${payment_id}' not found.` }], isError: true };
226
+ }
227
+ return { content: [{ type: "text", text: JSON.stringify(payment, null, 2) }] };
228
+ }
229
+ );
230
+
231
+ server.registerTool(
232
+ "payment_stats",
233
+ {
234
+ title: "Payment Statistics",
235
+ description: "Get overall payment statistics.",
236
+ inputSchema: {},
237
+ },
238
+ async () => {
239
+ const stats = getPaymentStats();
240
+ return { content: [{ type: "text", text: JSON.stringify(stats, null, 2) }] };
241
+ }
242
+ );
243
+
244
+ server.registerTool(
245
+ "balance_by_provider",
246
+ {
247
+ title: "Balance by Provider",
248
+ description: "Get balance breakdown by payment provider.",
249
+ inputSchema: {},
250
+ },
251
+ async () => {
252
+ const balances = getBalanceByProvider();
253
+ return { content: [{ type: "text", text: JSON.stringify(balances, null, 2) }] };
254
+ }
255
+ );
256
+
257
+ server.registerTool(
258
+ "list_by_provider",
259
+ {
260
+ title: "List by Provider",
261
+ description: "List all payments for a specific provider.",
262
+ inputSchema: {
263
+ provider: z.enum(["stripe", "square", "mercury", "manual"]),
264
+ },
265
+ },
266
+ async ({ provider }) => {
267
+ const payments = listByProvider(provider);
268
+ return {
269
+ content: [
270
+ { type: "text", text: JSON.stringify({ payments, count: payments.length }, null, 2) },
271
+ ],
272
+ };
273
+ }
274
+ );
275
+
276
+ // --- Disputes ---
277
+
278
+ server.registerTool(
279
+ "create_dispute",
280
+ {
281
+ title: "Create Dispute",
282
+ description: "Create a dispute for a payment.",
283
+ inputSchema: {
284
+ payment_id: z.string(),
285
+ reason: z.string().optional(),
286
+ amount: z.number().optional(),
287
+ },
288
+ },
289
+ async (params) => {
290
+ const dispute = createDispute(params);
291
+ return { content: [{ type: "text", text: JSON.stringify(dispute, null, 2) }] };
292
+ }
293
+ );
294
+
295
+ server.registerTool(
296
+ "get_dispute",
297
+ {
298
+ title: "Get Dispute",
299
+ description: "Get a dispute by ID.",
300
+ inputSchema: { id: z.string() },
301
+ },
302
+ async ({ id }) => {
303
+ const dispute = getDispute(id);
304
+ if (!dispute) {
305
+ return { content: [{ type: "text", text: `Dispute '${id}' not found.` }], isError: true };
306
+ }
307
+ return { content: [{ type: "text", text: JSON.stringify(dispute, null, 2) }] };
308
+ }
309
+ );
310
+
311
+ server.registerTool(
312
+ "list_disputes",
313
+ {
314
+ title: "List Disputes",
315
+ description: "List disputes with optional status filter.",
316
+ inputSchema: {
317
+ status: z.enum(["open", "under_review", "won", "lost"]).optional(),
318
+ },
319
+ },
320
+ async ({ status }) => {
321
+ const disputes = listDisputes(status);
322
+ return {
323
+ content: [
324
+ { type: "text", text: JSON.stringify({ disputes, count: disputes.length }, null, 2) },
325
+ ],
326
+ };
327
+ }
328
+ );
329
+
330
+ server.registerTool(
331
+ "respond_dispute",
332
+ {
333
+ title: "Respond to Dispute",
334
+ description: "Respond to a dispute — update status and optionally add evidence.",
335
+ inputSchema: {
336
+ id: z.string(),
337
+ status: z.enum(["open", "under_review", "won", "lost"]),
338
+ },
339
+ },
340
+ async ({ id, status }) => {
341
+ const dispute = respondDispute(id, { status });
342
+ if (!dispute) {
343
+ return { content: [{ type: "text", text: `Dispute '${id}' not found.` }], isError: true };
344
+ }
345
+ return { content: [{ type: "text", text: JSON.stringify(dispute, null, 2) }] };
346
+ }
347
+ );
348
+
349
+ server.registerTool(
350
+ "delete_dispute",
351
+ {
352
+ title: "Delete Dispute",
353
+ description: "Delete a dispute by ID.",
354
+ inputSchema: { id: z.string() },
355
+ },
356
+ async ({ id }) => {
357
+ const deleted = deleteDispute(id);
358
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
359
+ }
360
+ );
361
+
362
+ // --- Payouts ---
363
+
364
+ server.registerTool(
365
+ "create_payout",
366
+ {
367
+ title: "Create Payout",
368
+ description: "Initiate a new payout.",
369
+ inputSchema: {
370
+ amount: z.number(),
371
+ currency: z.string().optional(),
372
+ destination: z.string().optional(),
373
+ },
374
+ },
375
+ async (params) => {
376
+ const payout = createPayout(params);
377
+ return { content: [{ type: "text", text: JSON.stringify(payout, null, 2) }] };
378
+ }
379
+ );
380
+
381
+ server.registerTool(
382
+ "get_payout",
383
+ {
384
+ title: "Get Payout",
385
+ description: "Get a payout by ID.",
386
+ inputSchema: { id: z.string() },
387
+ },
388
+ async ({ id }) => {
389
+ const payout = getPayout(id);
390
+ if (!payout) {
391
+ return { content: [{ type: "text", text: `Payout '${id}' not found.` }], isError: true };
392
+ }
393
+ return { content: [{ type: "text", text: JSON.stringify(payout, null, 2) }] };
394
+ }
395
+ );
396
+
397
+ server.registerTool(
398
+ "list_payouts",
399
+ {
400
+ title: "List Payouts",
401
+ description: "List payouts with optional status filter.",
402
+ inputSchema: {
403
+ status: z.enum(["pending", "in_transit", "paid", "failed"]).optional(),
404
+ },
405
+ },
406
+ async ({ status }) => {
407
+ const payouts = listPayouts(status);
408
+ return {
409
+ content: [
410
+ { type: "text", text: JSON.stringify({ payouts, count: payouts.length }, null, 2) },
411
+ ],
412
+ };
413
+ }
414
+ );
415
+
416
+ server.registerTool(
417
+ "update_payout",
418
+ {
419
+ title: "Update Payout",
420
+ description: "Update a payout status.",
421
+ inputSchema: {
422
+ id: z.string(),
423
+ status: z.enum(["pending", "in_transit", "paid", "failed"]).optional(),
424
+ destination: z.string().optional(),
425
+ arrived_at: z.string().optional(),
426
+ },
427
+ },
428
+ async ({ id, ...input }) => {
429
+ const payout = updatePayout(id, input);
430
+ if (!payout) {
431
+ return { content: [{ type: "text", text: `Payout '${id}' not found.` }], isError: true };
432
+ }
433
+ return { content: [{ type: "text", text: JSON.stringify(payout, null, 2) }] };
434
+ }
435
+ );
436
+
437
+ server.registerTool(
438
+ "delete_payout",
439
+ {
440
+ title: "Delete Payout",
441
+ description: "Delete a payout by ID.",
442
+ inputSchema: { id: z.string() },
443
+ },
444
+ async ({ id }) => {
445
+ const deleted = deletePayout(id);
446
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
447
+ }
448
+ );
449
+
450
+ // --- Start ---
451
+ async function main() {
452
+ const transport = new StdioServerTransport();
453
+ await server.connect(transport);
454
+ console.error("microservice-payments MCP server running on stdio");
455
+ }
456
+
457
+ main().catch((error) => {
458
+ console.error("Fatal error:", error);
459
+ process.exit(1);
460
+ });
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@hasna/microservice-payroll",
3
+ "version": "0.0.1",
4
+ "description": "Payroll management microservice with SQLite — manage employees, pay periods, pay stubs, and payments",
5
+ "type": "module",
6
+ "bin": {
7
+ "microservice-payroll": "./src/cli/index.ts",
8
+ "microservice-payroll-mcp": "./src/mcp/index.ts"
9
+ },
10
+ "exports": {
11
+ ".": "./src/index.ts"
12
+ },
13
+ "scripts": {
14
+ "dev": "bun run ./src/cli/index.ts",
15
+ "test": "bun test"
16
+ },
17
+ "dependencies": {
18
+ "@modelcontextprotocol/sdk": "^1.26.0",
19
+ "commander": "^12.1.0",
20
+ "zod": "^3.24.0"
21
+ },
22
+ "license": "Apache-2.0",
23
+ "publishConfig": {
24
+ "registry": "https://registry.npmjs.org",
25
+ "access": "public"
26
+ }
27
+ }