@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,320 @@
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
+ createCampaign,
8
+ getCampaign,
9
+ listCampaigns,
10
+ updateCampaign,
11
+ deleteCampaign,
12
+ pauseCampaign,
13
+ resumeCampaign,
14
+ getCampaignStats,
15
+ getSpendByPlatform,
16
+ getPlatforms,
17
+ createAdGroup,
18
+ listAdGroups,
19
+ createAd,
20
+ listAds,
21
+ } from "../db/campaigns.js";
22
+
23
+ const server = new McpServer({
24
+ name: "microservice-ads",
25
+ version: "0.0.1",
26
+ });
27
+
28
+ const PlatformEnum = z.enum(["google", "meta", "linkedin", "tiktok"]);
29
+ const StatusEnum = z.enum(["draft", "active", "paused", "completed"]);
30
+
31
+ // --- Campaigns ---
32
+
33
+ server.registerTool(
34
+ "create_campaign",
35
+ {
36
+ title: "Create Campaign",
37
+ description: "Create a new ad campaign.",
38
+ inputSchema: {
39
+ platform: PlatformEnum,
40
+ name: z.string(),
41
+ status: StatusEnum.optional(),
42
+ budget_daily: z.number().optional(),
43
+ budget_total: z.number().optional(),
44
+ start_date: z.string().optional(),
45
+ end_date: z.string().optional(),
46
+ metadata: z.record(z.unknown()).optional(),
47
+ },
48
+ },
49
+ async (params) => {
50
+ const campaign = createCampaign(params);
51
+ return { content: [{ type: "text", text: JSON.stringify(campaign, null, 2) }] };
52
+ }
53
+ );
54
+
55
+ server.registerTool(
56
+ "get_campaign",
57
+ {
58
+ title: "Get Campaign",
59
+ description: "Get a campaign by ID.",
60
+ inputSchema: { id: z.string() },
61
+ },
62
+ async ({ id }) => {
63
+ const campaign = getCampaign(id);
64
+ if (!campaign) {
65
+ return { content: [{ type: "text", text: `Campaign '${id}' not found.` }], isError: true };
66
+ }
67
+ return { content: [{ type: "text", text: JSON.stringify(campaign, null, 2) }] };
68
+ }
69
+ );
70
+
71
+ server.registerTool(
72
+ "list_campaigns",
73
+ {
74
+ title: "List Campaigns",
75
+ description: "List campaigns with optional filters.",
76
+ inputSchema: {
77
+ platform: PlatformEnum.optional(),
78
+ status: StatusEnum.optional(),
79
+ search: z.string().optional(),
80
+ limit: z.number().optional(),
81
+ },
82
+ },
83
+ async (params) => {
84
+ const campaigns = listCampaigns(params);
85
+ return {
86
+ content: [
87
+ {
88
+ type: "text",
89
+ text: JSON.stringify({ campaigns, count: campaigns.length }, null, 2),
90
+ },
91
+ ],
92
+ };
93
+ }
94
+ );
95
+
96
+ server.registerTool(
97
+ "update_campaign",
98
+ {
99
+ title: "Update Campaign",
100
+ description: "Update an existing campaign.",
101
+ inputSchema: {
102
+ id: z.string(),
103
+ platform: PlatformEnum.optional(),
104
+ name: z.string().optional(),
105
+ status: StatusEnum.optional(),
106
+ budget_daily: z.number().optional(),
107
+ budget_total: z.number().optional(),
108
+ spend: z.number().optional(),
109
+ impressions: z.number().optional(),
110
+ clicks: z.number().optional(),
111
+ conversions: z.number().optional(),
112
+ roas: z.number().optional(),
113
+ start_date: z.string().optional(),
114
+ end_date: z.string().optional(),
115
+ metadata: z.record(z.unknown()).optional(),
116
+ },
117
+ },
118
+ async ({ id, ...input }) => {
119
+ const campaign = updateCampaign(id, input);
120
+ if (!campaign) {
121
+ return { content: [{ type: "text", text: `Campaign '${id}' not found.` }], isError: true };
122
+ }
123
+ return { content: [{ type: "text", text: JSON.stringify(campaign, null, 2) }] };
124
+ }
125
+ );
126
+
127
+ server.registerTool(
128
+ "delete_campaign",
129
+ {
130
+ title: "Delete Campaign",
131
+ description: "Delete a campaign by ID.",
132
+ inputSchema: { id: z.string() },
133
+ },
134
+ async ({ id }) => {
135
+ const deleted = deleteCampaign(id);
136
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
137
+ }
138
+ );
139
+
140
+ server.registerTool(
141
+ "pause_campaign",
142
+ {
143
+ title: "Pause Campaign",
144
+ description: "Pause an active campaign.",
145
+ inputSchema: { id: z.string() },
146
+ },
147
+ async ({ id }) => {
148
+ const campaign = pauseCampaign(id);
149
+ if (!campaign) {
150
+ return { content: [{ type: "text", text: `Campaign '${id}' not found.` }], isError: true };
151
+ }
152
+ return { content: [{ type: "text", text: JSON.stringify(campaign, null, 2) }] };
153
+ }
154
+ );
155
+
156
+ server.registerTool(
157
+ "resume_campaign",
158
+ {
159
+ title: "Resume Campaign",
160
+ description: "Resume a paused campaign.",
161
+ inputSchema: { id: z.string() },
162
+ },
163
+ async ({ id }) => {
164
+ const campaign = resumeCampaign(id);
165
+ if (!campaign) {
166
+ return { content: [{ type: "text", text: `Campaign '${id}' not found.` }], isError: true };
167
+ }
168
+ return { content: [{ type: "text", text: JSON.stringify(campaign, null, 2) }] };
169
+ }
170
+ );
171
+
172
+ server.registerTool(
173
+ "campaign_stats",
174
+ {
175
+ title: "Campaign Stats",
176
+ description: "Get aggregate campaign statistics.",
177
+ inputSchema: {},
178
+ },
179
+ async () => {
180
+ const stats = getCampaignStats();
181
+ return { content: [{ type: "text", text: JSON.stringify(stats, null, 2) }] };
182
+ }
183
+ );
184
+
185
+ server.registerTool(
186
+ "spend_by_platform",
187
+ {
188
+ title: "Spend by Platform",
189
+ description: "Get total spend broken down by platform.",
190
+ inputSchema: {},
191
+ },
192
+ async () => {
193
+ const spend = getSpendByPlatform();
194
+ return { content: [{ type: "text", text: JSON.stringify(spend, null, 2) }] };
195
+ }
196
+ );
197
+
198
+ server.registerTool(
199
+ "list_platforms",
200
+ {
201
+ title: "List Platforms",
202
+ description: "List platforms that have campaigns.",
203
+ inputSchema: {},
204
+ },
205
+ async () => {
206
+ const platforms = getPlatforms();
207
+ return { content: [{ type: "text", text: JSON.stringify(platforms, null, 2) }] };
208
+ }
209
+ );
210
+
211
+ server.registerTool(
212
+ "list_providers",
213
+ {
214
+ title: "List Providers",
215
+ description: "List all supported ad providers.",
216
+ inputSchema: {},
217
+ },
218
+ async () => {
219
+ const providers = ["google", "meta", "linkedin", "tiktok"];
220
+ return { content: [{ type: "text", text: JSON.stringify(providers, null, 2) }] };
221
+ }
222
+ );
223
+
224
+ // --- Ad Groups ---
225
+
226
+ server.registerTool(
227
+ "create_ad_group",
228
+ {
229
+ title: "Create Ad Group",
230
+ description: "Create a new ad group within a campaign.",
231
+ inputSchema: {
232
+ campaign_id: z.string(),
233
+ name: z.string(),
234
+ targeting: z.record(z.unknown()).optional(),
235
+ status: StatusEnum.optional(),
236
+ },
237
+ },
238
+ async (params) => {
239
+ const adGroup = createAdGroup(params);
240
+ return { content: [{ type: "text", text: JSON.stringify(adGroup, null, 2) }] };
241
+ }
242
+ );
243
+
244
+ server.registerTool(
245
+ "list_ad_groups",
246
+ {
247
+ title: "List Ad Groups",
248
+ description: "List ad groups, optionally filtered by campaign.",
249
+ inputSchema: {
250
+ campaign_id: z.string().optional(),
251
+ },
252
+ },
253
+ async ({ campaign_id }) => {
254
+ const adGroups = listAdGroups(campaign_id);
255
+ return {
256
+ content: [
257
+ {
258
+ type: "text",
259
+ text: JSON.stringify({ ad_groups: adGroups, count: adGroups.length }, null, 2),
260
+ },
261
+ ],
262
+ };
263
+ }
264
+ );
265
+
266
+ // --- Ads ---
267
+
268
+ server.registerTool(
269
+ "create_ad",
270
+ {
271
+ title: "Create Ad",
272
+ description: "Create a new ad within an ad group.",
273
+ inputSchema: {
274
+ ad_group_id: z.string(),
275
+ headline: z.string(),
276
+ description: z.string().optional(),
277
+ creative_url: z.string().optional(),
278
+ status: StatusEnum.optional(),
279
+ metrics: z.record(z.unknown()).optional(),
280
+ },
281
+ },
282
+ async (params) => {
283
+ const ad = createAd(params);
284
+ return { content: [{ type: "text", text: JSON.stringify(ad, null, 2) }] };
285
+ }
286
+ );
287
+
288
+ server.registerTool(
289
+ "list_ads",
290
+ {
291
+ title: "List Ads",
292
+ description: "List ads, optionally filtered by ad group.",
293
+ inputSchema: {
294
+ ad_group_id: z.string().optional(),
295
+ },
296
+ },
297
+ async ({ ad_group_id }) => {
298
+ const ads = listAds(ad_group_id);
299
+ return {
300
+ content: [
301
+ {
302
+ type: "text",
303
+ text: JSON.stringify({ ads, count: ads.length }, null, 2),
304
+ },
305
+ ],
306
+ };
307
+ }
308
+ );
309
+
310
+ // --- Start ---
311
+ async function main() {
312
+ const transport = new StdioServerTransport();
313
+ await server.connect(transport);
314
+ console.error("microservice-ads MCP server running on stdio");
315
+ }
316
+
317
+ main().catch((error) => {
318
+ console.error("Fatal error:", error);
319
+ process.exit(1);
320
+ });
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@hasna/microservice-contracts",
3
+ "version": "0.0.1",
4
+ "description": "Contract and agreement management microservice with SQLite — manage contracts, clauses, and reminders",
5
+ "type": "module",
6
+ "bin": {
7
+ "microservice-contracts": "./src/cli/index.ts",
8
+ "microservice-contracts-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
+ }