@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,93 @@
1
+ /**
2
+ * Database connection for microservice-compliance
3
+ */
4
+
5
+ import { Database } from "bun:sqlite";
6
+ import { existsSync, mkdirSync } from "node:fs";
7
+ import { dirname, join, resolve } from "node:path";
8
+ import { MIGRATIONS } from "./migrations.js";
9
+
10
+ let _db: Database | null = null;
11
+
12
+ function getDbPath(): string {
13
+ // Environment variable override
14
+ if (process.env["MICROSERVICES_DIR"]) {
15
+ return join(process.env["MICROSERVICES_DIR"], "microservice-compliance", "data.db");
16
+ }
17
+
18
+ // Check for .microservices in current or parent directories
19
+ let dir = resolve(process.cwd());
20
+ while (true) {
21
+ const candidate = join(dir, ".microservices", "microservice-compliance", "data.db");
22
+ const msDir = join(dir, ".microservices");
23
+ if (existsSync(msDir)) return candidate;
24
+ const parent = dirname(dir);
25
+ if (parent === dir) break;
26
+ dir = parent;
27
+ }
28
+
29
+ // Global fallback
30
+ const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
31
+ return join(home, ".microservices", "microservice-compliance", "data.db");
32
+ }
33
+
34
+ function ensureDir(filePath: string): void {
35
+ const dir = dirname(resolve(filePath));
36
+ if (!existsSync(dir)) {
37
+ mkdirSync(dir, { recursive: true });
38
+ }
39
+ }
40
+
41
+ export function getDatabase(): Database {
42
+ if (_db) return _db;
43
+
44
+ const dbPath = getDbPath();
45
+ ensureDir(dbPath);
46
+
47
+ _db = new Database(dbPath);
48
+ _db.exec("PRAGMA journal_mode = WAL");
49
+ _db.exec("PRAGMA foreign_keys = ON");
50
+
51
+ // Create migrations table
52
+ _db.exec(`
53
+ CREATE TABLE IF NOT EXISTS _migrations (
54
+ id INTEGER PRIMARY KEY,
55
+ name TEXT NOT NULL,
56
+ applied_at TEXT NOT NULL DEFAULT (datetime('now'))
57
+ )
58
+ `);
59
+
60
+ // Apply pending migrations
61
+ const applied = _db
62
+ .query("SELECT id FROM _migrations ORDER BY id")
63
+ .all() as { id: number }[];
64
+ const appliedIds = new Set(applied.map((r) => r.id));
65
+
66
+ for (const migration of MIGRATIONS) {
67
+ if (appliedIds.has(migration.id)) continue;
68
+
69
+ _db.exec("BEGIN");
70
+ try {
71
+ _db.exec(migration.sql);
72
+ _db.prepare("INSERT INTO _migrations (id, name) VALUES (?, ?)").run(
73
+ migration.id,
74
+ migration.name
75
+ );
76
+ _db.exec("COMMIT");
77
+ } catch (error) {
78
+ _db.exec("ROLLBACK");
79
+ throw new Error(
80
+ `Migration ${migration.id} (${migration.name}) failed: ${error instanceof Error ? error.message : String(error)}`
81
+ );
82
+ }
83
+ }
84
+
85
+ return _db;
86
+ }
87
+
88
+ export function closeDatabase(): void {
89
+ if (_db) {
90
+ _db.close();
91
+ _db = null;
92
+ }
93
+ }
@@ -0,0 +1,63 @@
1
+ export interface MigrationEntry {
2
+ id: number;
3
+ name: string;
4
+ sql: string;
5
+ }
6
+
7
+ export const MIGRATIONS: MigrationEntry[] = [
8
+ {
9
+ id: 1,
10
+ name: "initial_schema",
11
+ sql: `
12
+ CREATE TABLE IF NOT EXISTS requirements (
13
+ id TEXT PRIMARY KEY,
14
+ name TEXT NOT NULL,
15
+ framework TEXT CHECK(framework IN ('gdpr','soc2','hipaa','pci','tax','iso27001','custom')),
16
+ status TEXT NOT NULL DEFAULT 'in_progress' CHECK(status IN ('compliant','non_compliant','in_progress','not_applicable')),
17
+ description TEXT,
18
+ evidence TEXT,
19
+ due_date TEXT,
20
+ reviewed_at TEXT,
21
+ reviewer TEXT,
22
+ metadata TEXT NOT NULL DEFAULT '{}',
23
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
24
+ updated_at TEXT NOT NULL DEFAULT (datetime('now'))
25
+ );
26
+
27
+ CREATE TABLE IF NOT EXISTS licenses (
28
+ id TEXT PRIMARY KEY,
29
+ name TEXT NOT NULL,
30
+ type TEXT CHECK(type IN ('software','business','professional','patent','trademark')),
31
+ issuer TEXT,
32
+ license_number TEXT,
33
+ status TEXT NOT NULL DEFAULT 'active' CHECK(status IN ('active','expired','pending_renewal')),
34
+ issued_at TEXT,
35
+ expires_at TEXT,
36
+ auto_renew INTEGER NOT NULL DEFAULT 0,
37
+ cost REAL,
38
+ metadata TEXT NOT NULL DEFAULT '{}',
39
+ created_at TEXT NOT NULL DEFAULT (datetime('now'))
40
+ );
41
+
42
+ CREATE TABLE IF NOT EXISTS audits (
43
+ id TEXT PRIMARY KEY,
44
+ name TEXT NOT NULL,
45
+ framework TEXT,
46
+ status TEXT NOT NULL DEFAULT 'scheduled' CHECK(status IN ('scheduled','in_progress','completed','failed')),
47
+ findings TEXT NOT NULL DEFAULT '[]',
48
+ auditor TEXT,
49
+ scheduled_at TEXT,
50
+ completed_at TEXT,
51
+ created_at TEXT NOT NULL DEFAULT (datetime('now'))
52
+ );
53
+
54
+ CREATE INDEX IF NOT EXISTS idx_requirements_framework ON requirements(framework);
55
+ CREATE INDEX IF NOT EXISTS idx_requirements_status ON requirements(status);
56
+ CREATE INDEX IF NOT EXISTS idx_requirements_due_date ON requirements(due_date);
57
+ CREATE INDEX IF NOT EXISTS idx_licenses_status ON licenses(status);
58
+ CREATE INDEX IF NOT EXISTS idx_licenses_expires_at ON licenses(expires_at);
59
+ CREATE INDEX IF NOT EXISTS idx_audits_framework ON audits(framework);
60
+ CREATE INDEX IF NOT EXISTS idx_audits_status ON audits(status);
61
+ `,
62
+ },
63
+ ];
@@ -0,0 +1,46 @@
1
+ /**
2
+ * microservice-compliance — Compliance management microservice
3
+ */
4
+
5
+ export {
6
+ createRequirement,
7
+ getRequirement,
8
+ listRequirements,
9
+ updateRequirement,
10
+ deleteRequirement,
11
+ searchRequirements,
12
+ createLicense,
13
+ getLicense,
14
+ listLicenses,
15
+ updateLicense,
16
+ deleteLicense,
17
+ renewLicense,
18
+ listExpiringLicenses,
19
+ getLicenseStats,
20
+ scheduleAudit,
21
+ getAudit,
22
+ listAudits,
23
+ completeAudit,
24
+ getAuditReport,
25
+ deleteAudit,
26
+ getComplianceScore,
27
+ getFrameworkStatus,
28
+ type Requirement,
29
+ type License,
30
+ type Audit,
31
+ type Framework,
32
+ type RequirementStatus,
33
+ type LicenseType,
34
+ type LicenseStatus,
35
+ type AuditStatus,
36
+ type CreateRequirementInput,
37
+ type UpdateRequirementInput,
38
+ type ListRequirementsOptions,
39
+ type CreateLicenseInput,
40
+ type UpdateLicenseInput,
41
+ type ListLicensesOptions,
42
+ type CreateAuditInput,
43
+ type ListAuditsOptions,
44
+ } from "./db/compliance.js";
45
+
46
+ export { getDatabase, closeDatabase } from "./db/database.js";
@@ -0,0 +1,438 @@
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
+ createRequirement,
8
+ getRequirement,
9
+ listRequirements,
10
+ updateRequirement,
11
+ deleteRequirement,
12
+ searchRequirements,
13
+ createLicense,
14
+ getLicense,
15
+ listLicenses,
16
+ updateLicense,
17
+ deleteLicense,
18
+ renewLicense,
19
+ listExpiringLicenses,
20
+ getLicenseStats,
21
+ scheduleAudit,
22
+ getAudit,
23
+ listAudits,
24
+ completeAudit,
25
+ getAuditReport,
26
+ deleteAudit,
27
+ getComplianceScore,
28
+ getFrameworkStatus,
29
+ } from "../db/compliance.js";
30
+
31
+ const server = new McpServer({
32
+ name: "microservice-compliance",
33
+ version: "0.0.1",
34
+ });
35
+
36
+ // --- Requirements ---
37
+
38
+ server.registerTool(
39
+ "create_requirement",
40
+ {
41
+ title: "Create Requirement",
42
+ description: "Create a new compliance requirement.",
43
+ inputSchema: {
44
+ name: z.string(),
45
+ framework: z.enum(["gdpr", "soc2", "hipaa", "pci", "tax", "iso27001", "custom"]).optional(),
46
+ status: z.enum(["compliant", "non_compliant", "in_progress", "not_applicable"]).optional(),
47
+ description: z.string().optional(),
48
+ evidence: z.string().optional(),
49
+ due_date: z.string().optional(),
50
+ reviewer: z.string().optional(),
51
+ },
52
+ },
53
+ async (params) => {
54
+ const req = createRequirement(params);
55
+ return { content: [{ type: "text", text: JSON.stringify(req, null, 2) }] };
56
+ }
57
+ );
58
+
59
+ server.registerTool(
60
+ "get_requirement",
61
+ {
62
+ title: "Get Requirement",
63
+ description: "Get a compliance requirement by ID.",
64
+ inputSchema: { id: z.string() },
65
+ },
66
+ async ({ id }) => {
67
+ const req = getRequirement(id);
68
+ if (!req) {
69
+ return { content: [{ type: "text", text: `Requirement '${id}' not found.` }], isError: true };
70
+ }
71
+ return { content: [{ type: "text", text: JSON.stringify(req, null, 2) }] };
72
+ }
73
+ );
74
+
75
+ server.registerTool(
76
+ "list_requirements",
77
+ {
78
+ title: "List Requirements",
79
+ description: "List compliance requirements with optional filters.",
80
+ inputSchema: {
81
+ framework: z.string().optional(),
82
+ status: z.string().optional(),
83
+ search: z.string().optional(),
84
+ limit: z.number().optional(),
85
+ },
86
+ },
87
+ async (params) => {
88
+ const reqs = listRequirements(params);
89
+ return {
90
+ content: [{ type: "text", text: JSON.stringify({ requirements: reqs, count: reqs.length }, null, 2) }],
91
+ };
92
+ }
93
+ );
94
+
95
+ server.registerTool(
96
+ "update_requirement",
97
+ {
98
+ title: "Update Requirement",
99
+ description: "Update an existing compliance requirement.",
100
+ inputSchema: {
101
+ id: z.string(),
102
+ name: z.string().optional(),
103
+ framework: z.enum(["gdpr", "soc2", "hipaa", "pci", "tax", "iso27001", "custom"]).optional(),
104
+ status: z.enum(["compliant", "non_compliant", "in_progress", "not_applicable"]).optional(),
105
+ description: z.string().optional(),
106
+ evidence: z.string().optional(),
107
+ due_date: z.string().optional(),
108
+ reviewed_at: z.string().optional(),
109
+ reviewer: z.string().optional(),
110
+ },
111
+ },
112
+ async ({ id, ...input }) => {
113
+ const req = updateRequirement(id, input);
114
+ if (!req) {
115
+ return { content: [{ type: "text", text: `Requirement '${id}' not found.` }], isError: true };
116
+ }
117
+ return { content: [{ type: "text", text: JSON.stringify(req, null, 2) }] };
118
+ }
119
+ );
120
+
121
+ server.registerTool(
122
+ "delete_requirement",
123
+ {
124
+ title: "Delete Requirement",
125
+ description: "Delete a compliance requirement by ID.",
126
+ inputSchema: { id: z.string() },
127
+ },
128
+ async ({ id }) => {
129
+ const deleted = deleteRequirement(id);
130
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
131
+ }
132
+ );
133
+
134
+ server.registerTool(
135
+ "search_requirements",
136
+ {
137
+ title: "Search Requirements",
138
+ description: "Search requirements by name or description.",
139
+ inputSchema: { query: z.string() },
140
+ },
141
+ async ({ query }) => {
142
+ const results = searchRequirements(query);
143
+ return {
144
+ content: [{ type: "text", text: JSON.stringify({ results, count: results.length }, null, 2) }],
145
+ };
146
+ }
147
+ );
148
+
149
+ // --- Licenses ---
150
+
151
+ server.registerTool(
152
+ "create_license",
153
+ {
154
+ title: "Create License",
155
+ description: "Create a new license.",
156
+ inputSchema: {
157
+ name: z.string(),
158
+ type: z.enum(["software", "business", "professional", "patent", "trademark"]).optional(),
159
+ issuer: z.string().optional(),
160
+ license_number: z.string().optional(),
161
+ status: z.enum(["active", "expired", "pending_renewal"]).optional(),
162
+ issued_at: z.string().optional(),
163
+ expires_at: z.string().optional(),
164
+ auto_renew: z.boolean().optional(),
165
+ cost: z.number().optional(),
166
+ },
167
+ },
168
+ async (params) => {
169
+ const lic = createLicense(params);
170
+ return { content: [{ type: "text", text: JSON.stringify(lic, null, 2) }] };
171
+ }
172
+ );
173
+
174
+ server.registerTool(
175
+ "get_license",
176
+ {
177
+ title: "Get License",
178
+ description: "Get a license by ID.",
179
+ inputSchema: { id: z.string() },
180
+ },
181
+ async ({ id }) => {
182
+ const lic = getLicense(id);
183
+ if (!lic) {
184
+ return { content: [{ type: "text", text: `License '${id}' not found.` }], isError: true };
185
+ }
186
+ return { content: [{ type: "text", text: JSON.stringify(lic, null, 2) }] };
187
+ }
188
+ );
189
+
190
+ server.registerTool(
191
+ "list_licenses",
192
+ {
193
+ title: "List Licenses",
194
+ description: "List licenses with optional filters.",
195
+ inputSchema: {
196
+ type: z.string().optional(),
197
+ status: z.string().optional(),
198
+ search: z.string().optional(),
199
+ limit: z.number().optional(),
200
+ },
201
+ },
202
+ async (params) => {
203
+ const lics = listLicenses(params);
204
+ return {
205
+ content: [{ type: "text", text: JSON.stringify({ licenses: lics, count: lics.length }, null, 2) }],
206
+ };
207
+ }
208
+ );
209
+
210
+ server.registerTool(
211
+ "update_license",
212
+ {
213
+ title: "Update License",
214
+ description: "Update an existing license.",
215
+ inputSchema: {
216
+ id: z.string(),
217
+ name: z.string().optional(),
218
+ type: z.enum(["software", "business", "professional", "patent", "trademark"]).optional(),
219
+ issuer: z.string().optional(),
220
+ license_number: z.string().optional(),
221
+ status: z.enum(["active", "expired", "pending_renewal"]).optional(),
222
+ issued_at: z.string().optional(),
223
+ expires_at: z.string().optional(),
224
+ auto_renew: z.boolean().optional(),
225
+ cost: z.number().optional(),
226
+ },
227
+ },
228
+ async ({ id, ...input }) => {
229
+ const lic = updateLicense(id, input);
230
+ if (!lic) {
231
+ return { content: [{ type: "text", text: `License '${id}' not found.` }], isError: true };
232
+ }
233
+ return { content: [{ type: "text", text: JSON.stringify(lic, null, 2) }] };
234
+ }
235
+ );
236
+
237
+ server.registerTool(
238
+ "delete_license",
239
+ {
240
+ title: "Delete License",
241
+ description: "Delete a license by ID.",
242
+ inputSchema: { id: z.string() },
243
+ },
244
+ async ({ id }) => {
245
+ const deleted = deleteLicense(id);
246
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
247
+ }
248
+ );
249
+
250
+ server.registerTool(
251
+ "renew_license",
252
+ {
253
+ title: "Renew License",
254
+ description: "Renew a license with a new expiry date.",
255
+ inputSchema: {
256
+ id: z.string(),
257
+ expires_at: z.string(),
258
+ },
259
+ },
260
+ async ({ id, expires_at }) => {
261
+ const lic = renewLicense(id, expires_at);
262
+ if (!lic) {
263
+ return { content: [{ type: "text", text: `License '${id}' not found.` }], isError: true };
264
+ }
265
+ return { content: [{ type: "text", text: JSON.stringify(lic, null, 2) }] };
266
+ }
267
+ );
268
+
269
+ server.registerTool(
270
+ "list_expiring_licenses",
271
+ {
272
+ title: "List Expiring Licenses",
273
+ description: "List licenses expiring within N days.",
274
+ inputSchema: { days: z.number().default(30) },
275
+ },
276
+ async ({ days }) => {
277
+ const lics = listExpiringLicenses(days);
278
+ return {
279
+ content: [{ type: "text", text: JSON.stringify({ licenses: lics, count: lics.length }, null, 2) }],
280
+ };
281
+ }
282
+ );
283
+
284
+ server.registerTool(
285
+ "get_license_stats",
286
+ {
287
+ title: "Get License Stats",
288
+ description: "Get license statistics — totals by status and type.",
289
+ inputSchema: {},
290
+ },
291
+ async () => {
292
+ const stats = getLicenseStats();
293
+ return { content: [{ type: "text", text: JSON.stringify(stats, null, 2) }] };
294
+ }
295
+ );
296
+
297
+ // --- Audits ---
298
+
299
+ server.registerTool(
300
+ "schedule_audit",
301
+ {
302
+ title: "Schedule Audit",
303
+ description: "Schedule a new compliance audit.",
304
+ inputSchema: {
305
+ name: z.string(),
306
+ framework: z.string().optional(),
307
+ auditor: z.string().optional(),
308
+ scheduled_at: z.string().optional(),
309
+ },
310
+ },
311
+ async (params) => {
312
+ const audit = scheduleAudit(params);
313
+ return { content: [{ type: "text", text: JSON.stringify(audit, null, 2) }] };
314
+ }
315
+ );
316
+
317
+ server.registerTool(
318
+ "get_audit",
319
+ {
320
+ title: "Get Audit",
321
+ description: "Get an audit by ID.",
322
+ inputSchema: { id: z.string() },
323
+ },
324
+ async ({ id }) => {
325
+ const audit = getAudit(id);
326
+ if (!audit) {
327
+ return { content: [{ type: "text", text: `Audit '${id}' not found.` }], isError: true };
328
+ }
329
+ return { content: [{ type: "text", text: JSON.stringify(audit, null, 2) }] };
330
+ }
331
+ );
332
+
333
+ server.registerTool(
334
+ "list_audits",
335
+ {
336
+ title: "List Audits",
337
+ description: "List audits with optional filters.",
338
+ inputSchema: {
339
+ framework: z.string().optional(),
340
+ status: z.string().optional(),
341
+ limit: z.number().optional(),
342
+ },
343
+ },
344
+ async (params) => {
345
+ const audits = listAudits(params);
346
+ return {
347
+ content: [{ type: "text", text: JSON.stringify({ audits, count: audits.length }, null, 2) }],
348
+ };
349
+ }
350
+ );
351
+
352
+ server.registerTool(
353
+ "complete_audit",
354
+ {
355
+ title: "Complete Audit",
356
+ description: "Complete an audit with findings. Audits with critical-severity findings are marked as failed.",
357
+ inputSchema: {
358
+ id: z.string(),
359
+ findings: z.array(z.any()),
360
+ },
361
+ },
362
+ async ({ id, findings }) => {
363
+ const audit = completeAudit(id, findings);
364
+ if (!audit) {
365
+ return { content: [{ type: "text", text: `Audit '${id}' not found.` }], isError: true };
366
+ }
367
+ return { content: [{ type: "text", text: JSON.stringify(audit, null, 2) }] };
368
+ }
369
+ );
370
+
371
+ server.registerTool(
372
+ "get_audit_report",
373
+ {
374
+ title: "Get Audit Report",
375
+ description: "Get a detailed audit report with findings summary.",
376
+ inputSchema: { id: z.string() },
377
+ },
378
+ async ({ id }) => {
379
+ const report = getAuditReport(id);
380
+ if (!report) {
381
+ return { content: [{ type: "text", text: `Audit '${id}' not found.` }], isError: true };
382
+ }
383
+ return { content: [{ type: "text", text: JSON.stringify(report, null, 2) }] };
384
+ }
385
+ );
386
+
387
+ server.registerTool(
388
+ "delete_audit",
389
+ {
390
+ title: "Delete Audit",
391
+ description: "Delete an audit by ID.",
392
+ inputSchema: { id: z.string() },
393
+ },
394
+ async ({ id }) => {
395
+ const deleted = deleteAudit(id);
396
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
397
+ }
398
+ );
399
+
400
+ // --- Analytics ---
401
+
402
+ server.registerTool(
403
+ "get_compliance_score",
404
+ {
405
+ title: "Get Compliance Score",
406
+ description: "Get the overall compliance score — percentage of applicable requirements that are compliant.",
407
+ inputSchema: {},
408
+ },
409
+ async () => {
410
+ const score = getComplianceScore();
411
+ return { content: [{ type: "text", text: JSON.stringify(score, null, 2) }] };
412
+ }
413
+ );
414
+
415
+ server.registerTool(
416
+ "get_framework_status",
417
+ {
418
+ title: "Get Framework Status",
419
+ description: "Get compliance status for a specific framework.",
420
+ inputSchema: { framework: z.string() },
421
+ },
422
+ async ({ framework }) => {
423
+ const status = getFrameworkStatus(framework);
424
+ return { content: [{ type: "text", text: JSON.stringify(status, null, 2) }] };
425
+ }
426
+ );
427
+
428
+ // --- Start ---
429
+ async function main() {
430
+ const transport = new StdioServerTransport();
431
+ await server.connect(transport);
432
+ console.error("microservice-compliance MCP server running on stdio");
433
+ }
434
+
435
+ main().catch((error) => {
436
+ console.error("Fatal error:", error);
437
+ process.exit(1);
438
+ });
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@hasna/microservice-habits",
3
+ "version": "0.0.1",
4
+ "description": "Habit tracking microservice with streaks, completions, and analytics",
5
+ "type": "module",
6
+ "bin": {
7
+ "microservice-habits": "./src/cli/index.ts",
8
+ "microservice-habits-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
+ }