@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,435 @@
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
+ createAccount,
8
+ getAccount,
9
+ listAccounts,
10
+ updateAccount,
11
+ deleteAccount,
12
+ createPost,
13
+ getPost,
14
+ listPosts,
15
+ updatePost,
16
+ deletePost,
17
+ schedulePost,
18
+ publishPost,
19
+ createTemplate,
20
+ getTemplate,
21
+ listTemplates,
22
+ deleteTemplate,
23
+ useTemplate,
24
+ getEngagementStats,
25
+ getStatsByPlatform,
26
+ getCalendar,
27
+ getOverallStats,
28
+ } from "../db/social.js";
29
+
30
+ const PlatformEnum = z.enum(["x", "linkedin", "instagram", "threads", "bluesky"]);
31
+ const PostStatusEnum = z.enum(["draft", "scheduled", "published", "failed"]);
32
+
33
+ const server = new McpServer({
34
+ name: "microservice-social",
35
+ version: "0.0.1",
36
+ });
37
+
38
+ // --- Accounts ---
39
+
40
+ server.registerTool(
41
+ "create_account",
42
+ {
43
+ title: "Create Social Account",
44
+ description: "Add a social media account.",
45
+ inputSchema: {
46
+ platform: PlatformEnum,
47
+ handle: z.string(),
48
+ display_name: z.string().optional(),
49
+ connected: z.boolean().optional(),
50
+ access_token_env: z.string().optional(),
51
+ },
52
+ },
53
+ async (params) => {
54
+ const account = createAccount(params);
55
+ return { content: [{ type: "text", text: JSON.stringify(account, null, 2) }] };
56
+ }
57
+ );
58
+
59
+ server.registerTool(
60
+ "get_account",
61
+ {
62
+ title: "Get Social Account",
63
+ description: "Get a social media account by ID.",
64
+ inputSchema: { id: z.string() },
65
+ },
66
+ async ({ id }) => {
67
+ const account = getAccount(id);
68
+ if (!account) {
69
+ return { content: [{ type: "text", text: `Account '${id}' not found.` }], isError: true };
70
+ }
71
+ return { content: [{ type: "text", text: JSON.stringify(account, null, 2) }] };
72
+ }
73
+ );
74
+
75
+ server.registerTool(
76
+ "list_accounts",
77
+ {
78
+ title: "List Social Accounts",
79
+ description: "List social media accounts with optional filters.",
80
+ inputSchema: {
81
+ platform: PlatformEnum.optional(),
82
+ connected: z.boolean().optional(),
83
+ limit: z.number().optional(),
84
+ },
85
+ },
86
+ async (params) => {
87
+ const accounts = listAccounts(params);
88
+ return {
89
+ content: [
90
+ { type: "text", text: JSON.stringify({ accounts, count: accounts.length }, null, 2) },
91
+ ],
92
+ };
93
+ }
94
+ );
95
+
96
+ server.registerTool(
97
+ "update_account",
98
+ {
99
+ title: "Update Social Account",
100
+ description: "Update a social media account.",
101
+ inputSchema: {
102
+ id: z.string(),
103
+ platform: PlatformEnum.optional(),
104
+ handle: z.string().optional(),
105
+ display_name: z.string().optional(),
106
+ connected: z.boolean().optional(),
107
+ access_token_env: z.string().optional(),
108
+ },
109
+ },
110
+ async ({ id, ...input }) => {
111
+ const account = updateAccount(id, input);
112
+ if (!account) {
113
+ return { content: [{ type: "text", text: `Account '${id}' not found.` }], isError: true };
114
+ }
115
+ return { content: [{ type: "text", text: JSON.stringify(account, null, 2) }] };
116
+ }
117
+ );
118
+
119
+ server.registerTool(
120
+ "delete_account",
121
+ {
122
+ title: "Delete Social Account",
123
+ description: "Delete a social media account by ID.",
124
+ inputSchema: { id: z.string() },
125
+ },
126
+ async ({ id }) => {
127
+ const deleted = deleteAccount(id);
128
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
129
+ }
130
+ );
131
+
132
+ // --- Posts ---
133
+
134
+ server.registerTool(
135
+ "create_post",
136
+ {
137
+ title: "Create Post",
138
+ description: "Create a new social media post.",
139
+ inputSchema: {
140
+ account_id: z.string(),
141
+ content: z.string(),
142
+ media_urls: z.array(z.string()).optional(),
143
+ status: PostStatusEnum.optional(),
144
+ scheduled_at: z.string().optional(),
145
+ tags: z.array(z.string()).optional(),
146
+ },
147
+ },
148
+ async (params) => {
149
+ const post = createPost(params);
150
+ return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] };
151
+ }
152
+ );
153
+
154
+ server.registerTool(
155
+ "get_post",
156
+ {
157
+ title: "Get Post",
158
+ description: "Get a post by ID.",
159
+ inputSchema: { id: z.string() },
160
+ },
161
+ async ({ id }) => {
162
+ const post = getPost(id);
163
+ if (!post) {
164
+ return { content: [{ type: "text", text: `Post '${id}' not found.` }], isError: true };
165
+ }
166
+ return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] };
167
+ }
168
+ );
169
+
170
+ server.registerTool(
171
+ "list_posts",
172
+ {
173
+ title: "List Posts",
174
+ description: "List posts with optional filters.",
175
+ inputSchema: {
176
+ account_id: z.string().optional(),
177
+ status: PostStatusEnum.optional(),
178
+ tag: z.string().optional(),
179
+ search: z.string().optional(),
180
+ limit: z.number().optional(),
181
+ },
182
+ },
183
+ async (params) => {
184
+ const posts = listPosts(params);
185
+ return {
186
+ content: [
187
+ { type: "text", text: JSON.stringify({ posts, count: posts.length }, null, 2) },
188
+ ],
189
+ };
190
+ }
191
+ );
192
+
193
+ server.registerTool(
194
+ "update_post",
195
+ {
196
+ title: "Update Post",
197
+ description: "Update an existing post.",
198
+ inputSchema: {
199
+ id: z.string(),
200
+ content: z.string().optional(),
201
+ media_urls: z.array(z.string()).optional(),
202
+ status: PostStatusEnum.optional(),
203
+ scheduled_at: z.string().optional(),
204
+ published_at: z.string().optional(),
205
+ platform_post_id: z.string().optional(),
206
+ engagement: z.object({
207
+ likes: z.number().optional(),
208
+ shares: z.number().optional(),
209
+ comments: z.number().optional(),
210
+ impressions: z.number().optional(),
211
+ clicks: z.number().optional(),
212
+ }).optional(),
213
+ tags: z.array(z.string()).optional(),
214
+ },
215
+ },
216
+ async ({ id, ...input }) => {
217
+ const post = updatePost(id, input);
218
+ if (!post) {
219
+ return { content: [{ type: "text", text: `Post '${id}' not found.` }], isError: true };
220
+ }
221
+ return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] };
222
+ }
223
+ );
224
+
225
+ server.registerTool(
226
+ "delete_post",
227
+ {
228
+ title: "Delete Post",
229
+ description: "Delete a post by ID.",
230
+ inputSchema: { id: z.string() },
231
+ },
232
+ async ({ id }) => {
233
+ const deleted = deletePost(id);
234
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
235
+ }
236
+ );
237
+
238
+ server.registerTool(
239
+ "schedule_post",
240
+ {
241
+ title: "Schedule Post",
242
+ description: "Schedule a post for a specific date/time.",
243
+ inputSchema: {
244
+ id: z.string(),
245
+ scheduled_at: z.string(),
246
+ },
247
+ },
248
+ async ({ id, scheduled_at }) => {
249
+ const post = schedulePost(id, scheduled_at);
250
+ if (!post) {
251
+ return { content: [{ type: "text", text: `Post '${id}' not found.` }], isError: true };
252
+ }
253
+ return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] };
254
+ }
255
+ );
256
+
257
+ server.registerTool(
258
+ "publish_post",
259
+ {
260
+ title: "Publish Post",
261
+ description: "Mark a post as published.",
262
+ inputSchema: {
263
+ id: z.string(),
264
+ platform_post_id: z.string().optional(),
265
+ },
266
+ },
267
+ async ({ id, platform_post_id }) => {
268
+ const post = publishPost(id, platform_post_id);
269
+ if (!post) {
270
+ return { content: [{ type: "text", text: `Post '${id}' not found.` }], isError: true };
271
+ }
272
+ return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] };
273
+ }
274
+ );
275
+
276
+ // --- Templates ---
277
+
278
+ server.registerTool(
279
+ "create_template",
280
+ {
281
+ title: "Create Template",
282
+ description: "Create a post template with variables.",
283
+ inputSchema: {
284
+ name: z.string(),
285
+ content: z.string(),
286
+ variables: z.array(z.string()).optional(),
287
+ },
288
+ },
289
+ async (params) => {
290
+ const template = createTemplate(params);
291
+ return { content: [{ type: "text", text: JSON.stringify(template, null, 2) }] };
292
+ }
293
+ );
294
+
295
+ server.registerTool(
296
+ "list_templates",
297
+ {
298
+ title: "List Templates",
299
+ description: "List all post templates.",
300
+ inputSchema: {},
301
+ },
302
+ async () => {
303
+ const templates = listTemplates();
304
+ return {
305
+ content: [
306
+ { type: "text", text: JSON.stringify({ templates, count: templates.length }, null, 2) },
307
+ ],
308
+ };
309
+ }
310
+ );
311
+
312
+ server.registerTool(
313
+ "get_template",
314
+ {
315
+ title: "Get Template",
316
+ description: "Get a template by ID.",
317
+ inputSchema: { id: z.string() },
318
+ },
319
+ async ({ id }) => {
320
+ const template = getTemplate(id);
321
+ if (!template) {
322
+ return { content: [{ type: "text", text: `Template '${id}' not found.` }], isError: true };
323
+ }
324
+ return { content: [{ type: "text", text: JSON.stringify(template, null, 2) }] };
325
+ }
326
+ );
327
+
328
+ server.registerTool(
329
+ "delete_template",
330
+ {
331
+ title: "Delete Template",
332
+ description: "Delete a template by ID.",
333
+ inputSchema: { id: z.string() },
334
+ },
335
+ async ({ id }) => {
336
+ const deleted = deleteTemplate(id);
337
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
338
+ }
339
+ );
340
+
341
+ server.registerTool(
342
+ "use_template",
343
+ {
344
+ title: "Use Template",
345
+ description: "Create a post from a template by replacing variables.",
346
+ inputSchema: {
347
+ template_id: z.string(),
348
+ account_id: z.string(),
349
+ values: z.record(z.string()).optional(),
350
+ tags: z.array(z.string()).optional(),
351
+ },
352
+ },
353
+ async ({ template_id, account_id, values, tags }) => {
354
+ try {
355
+ const post = useTemplate(template_id, account_id, values || {}, tags);
356
+ return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] };
357
+ } catch (error) {
358
+ return {
359
+ content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
360
+ isError: true,
361
+ };
362
+ }
363
+ }
364
+ );
365
+
366
+ // --- Analytics ---
367
+
368
+ server.registerTool(
369
+ "get_engagement_stats",
370
+ {
371
+ title: "Get Engagement Stats",
372
+ description: "Get engagement analytics for published posts.",
373
+ inputSchema: {
374
+ account_id: z.string().optional(),
375
+ },
376
+ },
377
+ async ({ account_id }) => {
378
+ const stats = getEngagementStats(account_id);
379
+ return { content: [{ type: "text", text: JSON.stringify(stats, null, 2) }] };
380
+ }
381
+ );
382
+
383
+ server.registerTool(
384
+ "get_stats_by_platform",
385
+ {
386
+ title: "Get Stats By Platform",
387
+ description: "Get analytics grouped by social media platform.",
388
+ inputSchema: {},
389
+ },
390
+ async () => {
391
+ const stats = getStatsByPlatform();
392
+ return { content: [{ type: "text", text: JSON.stringify(stats, null, 2) }] };
393
+ }
394
+ );
395
+
396
+ server.registerTool(
397
+ "get_calendar",
398
+ {
399
+ title: "Get Calendar",
400
+ description: "View scheduled posts grouped by date.",
401
+ inputSchema: {
402
+ start_date: z.string().optional(),
403
+ end_date: z.string().optional(),
404
+ },
405
+ },
406
+ async ({ start_date, end_date }) => {
407
+ const calendar = getCalendar(start_date, end_date);
408
+ return { content: [{ type: "text", text: JSON.stringify(calendar, null, 2) }] };
409
+ }
410
+ );
411
+
412
+ server.registerTool(
413
+ "get_overall_stats",
414
+ {
415
+ title: "Get Overall Stats",
416
+ description: "Get overall social media management statistics.",
417
+ inputSchema: {},
418
+ },
419
+ async () => {
420
+ const stats = getOverallStats();
421
+ return { content: [{ type: "text", text: JSON.stringify(stats, null, 2) }] };
422
+ }
423
+ );
424
+
425
+ // --- Start ---
426
+ async function main() {
427
+ const transport = new StdioServerTransport();
428
+ await server.connect(transport);
429
+ console.error("microservice-social MCP server running on stdio");
430
+ }
431
+
432
+ main().catch((error) => {
433
+ console.error("Fatal error:", error);
434
+ process.exit(1);
435
+ });
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@hasna/microservice-subscriptions",
3
+ "version": "0.0.1",
4
+ "description": "Subscription and recurring billing management microservice with SQLite — manage plans, subscribers, and billing events",
5
+ "type": "module",
6
+ "bin": {
7
+ "microservice-subscriptions": "./src/cli/index.ts",
8
+ "microservice-subscriptions-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
+ }