@hasna/microservices 0.0.9 → 0.0.11

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 (100) hide show
  1. package/bin/index.js +236 -36
  2. package/bin/mcp.js +153 -4
  3. package/dist/index.js +120 -3
  4. package/microservices/microservice-analytics/package.json +27 -0
  5. package/microservices/microservice-analytics/src/cli/index.ts +373 -0
  6. package/microservices/microservice-analytics/src/db/analytics.ts +564 -0
  7. package/microservices/microservice-analytics/src/db/database.ts +93 -0
  8. package/microservices/microservice-analytics/src/db/migrations.ts +50 -0
  9. package/microservices/microservice-analytics/src/index.ts +37 -0
  10. package/microservices/microservice-analytics/src/mcp/index.ts +334 -0
  11. package/microservices/microservice-assets/package.json +27 -0
  12. package/microservices/microservice-assets/src/cli/index.ts +375 -0
  13. package/microservices/microservice-assets/src/db/assets.ts +370 -0
  14. package/microservices/microservice-assets/src/db/database.ts +93 -0
  15. package/microservices/microservice-assets/src/db/migrations.ts +51 -0
  16. package/microservices/microservice-assets/src/index.ts +32 -0
  17. package/microservices/microservice-assets/src/mcp/index.ts +346 -0
  18. package/microservices/microservice-compliance/package.json +27 -0
  19. package/microservices/microservice-compliance/src/cli/index.ts +467 -0
  20. package/microservices/microservice-compliance/src/db/compliance.ts +633 -0
  21. package/microservices/microservice-compliance/src/db/database.ts +93 -0
  22. package/microservices/microservice-compliance/src/db/migrations.ts +63 -0
  23. package/microservices/microservice-compliance/src/index.ts +46 -0
  24. package/microservices/microservice-compliance/src/mcp/index.ts +438 -0
  25. package/microservices/microservice-habits/package.json +27 -0
  26. package/microservices/microservice-habits/src/cli/index.ts +315 -0
  27. package/microservices/microservice-habits/src/db/database.ts +93 -0
  28. package/microservices/microservice-habits/src/db/habits.ts +451 -0
  29. package/microservices/microservice-habits/src/db/migrations.ts +46 -0
  30. package/microservices/microservice-habits/src/index.ts +31 -0
  31. package/microservices/microservice-habits/src/mcp/index.ts +313 -0
  32. package/microservices/microservice-health/package.json +27 -0
  33. package/microservices/microservice-health/src/cli/index.ts +484 -0
  34. package/microservices/microservice-health/src/db/database.ts +93 -0
  35. package/microservices/microservice-health/src/db/health.ts +708 -0
  36. package/microservices/microservice-health/src/db/migrations.ts +70 -0
  37. package/microservices/microservice-health/src/index.ts +63 -0
  38. package/microservices/microservice-health/src/mcp/index.ts +437 -0
  39. package/microservices/microservice-leads/package.json +27 -0
  40. package/microservices/microservice-leads/src/cli/index.ts +596 -0
  41. package/microservices/microservice-leads/src/db/database.ts +93 -0
  42. package/microservices/microservice-leads/src/db/leads.ts +520 -0
  43. package/microservices/microservice-leads/src/db/lists.ts +151 -0
  44. package/microservices/microservice-leads/src/db/migrations.ts +93 -0
  45. package/microservices/microservice-leads/src/index.ts +65 -0
  46. package/microservices/microservice-leads/src/lib/enrichment.ts +202 -0
  47. package/microservices/microservice-leads/src/lib/scoring.ts +134 -0
  48. package/microservices/microservice-leads/src/mcp/index.ts +533 -0
  49. package/microservices/microservice-notifications/package.json +27 -0
  50. package/microservices/microservice-notifications/src/cli/index.ts +349 -0
  51. package/microservices/microservice-notifications/src/db/database.ts +93 -0
  52. package/microservices/microservice-notifications/src/db/migrations.ts +62 -0
  53. package/microservices/microservice-notifications/src/db/notifications.ts +509 -0
  54. package/microservices/microservice-notifications/src/index.ts +41 -0
  55. package/microservices/microservice-notifications/src/mcp/index.ts +422 -0
  56. package/microservices/microservice-products/package.json +27 -0
  57. package/microservices/microservice-products/src/cli/index.ts +416 -0
  58. package/microservices/microservice-products/src/db/categories.ts +154 -0
  59. package/microservices/microservice-products/src/db/database.ts +93 -0
  60. package/microservices/microservice-products/src/db/migrations.ts +58 -0
  61. package/microservices/microservice-products/src/db/pricing-tiers.ts +66 -0
  62. package/microservices/microservice-products/src/db/products.ts +452 -0
  63. package/microservices/microservice-products/src/index.ts +53 -0
  64. package/microservices/microservice-products/src/mcp/index.ts +453 -0
  65. package/microservices/microservice-projects/package.json +27 -0
  66. package/microservices/microservice-projects/src/cli/index.ts +480 -0
  67. package/microservices/microservice-projects/src/db/database.ts +93 -0
  68. package/microservices/microservice-projects/src/db/migrations.ts +65 -0
  69. package/microservices/microservice-projects/src/db/projects.ts +715 -0
  70. package/microservices/microservice-projects/src/index.ts +57 -0
  71. package/microservices/microservice-projects/src/mcp/index.ts +501 -0
  72. package/microservices/microservice-proposals/package.json +27 -0
  73. package/microservices/microservice-proposals/src/cli/index.ts +400 -0
  74. package/microservices/microservice-proposals/src/db/database.ts +93 -0
  75. package/microservices/microservice-proposals/src/db/migrations.ts +52 -0
  76. package/microservices/microservice-proposals/src/db/proposals.ts +532 -0
  77. package/microservices/microservice-proposals/src/index.ts +37 -0
  78. package/microservices/microservice-proposals/src/mcp/index.ts +375 -0
  79. package/microservices/microservice-reading/package.json +27 -0
  80. package/microservices/microservice-reading/src/cli/index.ts +464 -0
  81. package/microservices/microservice-reading/src/db/database.ts +93 -0
  82. package/microservices/microservice-reading/src/db/migrations.ts +59 -0
  83. package/microservices/microservice-reading/src/db/reading.ts +524 -0
  84. package/microservices/microservice-reading/src/index.ts +51 -0
  85. package/microservices/microservice-reading/src/mcp/index.ts +368 -0
  86. package/microservices/microservice-travel/package.json +27 -0
  87. package/microservices/microservice-travel/src/cli/index.ts +505 -0
  88. package/microservices/microservice-travel/src/db/database.ts +93 -0
  89. package/microservices/microservice-travel/src/db/migrations.ts +77 -0
  90. package/microservices/microservice-travel/src/db/travel.ts +802 -0
  91. package/microservices/microservice-travel/src/index.ts +60 -0
  92. package/microservices/microservice-travel/src/mcp/index.ts +495 -0
  93. package/microservices/microservice-wiki/package.json +27 -0
  94. package/microservices/microservice-wiki/src/cli/index.ts +345 -0
  95. package/microservices/microservice-wiki/src/db/database.ts +93 -0
  96. package/microservices/microservice-wiki/src/db/migrations.ts +55 -0
  97. package/microservices/microservice-wiki/src/db/wiki.ts +395 -0
  98. package/microservices/microservice-wiki/src/index.ts +32 -0
  99. package/microservices/microservice-wiki/src/mcp/index.ts +344 -0
  100. package/package.json +1 -1
@@ -0,0 +1,453 @@
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
+ createProduct,
8
+ getProduct,
9
+ listProducts,
10
+ updateProduct,
11
+ deleteProduct,
12
+ countProducts,
13
+ searchProducts,
14
+ listByCategory,
15
+ listByType,
16
+ listByStatus,
17
+ getProductWithTiers,
18
+ bulkImportProducts,
19
+ exportProducts,
20
+ getProductStats,
21
+ } from "../db/products.js";
22
+ import {
23
+ createCategory,
24
+ getCategory,
25
+ listCategories,
26
+ updateCategory,
27
+ deleteCategory,
28
+ getCategoryTree,
29
+ } from "../db/categories.js";
30
+ import {
31
+ createPricingTier,
32
+ listPricingTiers,
33
+ deletePricingTier,
34
+ } from "../db/pricing-tiers.js";
35
+
36
+ const server = new McpServer({
37
+ name: "microservice-products",
38
+ version: "0.0.1",
39
+ });
40
+
41
+ // --- Products ---
42
+
43
+ server.registerTool(
44
+ "create_product",
45
+ {
46
+ title: "Create Product",
47
+ description: "Create a new product.",
48
+ inputSchema: {
49
+ name: z.string(),
50
+ description: z.string().optional(),
51
+ type: z.enum(["product", "service", "subscription", "digital"]).optional(),
52
+ sku: z.string().optional(),
53
+ price: z.number().optional(),
54
+ currency: z.string().optional(),
55
+ unit: z.string().optional(),
56
+ category: z.string().optional(),
57
+ status: z.enum(["active", "draft", "archived"]).optional(),
58
+ images: z.array(z.string()).optional(),
59
+ variants: z.array(z.record(z.unknown())).optional(),
60
+ metadata: z.record(z.unknown()).optional(),
61
+ },
62
+ },
63
+ async (params) => {
64
+ const product = createProduct(params);
65
+ return { content: [{ type: "text", text: JSON.stringify(product, null, 2) }] };
66
+ }
67
+ );
68
+
69
+ server.registerTool(
70
+ "get_product",
71
+ {
72
+ title: "Get Product",
73
+ description: "Get a product by ID.",
74
+ inputSchema: { id: z.string() },
75
+ },
76
+ async ({ id }) => {
77
+ const product = getProduct(id);
78
+ if (!product) {
79
+ return { content: [{ type: "text", text: `Product '${id}' not found.` }], isError: true };
80
+ }
81
+ return { content: [{ type: "text", text: JSON.stringify(product, null, 2) }] };
82
+ }
83
+ );
84
+
85
+ server.registerTool(
86
+ "list_products",
87
+ {
88
+ title: "List Products",
89
+ description: "List products with optional filters.",
90
+ inputSchema: {
91
+ search: z.string().optional(),
92
+ category: z.string().optional(),
93
+ type: z.enum(["product", "service", "subscription", "digital"]).optional(),
94
+ status: z.enum(["active", "draft", "archived"]).optional(),
95
+ limit: z.number().optional(),
96
+ offset: z.number().optional(),
97
+ },
98
+ },
99
+ async (params) => {
100
+ const products = listProducts(params);
101
+ return {
102
+ content: [
103
+ {
104
+ type: "text",
105
+ text: JSON.stringify({ products, count: products.length }, null, 2),
106
+ },
107
+ ],
108
+ };
109
+ }
110
+ );
111
+
112
+ server.registerTool(
113
+ "update_product",
114
+ {
115
+ title: "Update Product",
116
+ description: "Update an existing product.",
117
+ inputSchema: {
118
+ id: z.string(),
119
+ name: z.string().optional(),
120
+ description: z.string().optional(),
121
+ type: z.enum(["product", "service", "subscription", "digital"]).optional(),
122
+ sku: z.string().optional(),
123
+ price: z.number().optional(),
124
+ currency: z.string().optional(),
125
+ unit: z.string().optional(),
126
+ category: z.string().optional(),
127
+ status: z.enum(["active", "draft", "archived"]).optional(),
128
+ images: z.array(z.string()).optional(),
129
+ variants: z.array(z.record(z.unknown())).optional(),
130
+ metadata: z.record(z.unknown()).optional(),
131
+ },
132
+ },
133
+ async ({ id, ...input }) => {
134
+ const product = updateProduct(id, input);
135
+ if (!product) {
136
+ return { content: [{ type: "text", text: `Product '${id}' not found.` }], isError: true };
137
+ }
138
+ return { content: [{ type: "text", text: JSON.stringify(product, null, 2) }] };
139
+ }
140
+ );
141
+
142
+ server.registerTool(
143
+ "delete_product",
144
+ {
145
+ title: "Delete Product",
146
+ description: "Delete a product by ID.",
147
+ inputSchema: { id: z.string() },
148
+ },
149
+ async ({ id }) => {
150
+ const deleted = deleteProduct(id);
151
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
152
+ }
153
+ );
154
+
155
+ server.registerTool(
156
+ "search_products",
157
+ {
158
+ title: "Search Products",
159
+ description: "Search products by name, description, or SKU.",
160
+ inputSchema: { query: z.string() },
161
+ },
162
+ async ({ query }) => {
163
+ const results = searchProducts(query);
164
+ return {
165
+ content: [
166
+ { type: "text", text: JSON.stringify({ results, count: results.length }, null, 2) },
167
+ ],
168
+ };
169
+ }
170
+ );
171
+
172
+ server.registerTool(
173
+ "count_products",
174
+ {
175
+ title: "Count Products",
176
+ description: "Get the total number of products.",
177
+ inputSchema: {},
178
+ },
179
+ async () => {
180
+ const count = countProducts();
181
+ return { content: [{ type: "text", text: JSON.stringify({ count }) }] };
182
+ }
183
+ );
184
+
185
+ server.registerTool(
186
+ "list_products_by_category",
187
+ {
188
+ title: "List Products by Category",
189
+ description: "List all products in a given category.",
190
+ inputSchema: { category: z.string() },
191
+ },
192
+ async ({ category }) => {
193
+ const products = listByCategory(category);
194
+ return {
195
+ content: [
196
+ { type: "text", text: JSON.stringify({ products, count: products.length }, null, 2) },
197
+ ],
198
+ };
199
+ }
200
+ );
201
+
202
+ server.registerTool(
203
+ "list_products_by_type",
204
+ {
205
+ title: "List Products by Type",
206
+ description: "List all products of a given type.",
207
+ inputSchema: { type: z.enum(["product", "service", "subscription", "digital"]) },
208
+ },
209
+ async ({ type }) => {
210
+ const products = listByType(type);
211
+ return {
212
+ content: [
213
+ { type: "text", text: JSON.stringify({ products, count: products.length }, null, 2) },
214
+ ],
215
+ };
216
+ }
217
+ );
218
+
219
+ server.registerTool(
220
+ "list_products_by_status",
221
+ {
222
+ title: "List Products by Status",
223
+ description: "List all products with a given status.",
224
+ inputSchema: { status: z.enum(["active", "draft", "archived"]) },
225
+ },
226
+ async ({ status }) => {
227
+ const products = listByStatus(status);
228
+ return {
229
+ content: [
230
+ { type: "text", text: JSON.stringify({ products, count: products.length }, null, 2) },
231
+ ],
232
+ };
233
+ }
234
+ );
235
+
236
+ server.registerTool(
237
+ "get_product_with_tiers",
238
+ {
239
+ title: "Get Product with Pricing Tiers",
240
+ description: "Get a product along with all its pricing tiers.",
241
+ inputSchema: { id: z.string() },
242
+ },
243
+ async ({ id }) => {
244
+ const product = getProductWithTiers(id);
245
+ if (!product) {
246
+ return { content: [{ type: "text", text: `Product '${id}' not found.` }], isError: true };
247
+ }
248
+ return { content: [{ type: "text", text: JSON.stringify(product, null, 2) }] };
249
+ }
250
+ );
251
+
252
+ server.registerTool(
253
+ "bulk_import_products",
254
+ {
255
+ title: "Bulk Import Products",
256
+ description: "Import products from a CSV string. CSV must have a header row with at least a 'name' column.",
257
+ inputSchema: { csv: z.string() },
258
+ },
259
+ async ({ csv }) => {
260
+ const result = bulkImportProducts(csv);
261
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
262
+ }
263
+ );
264
+
265
+ server.registerTool(
266
+ "export_products",
267
+ {
268
+ title: "Export Products",
269
+ description: "Export all products in CSV or JSON format.",
270
+ inputSchema: { format: z.enum(["csv", "json"]).optional() },
271
+ },
272
+ async ({ format }) => {
273
+ const output = exportProducts(format || "json");
274
+ return { content: [{ type: "text", text: output }] };
275
+ }
276
+ );
277
+
278
+ server.registerTool(
279
+ "get_product_stats",
280
+ {
281
+ title: "Get Product Statistics",
282
+ description: "Get aggregate statistics about products (counts by status, type, category, and price range).",
283
+ inputSchema: {},
284
+ },
285
+ async () => {
286
+ const stats = getProductStats();
287
+ return { content: [{ type: "text", text: JSON.stringify(stats, null, 2) }] };
288
+ }
289
+ );
290
+
291
+ // --- Categories ---
292
+
293
+ server.registerTool(
294
+ "create_category",
295
+ {
296
+ title: "Create Category",
297
+ description: "Create a new product category.",
298
+ inputSchema: {
299
+ name: z.string(),
300
+ parent_id: z.string().optional(),
301
+ description: z.string().optional(),
302
+ },
303
+ },
304
+ async (params) => {
305
+ const category = createCategory(params);
306
+ return { content: [{ type: "text", text: JSON.stringify(category, null, 2) }] };
307
+ }
308
+ );
309
+
310
+ server.registerTool(
311
+ "get_category",
312
+ {
313
+ title: "Get Category",
314
+ description: "Get a category by ID.",
315
+ inputSchema: { id: z.string() },
316
+ },
317
+ async ({ id }) => {
318
+ const category = getCategory(id);
319
+ if (!category) {
320
+ return { content: [{ type: "text", text: `Category '${id}' not found.` }], isError: true };
321
+ }
322
+ return { content: [{ type: "text", text: JSON.stringify(category, null, 2) }] };
323
+ }
324
+ );
325
+
326
+ server.registerTool(
327
+ "list_categories",
328
+ {
329
+ title: "List Categories",
330
+ description: "List all product categories.",
331
+ inputSchema: {
332
+ search: z.string().optional(),
333
+ },
334
+ },
335
+ async (params) => {
336
+ const categories = listCategories(params);
337
+ return {
338
+ content: [
339
+ { type: "text", text: JSON.stringify({ categories, count: categories.length }, null, 2) },
340
+ ],
341
+ };
342
+ }
343
+ );
344
+
345
+ server.registerTool(
346
+ "update_category",
347
+ {
348
+ title: "Update Category",
349
+ description: "Update an existing category.",
350
+ inputSchema: {
351
+ id: z.string(),
352
+ name: z.string().optional(),
353
+ parent_id: z.string().optional(),
354
+ description: z.string().optional(),
355
+ },
356
+ },
357
+ async ({ id, ...input }) => {
358
+ const category = updateCategory(id, input);
359
+ if (!category) {
360
+ return { content: [{ type: "text", text: `Category '${id}' not found.` }], isError: true };
361
+ }
362
+ return { content: [{ type: "text", text: JSON.stringify(category, null, 2) }] };
363
+ }
364
+ );
365
+
366
+ server.registerTool(
367
+ "delete_category",
368
+ {
369
+ title: "Delete Category",
370
+ description: "Delete a category by ID.",
371
+ inputSchema: { id: z.string() },
372
+ },
373
+ async ({ id }) => {
374
+ const deleted = deleteCategory(id);
375
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
376
+ }
377
+ );
378
+
379
+ server.registerTool(
380
+ "get_category_tree",
381
+ {
382
+ title: "Get Category Tree",
383
+ description: "Get the full category hierarchy as a tree structure.",
384
+ inputSchema: {},
385
+ },
386
+ async () => {
387
+ const tree = getCategoryTree();
388
+ return { content: [{ type: "text", text: JSON.stringify(tree, null, 2) }] };
389
+ }
390
+ );
391
+
392
+ // --- Pricing Tiers ---
393
+
394
+ server.registerTool(
395
+ "create_pricing_tier",
396
+ {
397
+ title: "Create Pricing Tier",
398
+ description: "Add a pricing tier to a product.",
399
+ inputSchema: {
400
+ product_id: z.string(),
401
+ name: z.string(),
402
+ min_quantity: z.number(),
403
+ price: z.number(),
404
+ currency: z.string().optional(),
405
+ },
406
+ },
407
+ async (params) => {
408
+ const tier = createPricingTier(params);
409
+ return { content: [{ type: "text", text: JSON.stringify(tier, null, 2) }] };
410
+ }
411
+ );
412
+
413
+ server.registerTool(
414
+ "list_pricing_tiers",
415
+ {
416
+ title: "List Pricing Tiers",
417
+ description: "List all pricing tiers for a product.",
418
+ inputSchema: { product_id: z.string() },
419
+ },
420
+ async ({ product_id }) => {
421
+ const tiers = listPricingTiers(product_id);
422
+ return {
423
+ content: [
424
+ { type: "text", text: JSON.stringify({ tiers, count: tiers.length }, null, 2) },
425
+ ],
426
+ };
427
+ }
428
+ );
429
+
430
+ server.registerTool(
431
+ "delete_pricing_tier",
432
+ {
433
+ title: "Delete Pricing Tier",
434
+ description: "Delete a pricing tier by ID.",
435
+ inputSchema: { id: z.string() },
436
+ },
437
+ async ({ id }) => {
438
+ const deleted = deletePricingTier(id);
439
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
440
+ }
441
+ );
442
+
443
+ // --- Start ---
444
+ async function main() {
445
+ const transport = new StdioServerTransport();
446
+ await server.connect(transport);
447
+ console.error("microservice-products MCP server running on stdio");
448
+ }
449
+
450
+ main().catch((error) => {
451
+ console.error("Fatal error:", error);
452
+ process.exit(1);
453
+ });
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@hasna/microservice-projects",
3
+ "version": "0.0.1",
4
+ "description": "Project management microservice with SQLite — manage projects, milestones, and deliverables",
5
+ "type": "module",
6
+ "bin": {
7
+ "microservice-projects": "./src/cli/index.ts",
8
+ "microservice-projects-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
+ }