@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,368 @@
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
+ createBook,
8
+ getBook,
9
+ listBooks,
10
+ updateBook,
11
+ deleteBook,
12
+ searchBooks,
13
+ startBook,
14
+ finishBook,
15
+ abandonBook,
16
+ getCurrentlyReading,
17
+ getBookProgress,
18
+ getReadingStats,
19
+ getReadingPace,
20
+ createHighlight,
21
+ listHighlights,
22
+ searchHighlights,
23
+ deleteHighlight,
24
+ createReadingSession,
25
+ listReadingSessions,
26
+ } from "../db/reading.js";
27
+
28
+ const server = new McpServer({
29
+ name: "microservice-reading",
30
+ version: "0.0.1",
31
+ });
32
+
33
+ // --- Books ---
34
+
35
+ server.registerTool(
36
+ "create_book",
37
+ {
38
+ title: "Create Book",
39
+ description: "Add a new book to your reading list.",
40
+ inputSchema: {
41
+ title: z.string(),
42
+ author: z.string().optional(),
43
+ isbn: z.string().optional(),
44
+ category: z.string().optional(),
45
+ pages: z.number().optional(),
46
+ cover_url: z.string().optional(),
47
+ },
48
+ },
49
+ async (params) => {
50
+ const book = createBook(params);
51
+ return { content: [{ type: "text", text: JSON.stringify(book, null, 2) }] };
52
+ }
53
+ );
54
+
55
+ server.registerTool(
56
+ "get_book",
57
+ {
58
+ title: "Get Book",
59
+ description: "Get a book by ID.",
60
+ inputSchema: { id: z.string() },
61
+ },
62
+ async ({ id }) => {
63
+ const book = getBook(id);
64
+ if (!book) {
65
+ return { content: [{ type: "text", text: `Book '${id}' not found.` }], isError: true };
66
+ }
67
+ return { content: [{ type: "text", text: JSON.stringify(book, null, 2) }] };
68
+ }
69
+ );
70
+
71
+ server.registerTool(
72
+ "list_books",
73
+ {
74
+ title: "List Books",
75
+ description: "List books with optional filters.",
76
+ inputSchema: {
77
+ search: z.string().optional(),
78
+ status: z.string().optional(),
79
+ category: z.string().optional(),
80
+ author: z.string().optional(),
81
+ limit: z.number().optional(),
82
+ },
83
+ },
84
+ async (params) => {
85
+ const books = listBooks(params);
86
+ return {
87
+ content: [{ type: "text", text: JSON.stringify({ books, count: books.length }, null, 2) }],
88
+ };
89
+ }
90
+ );
91
+
92
+ server.registerTool(
93
+ "update_book",
94
+ {
95
+ title: "Update Book",
96
+ description: "Update an existing book.",
97
+ inputSchema: {
98
+ id: z.string(),
99
+ title: z.string().optional(),
100
+ author: z.string().optional(),
101
+ isbn: z.string().optional(),
102
+ category: z.string().optional(),
103
+ pages: z.number().optional(),
104
+ current_page: z.number().optional(),
105
+ rating: z.number().optional(),
106
+ cover_url: z.string().optional(),
107
+ },
108
+ },
109
+ async ({ id, ...input }) => {
110
+ const book = updateBook(id, input);
111
+ if (!book) {
112
+ return { content: [{ type: "text", text: `Book '${id}' not found.` }], isError: true };
113
+ }
114
+ return { content: [{ type: "text", text: JSON.stringify(book, null, 2) }] };
115
+ }
116
+ );
117
+
118
+ server.registerTool(
119
+ "delete_book",
120
+ {
121
+ title: "Delete Book",
122
+ description: "Delete a book by ID.",
123
+ inputSchema: { id: z.string() },
124
+ },
125
+ async ({ id }) => {
126
+ const deleted = deleteBook(id);
127
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
128
+ }
129
+ );
130
+
131
+ server.registerTool(
132
+ "search_books",
133
+ {
134
+ title: "Search Books",
135
+ description: "Search books by title, author, ISBN, or category.",
136
+ inputSchema: { query: z.string() },
137
+ },
138
+ async ({ query }) => {
139
+ const results = searchBooks(query);
140
+ return {
141
+ content: [{ type: "text", text: JSON.stringify({ results, count: results.length }, null, 2) }],
142
+ };
143
+ }
144
+ );
145
+
146
+ server.registerTool(
147
+ "start_book",
148
+ {
149
+ title: "Start Book",
150
+ description: "Mark a book as currently reading.",
151
+ inputSchema: { id: z.string() },
152
+ },
153
+ async ({ id }) => {
154
+ const book = startBook(id);
155
+ if (!book) {
156
+ return { content: [{ type: "text", text: `Book '${id}' not found.` }], isError: true };
157
+ }
158
+ return { content: [{ type: "text", text: JSON.stringify(book, null, 2) }] };
159
+ }
160
+ );
161
+
162
+ server.registerTool(
163
+ "finish_book",
164
+ {
165
+ title: "Finish Book",
166
+ description: "Mark a book as completed.",
167
+ inputSchema: {
168
+ id: z.string(),
169
+ rating: z.number().optional(),
170
+ },
171
+ },
172
+ async ({ id, rating }) => {
173
+ const book = finishBook(id, rating);
174
+ if (!book) {
175
+ return { content: [{ type: "text", text: `Book '${id}' not found.` }], isError: true };
176
+ }
177
+ return { content: [{ type: "text", text: JSON.stringify(book, null, 2) }] };
178
+ }
179
+ );
180
+
181
+ server.registerTool(
182
+ "abandon_book",
183
+ {
184
+ title: "Abandon Book",
185
+ description: "Mark a book as abandoned.",
186
+ inputSchema: { id: z.string() },
187
+ },
188
+ async ({ id }) => {
189
+ const book = abandonBook(id);
190
+ if (!book) {
191
+ return { content: [{ type: "text", text: `Book '${id}' not found.` }], isError: true };
192
+ }
193
+ return { content: [{ type: "text", text: JSON.stringify(book, null, 2) }] };
194
+ }
195
+ );
196
+
197
+ server.registerTool(
198
+ "currently_reading",
199
+ {
200
+ title: "Currently Reading",
201
+ description: "Get all books currently being read.",
202
+ inputSchema: {},
203
+ },
204
+ async () => {
205
+ const books = getCurrentlyReading();
206
+ return {
207
+ content: [{ type: "text", text: JSON.stringify({ books, count: books.length }, null, 2) }],
208
+ };
209
+ }
210
+ );
211
+
212
+ server.registerTool(
213
+ "book_progress",
214
+ {
215
+ title: "Book Progress",
216
+ description: "Get reading progress for a book (current page, total pages, percentage).",
217
+ inputSchema: { id: z.string() },
218
+ },
219
+ async ({ id }) => {
220
+ const progress = getBookProgress(id);
221
+ if (!progress) {
222
+ return { content: [{ type: "text", text: `Book '${id}' not found.` }], isError: true };
223
+ }
224
+ return { content: [{ type: "text", text: JSON.stringify(progress, null, 2) }] };
225
+ }
226
+ );
227
+
228
+ // --- Highlights ---
229
+
230
+ server.registerTool(
231
+ "create_highlight",
232
+ {
233
+ title: "Create Highlight",
234
+ description: "Add a highlight to a book.",
235
+ inputSchema: {
236
+ book_id: z.string(),
237
+ text: z.string(),
238
+ page: z.number().optional(),
239
+ chapter: z.string().optional(),
240
+ color: z.string().optional(),
241
+ notes: z.string().optional(),
242
+ },
243
+ },
244
+ async (params) => {
245
+ const highlight = createHighlight(params);
246
+ return { content: [{ type: "text", text: JSON.stringify(highlight, null, 2) }] };
247
+ }
248
+ );
249
+
250
+ server.registerTool(
251
+ "list_highlights",
252
+ {
253
+ title: "List Highlights",
254
+ description: "List all highlights for a book.",
255
+ inputSchema: { book_id: z.string() },
256
+ },
257
+ async ({ book_id }) => {
258
+ const highlights = listHighlights(book_id);
259
+ return {
260
+ content: [{ type: "text", text: JSON.stringify({ highlights, count: highlights.length }, null, 2) }],
261
+ };
262
+ }
263
+ );
264
+
265
+ server.registerTool(
266
+ "search_highlights",
267
+ {
268
+ title: "Search Highlights",
269
+ description: "Search highlights across all books.",
270
+ inputSchema: { query: z.string() },
271
+ },
272
+ async ({ query }) => {
273
+ const results = searchHighlights(query);
274
+ return {
275
+ content: [{ type: "text", text: JSON.stringify({ results, count: results.length }, null, 2) }],
276
+ };
277
+ }
278
+ );
279
+
280
+ server.registerTool(
281
+ "delete_highlight",
282
+ {
283
+ title: "Delete Highlight",
284
+ description: "Delete a highlight by ID.",
285
+ inputSchema: { id: z.string() },
286
+ },
287
+ async ({ id }) => {
288
+ const deleted = deleteHighlight(id);
289
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
290
+ }
291
+ );
292
+
293
+ // --- Reading Sessions ---
294
+
295
+ server.registerTool(
296
+ "log_reading_session",
297
+ {
298
+ title: "Log Reading Session",
299
+ description: "Log a reading session for a book.",
300
+ inputSchema: {
301
+ book_id: z.string(),
302
+ pages_read: z.number().optional(),
303
+ duration_min: z.number().optional(),
304
+ logged_at: z.string(),
305
+ },
306
+ },
307
+ async (params) => {
308
+ const session = createReadingSession(params);
309
+ return { content: [{ type: "text", text: JSON.stringify(session, null, 2) }] };
310
+ }
311
+ );
312
+
313
+ server.registerTool(
314
+ "list_reading_sessions",
315
+ {
316
+ title: "List Reading Sessions",
317
+ description: "List reading sessions for a book.",
318
+ inputSchema: { book_id: z.string() },
319
+ },
320
+ async ({ book_id }) => {
321
+ const sessions = listReadingSessions(book_id);
322
+ return {
323
+ content: [{ type: "text", text: JSON.stringify({ sessions, count: sessions.length }, null, 2) }],
324
+ };
325
+ }
326
+ );
327
+
328
+ // --- Stats ---
329
+
330
+ server.registerTool(
331
+ "reading_stats",
332
+ {
333
+ title: "Reading Stats",
334
+ description: "Get reading statistics (books read, pages read, sessions, avg rating, by category).",
335
+ inputSchema: {
336
+ year: z.number().optional(),
337
+ },
338
+ },
339
+ async ({ year }) => {
340
+ const stats = getReadingStats(year);
341
+ return { content: [{ type: "text", text: JSON.stringify(stats, null, 2) }] };
342
+ }
343
+ );
344
+
345
+ server.registerTool(
346
+ "reading_pace",
347
+ {
348
+ title: "Reading Pace",
349
+ description: "Get reading pace (pages/day, books/month, session averages).",
350
+ inputSchema: {},
351
+ },
352
+ async () => {
353
+ const pace = getReadingPace();
354
+ return { content: [{ type: "text", text: JSON.stringify(pace, null, 2) }] };
355
+ }
356
+ );
357
+
358
+ // --- Start ---
359
+ async function main() {
360
+ const transport = new StdioServerTransport();
361
+ await server.connect(transport);
362
+ console.error("microservice-reading MCP server running on stdio");
363
+ }
364
+
365
+ main().catch((error) => {
366
+ console.error("Fatal error:", error);
367
+ process.exit(1);
368
+ });
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@hasna/microservice-travel",
3
+ "version": "0.0.1",
4
+ "description": "Travel management microservice with SQLite — manage trips, bookings, documents, and loyalty programs",
5
+ "type": "module",
6
+ "bin": {
7
+ "microservice-travel": "./src/cli/index.ts",
8
+ "microservice-travel-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
+ }