@hasna/microservices 0.0.10 → 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 (90) hide show
  1. package/bin/index.js +86 -1
  2. package/bin/mcp.js +86 -1
  3. package/dist/index.js +86 -1
  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-notifications/package.json +27 -0
  40. package/microservices/microservice-notifications/src/cli/index.ts +349 -0
  41. package/microservices/microservice-notifications/src/db/database.ts +93 -0
  42. package/microservices/microservice-notifications/src/db/migrations.ts +62 -0
  43. package/microservices/microservice-notifications/src/db/notifications.ts +509 -0
  44. package/microservices/microservice-notifications/src/index.ts +41 -0
  45. package/microservices/microservice-notifications/src/mcp/index.ts +422 -0
  46. package/microservices/microservice-products/package.json +27 -0
  47. package/microservices/microservice-products/src/cli/index.ts +416 -0
  48. package/microservices/microservice-products/src/db/categories.ts +154 -0
  49. package/microservices/microservice-products/src/db/database.ts +93 -0
  50. package/microservices/microservice-products/src/db/migrations.ts +58 -0
  51. package/microservices/microservice-products/src/db/pricing-tiers.ts +66 -0
  52. package/microservices/microservice-products/src/db/products.ts +452 -0
  53. package/microservices/microservice-products/src/index.ts +53 -0
  54. package/microservices/microservice-products/src/mcp/index.ts +453 -0
  55. package/microservices/microservice-projects/package.json +27 -0
  56. package/microservices/microservice-projects/src/cli/index.ts +480 -0
  57. package/microservices/microservice-projects/src/db/database.ts +93 -0
  58. package/microservices/microservice-projects/src/db/migrations.ts +65 -0
  59. package/microservices/microservice-projects/src/db/projects.ts +715 -0
  60. package/microservices/microservice-projects/src/index.ts +57 -0
  61. package/microservices/microservice-projects/src/mcp/index.ts +501 -0
  62. package/microservices/microservice-proposals/package.json +27 -0
  63. package/microservices/microservice-proposals/src/cli/index.ts +400 -0
  64. package/microservices/microservice-proposals/src/db/database.ts +93 -0
  65. package/microservices/microservice-proposals/src/db/migrations.ts +52 -0
  66. package/microservices/microservice-proposals/src/db/proposals.ts +532 -0
  67. package/microservices/microservice-proposals/src/index.ts +37 -0
  68. package/microservices/microservice-proposals/src/mcp/index.ts +375 -0
  69. package/microservices/microservice-reading/package.json +27 -0
  70. package/microservices/microservice-reading/src/cli/index.ts +464 -0
  71. package/microservices/microservice-reading/src/db/database.ts +93 -0
  72. package/microservices/microservice-reading/src/db/migrations.ts +59 -0
  73. package/microservices/microservice-reading/src/db/reading.ts +524 -0
  74. package/microservices/microservice-reading/src/index.ts +51 -0
  75. package/microservices/microservice-reading/src/mcp/index.ts +368 -0
  76. package/microservices/microservice-travel/package.json +27 -0
  77. package/microservices/microservice-travel/src/cli/index.ts +505 -0
  78. package/microservices/microservice-travel/src/db/database.ts +93 -0
  79. package/microservices/microservice-travel/src/db/migrations.ts +77 -0
  80. package/microservices/microservice-travel/src/db/travel.ts +802 -0
  81. package/microservices/microservice-travel/src/index.ts +60 -0
  82. package/microservices/microservice-travel/src/mcp/index.ts +495 -0
  83. package/microservices/microservice-wiki/package.json +27 -0
  84. package/microservices/microservice-wiki/src/cli/index.ts +345 -0
  85. package/microservices/microservice-wiki/src/db/database.ts +93 -0
  86. package/microservices/microservice-wiki/src/db/migrations.ts +55 -0
  87. package/microservices/microservice-wiki/src/db/wiki.ts +395 -0
  88. package/microservices/microservice-wiki/src/index.ts +32 -0
  89. package/microservices/microservice-wiki/src/mcp/index.ts +344 -0
  90. package/package.json +1 -1
@@ -0,0 +1,344 @@
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
+ createPage,
8
+ getPage,
9
+ getPageBySlug,
10
+ listPages,
11
+ updatePage,
12
+ deletePage,
13
+ searchPages,
14
+ getPageTree,
15
+ getRecentlyUpdated,
16
+ getByCategory,
17
+ getByTag,
18
+ getPageHistory,
19
+ revertToVersion,
20
+ addLink,
21
+ removeLink,
22
+ getLinksFrom,
23
+ getLinksTo,
24
+ } from "../db/wiki.js";
25
+
26
+ const server = new McpServer({
27
+ name: "microservice-wiki",
28
+ version: "0.0.1",
29
+ });
30
+
31
+ // --- Pages ---
32
+
33
+ server.registerTool(
34
+ "create_page",
35
+ {
36
+ title: "Create Page",
37
+ description: "Create a new wiki page.",
38
+ inputSchema: {
39
+ title: z.string(),
40
+ slug: z.string().optional(),
41
+ content: z.string().optional(),
42
+ format: z.enum(["markdown", "html"]).optional(),
43
+ category: z.string().optional(),
44
+ parent_id: z.string().optional(),
45
+ author: z.string().optional(),
46
+ status: z.enum(["draft", "published", "archived"]).optional(),
47
+ tags: z.array(z.string()).optional(),
48
+ },
49
+ },
50
+ async (params) => {
51
+ const page = createPage(params);
52
+ return { content: [{ type: "text", text: JSON.stringify(page, null, 2) }] };
53
+ }
54
+ );
55
+
56
+ server.registerTool(
57
+ "get_page",
58
+ {
59
+ title: "Get Page",
60
+ description: "Get a wiki page by ID.",
61
+ inputSchema: { id: z.string() },
62
+ },
63
+ async ({ id }) => {
64
+ const page = getPage(id);
65
+ if (!page) {
66
+ return { content: [{ type: "text", text: `Page '${id}' not found.` }], isError: true };
67
+ }
68
+ return { content: [{ type: "text", text: JSON.stringify(page, null, 2) }] };
69
+ }
70
+ );
71
+
72
+ server.registerTool(
73
+ "get_page_by_slug",
74
+ {
75
+ title: "Get Page by Slug",
76
+ description: "Get a wiki page by its URL slug.",
77
+ inputSchema: { slug: z.string() },
78
+ },
79
+ async ({ slug }) => {
80
+ const page = getPageBySlug(slug);
81
+ if (!page) {
82
+ return { content: [{ type: "text", text: `Page with slug '${slug}' not found.` }], isError: true };
83
+ }
84
+ return { content: [{ type: "text", text: JSON.stringify(page, null, 2) }] };
85
+ }
86
+ );
87
+
88
+ server.registerTool(
89
+ "list_pages",
90
+ {
91
+ title: "List Pages",
92
+ description: "List wiki pages with optional filters.",
93
+ inputSchema: {
94
+ search: z.string().optional(),
95
+ category: z.string().optional(),
96
+ status: z.enum(["draft", "published", "archived"]).optional(),
97
+ tag: z.string().optional(),
98
+ limit: z.number().optional(),
99
+ },
100
+ },
101
+ async (params) => {
102
+ const pages = listPages(params);
103
+ return {
104
+ content: [
105
+ { type: "text", text: JSON.stringify({ pages, count: pages.length }, null, 2) },
106
+ ],
107
+ };
108
+ }
109
+ );
110
+
111
+ server.registerTool(
112
+ "update_page",
113
+ {
114
+ title: "Update Page",
115
+ description: "Update an existing wiki page. Auto-saves a version snapshot before updating.",
116
+ inputSchema: {
117
+ id: z.string(),
118
+ title: z.string().optional(),
119
+ slug: z.string().optional(),
120
+ content: z.string().optional(),
121
+ format: z.enum(["markdown", "html"]).optional(),
122
+ category: z.string().optional(),
123
+ parent_id: z.string().optional(),
124
+ author: z.string().optional(),
125
+ status: z.enum(["draft", "published", "archived"]).optional(),
126
+ tags: z.array(z.string()).optional(),
127
+ },
128
+ },
129
+ async ({ id, ...input }) => {
130
+ const page = updatePage(id, input);
131
+ if (!page) {
132
+ return { content: [{ type: "text", text: `Page '${id}' not found.` }], isError: true };
133
+ }
134
+ return { content: [{ type: "text", text: JSON.stringify(page, null, 2) }] };
135
+ }
136
+ );
137
+
138
+ server.registerTool(
139
+ "delete_page",
140
+ {
141
+ title: "Delete Page",
142
+ description: "Delete a wiki page by ID.",
143
+ inputSchema: { id: z.string() },
144
+ },
145
+ async ({ id }) => {
146
+ const deleted = deletePage(id);
147
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
148
+ }
149
+ );
150
+
151
+ server.registerTool(
152
+ "search_pages",
153
+ {
154
+ title: "Search Pages",
155
+ description: "Search wiki pages by title or content.",
156
+ inputSchema: { query: z.string() },
157
+ },
158
+ async ({ query }) => {
159
+ const results = searchPages(query);
160
+ return {
161
+ content: [
162
+ { type: "text", text: JSON.stringify({ results, count: results.length }, null, 2) },
163
+ ],
164
+ };
165
+ }
166
+ );
167
+
168
+ server.registerTool(
169
+ "get_page_tree",
170
+ {
171
+ title: "Get Page Tree",
172
+ description: "Get hierarchical page tree organized by parent-child relationships.",
173
+ inputSchema: {},
174
+ },
175
+ async () => {
176
+ const tree = getPageTree();
177
+ return { content: [{ type: "text", text: JSON.stringify(tree, null, 2) }] };
178
+ }
179
+ );
180
+
181
+ server.registerTool(
182
+ "get_recently_updated",
183
+ {
184
+ title: "Get Recently Updated Pages",
185
+ description: "Get the most recently updated wiki pages.",
186
+ inputSchema: { limit: z.number().optional() },
187
+ },
188
+ async ({ limit }) => {
189
+ const pages = getRecentlyUpdated(limit);
190
+ return {
191
+ content: [
192
+ { type: "text", text: JSON.stringify({ pages, count: pages.length }, null, 2) },
193
+ ],
194
+ };
195
+ }
196
+ );
197
+
198
+ server.registerTool(
199
+ "get_pages_by_category",
200
+ {
201
+ title: "Get Pages by Category",
202
+ description: "Get all wiki pages in a specific category.",
203
+ inputSchema: { category: z.string() },
204
+ },
205
+ async ({ category }) => {
206
+ const pages = getByCategory(category);
207
+ return {
208
+ content: [
209
+ { type: "text", text: JSON.stringify({ pages, count: pages.length }, null, 2) },
210
+ ],
211
+ };
212
+ }
213
+ );
214
+
215
+ server.registerTool(
216
+ "get_pages_by_tag",
217
+ {
218
+ title: "Get Pages by Tag",
219
+ description: "Get all wiki pages with a specific tag.",
220
+ inputSchema: { tag: z.string() },
221
+ },
222
+ async ({ tag }) => {
223
+ const pages = getByTag(tag);
224
+ return {
225
+ content: [
226
+ { type: "text", text: JSON.stringify({ pages, count: pages.length }, null, 2) },
227
+ ],
228
+ };
229
+ }
230
+ );
231
+
232
+ server.registerTool(
233
+ "get_page_history",
234
+ {
235
+ title: "Get Page History",
236
+ description: "Get the version history of a wiki page.",
237
+ inputSchema: { page_id: z.string() },
238
+ },
239
+ async ({ page_id }) => {
240
+ const history = getPageHistory(page_id);
241
+ return {
242
+ content: [
243
+ { type: "text", text: JSON.stringify({ versions: history, count: history.length }, null, 2) },
244
+ ],
245
+ };
246
+ }
247
+ );
248
+
249
+ server.registerTool(
250
+ "revert_page",
251
+ {
252
+ title: "Revert Page",
253
+ description: "Revert a wiki page to a previous version.",
254
+ inputSchema: {
255
+ page_id: z.string(),
256
+ version: z.number(),
257
+ },
258
+ },
259
+ async ({ page_id, version }) => {
260
+ const page = revertToVersion(page_id, version);
261
+ if (!page) {
262
+ return { content: [{ type: "text", text: `Page '${page_id}' or version ${version} not found.` }], isError: true };
263
+ }
264
+ return { content: [{ type: "text", text: JSON.stringify(page, null, 2) }] };
265
+ }
266
+ );
267
+
268
+ server.registerTool(
269
+ "add_page_link",
270
+ {
271
+ title: "Add Page Link",
272
+ description: "Create a link between two wiki pages.",
273
+ inputSchema: {
274
+ source_id: z.string(),
275
+ target_id: z.string(),
276
+ },
277
+ },
278
+ async ({ source_id, target_id }) => {
279
+ const link = addLink(source_id, target_id);
280
+ return { content: [{ type: "text", text: JSON.stringify(link, null, 2) }] };
281
+ }
282
+ );
283
+
284
+ server.registerTool(
285
+ "remove_page_link",
286
+ {
287
+ title: "Remove Page Link",
288
+ description: "Remove a link between two wiki pages.",
289
+ inputSchema: {
290
+ source_id: z.string(),
291
+ target_id: z.string(),
292
+ },
293
+ },
294
+ async ({ source_id, target_id }) => {
295
+ const removed = removeLink(source_id, target_id);
296
+ return { content: [{ type: "text", text: JSON.stringify({ source_id, target_id, removed }) }] };
297
+ }
298
+ );
299
+
300
+ server.registerTool(
301
+ "get_links_from",
302
+ {
303
+ title: "Get Outgoing Links",
304
+ description: "Get all links from a wiki page to other pages.",
305
+ inputSchema: { page_id: z.string() },
306
+ },
307
+ async ({ page_id }) => {
308
+ const links = getLinksFrom(page_id);
309
+ return {
310
+ content: [
311
+ { type: "text", text: JSON.stringify({ links, count: links.length }, null, 2) },
312
+ ],
313
+ };
314
+ }
315
+ );
316
+
317
+ server.registerTool(
318
+ "get_links_to",
319
+ {
320
+ title: "Get Incoming Links",
321
+ description: "Get all links to a wiki page from other pages.",
322
+ inputSchema: { page_id: z.string() },
323
+ },
324
+ async ({ page_id }) => {
325
+ const links = getLinksTo(page_id);
326
+ return {
327
+ content: [
328
+ { type: "text", text: JSON.stringify({ links, count: links.length }, null, 2) },
329
+ ],
330
+ };
331
+ }
332
+ );
333
+
334
+ // --- Start ---
335
+ async function main() {
336
+ const transport = new StdioServerTransport();
337
+ await server.connect(transport);
338
+ console.error("microservice-wiki MCP server running on stdio");
339
+ }
340
+
341
+ main().catch((error) => {
342
+ console.error("Fatal error:", error);
343
+ process.exit(1);
344
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/microservices",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "Mini business apps for AI agents - invoices, contacts, bookkeeping and more, each with its own SQLite database",
5
5
  "type": "module",
6
6
  "bin": {