@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.
- package/bin/index.js +236 -36
- package/bin/mcp.js +153 -4
- package/dist/index.js +120 -3
- package/microservices/microservice-analytics/package.json +27 -0
- package/microservices/microservice-analytics/src/cli/index.ts +373 -0
- package/microservices/microservice-analytics/src/db/analytics.ts +564 -0
- package/microservices/microservice-analytics/src/db/database.ts +93 -0
- package/microservices/microservice-analytics/src/db/migrations.ts +50 -0
- package/microservices/microservice-analytics/src/index.ts +37 -0
- package/microservices/microservice-analytics/src/mcp/index.ts +334 -0
- package/microservices/microservice-assets/package.json +27 -0
- package/microservices/microservice-assets/src/cli/index.ts +375 -0
- package/microservices/microservice-assets/src/db/assets.ts +370 -0
- package/microservices/microservice-assets/src/db/database.ts +93 -0
- package/microservices/microservice-assets/src/db/migrations.ts +51 -0
- package/microservices/microservice-assets/src/index.ts +32 -0
- package/microservices/microservice-assets/src/mcp/index.ts +346 -0
- package/microservices/microservice-compliance/package.json +27 -0
- package/microservices/microservice-compliance/src/cli/index.ts +467 -0
- package/microservices/microservice-compliance/src/db/compliance.ts +633 -0
- package/microservices/microservice-compliance/src/db/database.ts +93 -0
- package/microservices/microservice-compliance/src/db/migrations.ts +63 -0
- package/microservices/microservice-compliance/src/index.ts +46 -0
- package/microservices/microservice-compliance/src/mcp/index.ts +438 -0
- package/microservices/microservice-habits/package.json +27 -0
- package/microservices/microservice-habits/src/cli/index.ts +315 -0
- package/microservices/microservice-habits/src/db/database.ts +93 -0
- package/microservices/microservice-habits/src/db/habits.ts +451 -0
- package/microservices/microservice-habits/src/db/migrations.ts +46 -0
- package/microservices/microservice-habits/src/index.ts +31 -0
- package/microservices/microservice-habits/src/mcp/index.ts +313 -0
- package/microservices/microservice-health/package.json +27 -0
- package/microservices/microservice-health/src/cli/index.ts +484 -0
- package/microservices/microservice-health/src/db/database.ts +93 -0
- package/microservices/microservice-health/src/db/health.ts +708 -0
- package/microservices/microservice-health/src/db/migrations.ts +70 -0
- package/microservices/microservice-health/src/index.ts +63 -0
- package/microservices/microservice-health/src/mcp/index.ts +437 -0
- package/microservices/microservice-leads/package.json +27 -0
- package/microservices/microservice-leads/src/cli/index.ts +596 -0
- package/microservices/microservice-leads/src/db/database.ts +93 -0
- package/microservices/microservice-leads/src/db/leads.ts +520 -0
- package/microservices/microservice-leads/src/db/lists.ts +151 -0
- package/microservices/microservice-leads/src/db/migrations.ts +93 -0
- package/microservices/microservice-leads/src/index.ts +65 -0
- package/microservices/microservice-leads/src/lib/enrichment.ts +202 -0
- package/microservices/microservice-leads/src/lib/scoring.ts +134 -0
- package/microservices/microservice-leads/src/mcp/index.ts +533 -0
- package/microservices/microservice-notifications/package.json +27 -0
- package/microservices/microservice-notifications/src/cli/index.ts +349 -0
- package/microservices/microservice-notifications/src/db/database.ts +93 -0
- package/microservices/microservice-notifications/src/db/migrations.ts +62 -0
- package/microservices/microservice-notifications/src/db/notifications.ts +509 -0
- package/microservices/microservice-notifications/src/index.ts +41 -0
- package/microservices/microservice-notifications/src/mcp/index.ts +422 -0
- package/microservices/microservice-products/package.json +27 -0
- package/microservices/microservice-products/src/cli/index.ts +416 -0
- package/microservices/microservice-products/src/db/categories.ts +154 -0
- package/microservices/microservice-products/src/db/database.ts +93 -0
- package/microservices/microservice-products/src/db/migrations.ts +58 -0
- package/microservices/microservice-products/src/db/pricing-tiers.ts +66 -0
- package/microservices/microservice-products/src/db/products.ts +452 -0
- package/microservices/microservice-products/src/index.ts +53 -0
- package/microservices/microservice-products/src/mcp/index.ts +453 -0
- package/microservices/microservice-projects/package.json +27 -0
- package/microservices/microservice-projects/src/cli/index.ts +480 -0
- package/microservices/microservice-projects/src/db/database.ts +93 -0
- package/microservices/microservice-projects/src/db/migrations.ts +65 -0
- package/microservices/microservice-projects/src/db/projects.ts +715 -0
- package/microservices/microservice-projects/src/index.ts +57 -0
- package/microservices/microservice-projects/src/mcp/index.ts +501 -0
- package/microservices/microservice-proposals/package.json +27 -0
- package/microservices/microservice-proposals/src/cli/index.ts +400 -0
- package/microservices/microservice-proposals/src/db/database.ts +93 -0
- package/microservices/microservice-proposals/src/db/migrations.ts +52 -0
- package/microservices/microservice-proposals/src/db/proposals.ts +532 -0
- package/microservices/microservice-proposals/src/index.ts +37 -0
- package/microservices/microservice-proposals/src/mcp/index.ts +375 -0
- package/microservices/microservice-reading/package.json +27 -0
- package/microservices/microservice-reading/src/cli/index.ts +464 -0
- package/microservices/microservice-reading/src/db/database.ts +93 -0
- package/microservices/microservice-reading/src/db/migrations.ts +59 -0
- package/microservices/microservice-reading/src/db/reading.ts +524 -0
- package/microservices/microservice-reading/src/index.ts +51 -0
- package/microservices/microservice-reading/src/mcp/index.ts +368 -0
- package/microservices/microservice-travel/package.json +27 -0
- package/microservices/microservice-travel/src/cli/index.ts +505 -0
- package/microservices/microservice-travel/src/db/database.ts +93 -0
- package/microservices/microservice-travel/src/db/migrations.ts +77 -0
- package/microservices/microservice-travel/src/db/travel.ts +802 -0
- package/microservices/microservice-travel/src/index.ts +60 -0
- package/microservices/microservice-travel/src/mcp/index.ts +495 -0
- package/microservices/microservice-wiki/package.json +27 -0
- package/microservices/microservice-wiki/src/cli/index.ts +345 -0
- package/microservices/microservice-wiki/src/db/database.ts +93 -0
- package/microservices/microservice-wiki/src/db/migrations.ts +55 -0
- package/microservices/microservice-wiki/src/db/wiki.ts +395 -0
- package/microservices/microservice-wiki/src/index.ts +32 -0
- package/microservices/microservice-wiki/src/mcp/index.ts +344 -0
- package/package.json +1 -1
|
@@ -0,0 +1,313 @@
|
|
|
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
|
+
createHabit,
|
|
8
|
+
getHabit,
|
|
9
|
+
listHabits,
|
|
10
|
+
updateHabit,
|
|
11
|
+
deleteHabit,
|
|
12
|
+
activateHabit,
|
|
13
|
+
deactivateHabit,
|
|
14
|
+
completeHabit,
|
|
15
|
+
getStreak,
|
|
16
|
+
getAllStreaks,
|
|
17
|
+
getCompletionRate,
|
|
18
|
+
getCompletions,
|
|
19
|
+
getTodayStatus,
|
|
20
|
+
getWeeklyReport,
|
|
21
|
+
countHabits,
|
|
22
|
+
} from "../db/habits.js";
|
|
23
|
+
|
|
24
|
+
const server = new McpServer({
|
|
25
|
+
name: "microservice-habits",
|
|
26
|
+
version: "0.0.1",
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// --- Habits CRUD ---
|
|
30
|
+
|
|
31
|
+
server.registerTool(
|
|
32
|
+
"create_habit",
|
|
33
|
+
{
|
|
34
|
+
title: "Create Habit",
|
|
35
|
+
description: "Create a new habit to track.",
|
|
36
|
+
inputSchema: {
|
|
37
|
+
name: z.string(),
|
|
38
|
+
description: z.string().optional(),
|
|
39
|
+
frequency: z.enum(["daily", "weekly", "monthly"]).optional(),
|
|
40
|
+
target_count: z.number().optional(),
|
|
41
|
+
category: z.string().optional(),
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
async (params) => {
|
|
45
|
+
const habit = createHabit(params);
|
|
46
|
+
return { content: [{ type: "text", text: JSON.stringify(habit, null, 2) }] };
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
server.registerTool(
|
|
51
|
+
"get_habit",
|
|
52
|
+
{
|
|
53
|
+
title: "Get Habit",
|
|
54
|
+
description: "Get a habit by ID.",
|
|
55
|
+
inputSchema: { id: z.string() },
|
|
56
|
+
},
|
|
57
|
+
async ({ id }) => {
|
|
58
|
+
const habit = getHabit(id);
|
|
59
|
+
if (!habit) {
|
|
60
|
+
return { content: [{ type: "text", text: `Habit '${id}' not found.` }], isError: true };
|
|
61
|
+
}
|
|
62
|
+
return { content: [{ type: "text", text: JSON.stringify(habit, null, 2) }] };
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
server.registerTool(
|
|
67
|
+
"list_habits",
|
|
68
|
+
{
|
|
69
|
+
title: "List Habits",
|
|
70
|
+
description: "List habits with optional filters.",
|
|
71
|
+
inputSchema: {
|
|
72
|
+
category: z.string().optional(),
|
|
73
|
+
active: z.boolean().optional(),
|
|
74
|
+
frequency: z.enum(["daily", "weekly", "monthly"]).optional(),
|
|
75
|
+
limit: z.number().optional(),
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
async (params) => {
|
|
79
|
+
const habits = listHabits(params);
|
|
80
|
+
return {
|
|
81
|
+
content: [
|
|
82
|
+
{
|
|
83
|
+
type: "text",
|
|
84
|
+
text: JSON.stringify({ habits, count: habits.length }, null, 2),
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
server.registerTool(
|
|
92
|
+
"update_habit",
|
|
93
|
+
{
|
|
94
|
+
title: "Update Habit",
|
|
95
|
+
description: "Update an existing habit.",
|
|
96
|
+
inputSchema: {
|
|
97
|
+
id: z.string(),
|
|
98
|
+
name: z.string().optional(),
|
|
99
|
+
description: z.string().optional(),
|
|
100
|
+
frequency: z.enum(["daily", "weekly", "monthly"]).optional(),
|
|
101
|
+
target_count: z.number().optional(),
|
|
102
|
+
category: z.string().optional(),
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
async ({ id, ...input }) => {
|
|
106
|
+
const habit = updateHabit(id, input);
|
|
107
|
+
if (!habit) {
|
|
108
|
+
return { content: [{ type: "text", text: `Habit '${id}' not found.` }], isError: true };
|
|
109
|
+
}
|
|
110
|
+
return { content: [{ type: "text", text: JSON.stringify(habit, null, 2) }] };
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
server.registerTool(
|
|
115
|
+
"delete_habit",
|
|
116
|
+
{
|
|
117
|
+
title: "Delete Habit",
|
|
118
|
+
description: "Delete a habit by ID.",
|
|
119
|
+
inputSchema: { id: z.string() },
|
|
120
|
+
},
|
|
121
|
+
async ({ id }) => {
|
|
122
|
+
const deleted = deleteHabit(id);
|
|
123
|
+
return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
server.registerTool(
|
|
128
|
+
"activate_habit",
|
|
129
|
+
{
|
|
130
|
+
title: "Activate Habit",
|
|
131
|
+
description: "Activate a deactivated habit.",
|
|
132
|
+
inputSchema: { id: z.string() },
|
|
133
|
+
},
|
|
134
|
+
async ({ id }) => {
|
|
135
|
+
const habit = activateHabit(id);
|
|
136
|
+
if (!habit) {
|
|
137
|
+
return { content: [{ type: "text", text: `Habit '${id}' not found.` }], isError: true };
|
|
138
|
+
}
|
|
139
|
+
return { content: [{ type: "text", text: JSON.stringify(habit, null, 2) }] };
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
server.registerTool(
|
|
144
|
+
"deactivate_habit",
|
|
145
|
+
{
|
|
146
|
+
title: "Deactivate Habit",
|
|
147
|
+
description: "Deactivate a habit without deleting it.",
|
|
148
|
+
inputSchema: { id: z.string() },
|
|
149
|
+
},
|
|
150
|
+
async ({ id }) => {
|
|
151
|
+
const habit = deactivateHabit(id);
|
|
152
|
+
if (!habit) {
|
|
153
|
+
return { content: [{ type: "text", text: `Habit '${id}' not found.` }], isError: true };
|
|
154
|
+
}
|
|
155
|
+
return { content: [{ type: "text", text: JSON.stringify(habit, null, 2) }] };
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
// --- Completions ---
|
|
160
|
+
|
|
161
|
+
server.registerTool(
|
|
162
|
+
"complete_habit",
|
|
163
|
+
{
|
|
164
|
+
title: "Complete Habit",
|
|
165
|
+
description: "Record a habit completion. Auto-updates streak.",
|
|
166
|
+
inputSchema: {
|
|
167
|
+
id: z.string(),
|
|
168
|
+
notes: z.string().optional(),
|
|
169
|
+
value: z.number().optional(),
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
async ({ id, notes, value }) => {
|
|
173
|
+
const completion = completeHabit(id, notes, value);
|
|
174
|
+
if (!completion) {
|
|
175
|
+
return { content: [{ type: "text", text: `Habit '${id}' not found.` }], isError: true };
|
|
176
|
+
}
|
|
177
|
+
return { content: [{ type: "text", text: JSON.stringify(completion, null, 2) }] };
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
server.registerTool(
|
|
182
|
+
"get_completions",
|
|
183
|
+
{
|
|
184
|
+
title: "Get Completions",
|
|
185
|
+
description: "Get completion history for a habit.",
|
|
186
|
+
inputSchema: {
|
|
187
|
+
habit_id: z.string(),
|
|
188
|
+
limit: z.number().optional(),
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
async ({ habit_id, limit }) => {
|
|
192
|
+
const completions = getCompletions(habit_id, limit);
|
|
193
|
+
return {
|
|
194
|
+
content: [
|
|
195
|
+
{ type: "text", text: JSON.stringify({ completions, count: completions.length }, null, 2) },
|
|
196
|
+
],
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
// --- Streaks ---
|
|
202
|
+
|
|
203
|
+
server.registerTool(
|
|
204
|
+
"get_streak",
|
|
205
|
+
{
|
|
206
|
+
title: "Get Streak",
|
|
207
|
+
description: "Get streak information for a habit.",
|
|
208
|
+
inputSchema: { habit_id: z.string() },
|
|
209
|
+
},
|
|
210
|
+
async ({ habit_id }) => {
|
|
211
|
+
const streak = getStreak(habit_id);
|
|
212
|
+
if (!streak) {
|
|
213
|
+
return { content: [{ type: "text", text: `No streak data for habit '${habit_id}'.` }], isError: true };
|
|
214
|
+
}
|
|
215
|
+
return { content: [{ type: "text", text: JSON.stringify(streak, null, 2) }] };
|
|
216
|
+
}
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
server.registerTool(
|
|
220
|
+
"get_all_streaks",
|
|
221
|
+
{
|
|
222
|
+
title: "Get All Streaks",
|
|
223
|
+
description: "Get streaks for all active habits.",
|
|
224
|
+
inputSchema: {},
|
|
225
|
+
},
|
|
226
|
+
async () => {
|
|
227
|
+
const streaks = getAllStreaks();
|
|
228
|
+
return {
|
|
229
|
+
content: [
|
|
230
|
+
{ type: "text", text: JSON.stringify({ streaks, count: streaks.length }, null, 2) },
|
|
231
|
+
],
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
// --- Analytics ---
|
|
237
|
+
|
|
238
|
+
server.registerTool(
|
|
239
|
+
"get_completion_rate",
|
|
240
|
+
{
|
|
241
|
+
title: "Get Completion Rate",
|
|
242
|
+
description: "Get completion rate percentage for a habit over N days.",
|
|
243
|
+
inputSchema: {
|
|
244
|
+
habit_id: z.string(),
|
|
245
|
+
days: z.number().default(30),
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
async ({ habit_id, days }) => {
|
|
249
|
+
const rate = getCompletionRate(habit_id, days);
|
|
250
|
+
return {
|
|
251
|
+
content: [{ type: "text", text: JSON.stringify({ habit_id, days, rate }) }],
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
server.registerTool(
|
|
257
|
+
"get_today_status",
|
|
258
|
+
{
|
|
259
|
+
title: "Get Today Status",
|
|
260
|
+
description: "Get today's completion status for all active habits.",
|
|
261
|
+
inputSchema: {},
|
|
262
|
+
},
|
|
263
|
+
async () => {
|
|
264
|
+
const status = getTodayStatus();
|
|
265
|
+
return {
|
|
266
|
+
content: [
|
|
267
|
+
{ type: "text", text: JSON.stringify({ status, count: status.length }, null, 2) },
|
|
268
|
+
],
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
server.registerTool(
|
|
274
|
+
"get_weekly_report",
|
|
275
|
+
{
|
|
276
|
+
title: "Get Weekly Report",
|
|
277
|
+
description: "Get weekly completion report for all active habits.",
|
|
278
|
+
inputSchema: {},
|
|
279
|
+
},
|
|
280
|
+
async () => {
|
|
281
|
+
const report = getWeeklyReport();
|
|
282
|
+
return {
|
|
283
|
+
content: [
|
|
284
|
+
{ type: "text", text: JSON.stringify({ report, count: report.length }, null, 2) },
|
|
285
|
+
],
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
server.registerTool(
|
|
291
|
+
"count_habits",
|
|
292
|
+
{
|
|
293
|
+
title: "Count Habits",
|
|
294
|
+
description: "Get total number of habits.",
|
|
295
|
+
inputSchema: {},
|
|
296
|
+
},
|
|
297
|
+
async () => {
|
|
298
|
+
const count = countHabits();
|
|
299
|
+
return { content: [{ type: "text", text: JSON.stringify({ count }) }] };
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
// --- Start ---
|
|
304
|
+
async function main() {
|
|
305
|
+
const transport = new StdioServerTransport();
|
|
306
|
+
await server.connect(transport);
|
|
307
|
+
console.error("microservice-habits MCP server running on stdio");
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
main().catch((error) => {
|
|
311
|
+
console.error("Fatal error:", error);
|
|
312
|
+
process.exit(1);
|
|
313
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hasna/microservice-health",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Health tracking microservice with SQLite — manage metrics, medications, appointments, and fitness logs",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"microservice-health": "./src/cli/index.ts",
|
|
8
|
+
"microservice-health-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
|
+
}
|