@hasna/microservices 0.0.3 → 0.0.5

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 (68) 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 +605 -0
  6. package/microservices/microservice-ads/src/db/campaigns.ts +797 -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 +480 -0
  11. package/microservices/microservice-contracts/package.json +27 -0
  12. package/microservices/microservice-contracts/src/cli/index.ts +770 -0
  13. package/microservices/microservice-contracts/src/db/contracts.ts +925 -0
  14. package/microservices/microservice-contracts/src/db/database.ts +93 -0
  15. package/microservices/microservice-contracts/src/db/migrations.ts +141 -0
  16. package/microservices/microservice-contracts/src/index.ts +43 -0
  17. package/microservices/microservice-contracts/src/mcp/index.ts +617 -0
  18. package/microservices/microservice-domains/package.json +27 -0
  19. package/microservices/microservice-domains/src/cli/index.ts +691 -0
  20. package/microservices/microservice-domains/src/db/database.ts +93 -0
  21. package/microservices/microservice-domains/src/db/domains.ts +1164 -0
  22. package/microservices/microservice-domains/src/db/migrations.ts +60 -0
  23. package/microservices/microservice-domains/src/index.ts +65 -0
  24. package/microservices/microservice-domains/src/mcp/index.ts +536 -0
  25. package/microservices/microservice-hiring/package.json +27 -0
  26. package/microservices/microservice-hiring/src/cli/index.ts +741 -0
  27. package/microservices/microservice-hiring/src/db/database.ts +93 -0
  28. package/microservices/microservice-hiring/src/db/hiring.ts +1085 -0
  29. package/microservices/microservice-hiring/src/db/migrations.ts +89 -0
  30. package/microservices/microservice-hiring/src/index.ts +80 -0
  31. package/microservices/microservice-hiring/src/lib/scoring.ts +206 -0
  32. package/microservices/microservice-hiring/src/mcp/index.ts +709 -0
  33. package/microservices/microservice-payments/package.json +27 -0
  34. package/microservices/microservice-payments/src/cli/index.ts +609 -0
  35. package/microservices/microservice-payments/src/db/database.ts +93 -0
  36. package/microservices/microservice-payments/src/db/migrations.ts +81 -0
  37. package/microservices/microservice-payments/src/db/payments.ts +1204 -0
  38. package/microservices/microservice-payments/src/index.ts +51 -0
  39. package/microservices/microservice-payments/src/mcp/index.ts +683 -0
  40. package/microservices/microservice-payroll/package.json +27 -0
  41. package/microservices/microservice-payroll/src/cli/index.ts +643 -0
  42. package/microservices/microservice-payroll/src/db/database.ts +93 -0
  43. package/microservices/microservice-payroll/src/db/migrations.ts +95 -0
  44. package/microservices/microservice-payroll/src/db/payroll.ts +1377 -0
  45. package/microservices/microservice-payroll/src/index.ts +48 -0
  46. package/microservices/microservice-payroll/src/mcp/index.ts +666 -0
  47. package/microservices/microservice-shipping/package.json +27 -0
  48. package/microservices/microservice-shipping/src/cli/index.ts +606 -0
  49. package/microservices/microservice-shipping/src/db/database.ts +93 -0
  50. package/microservices/microservice-shipping/src/db/migrations.ts +69 -0
  51. package/microservices/microservice-shipping/src/db/shipping.ts +1093 -0
  52. package/microservices/microservice-shipping/src/index.ts +53 -0
  53. package/microservices/microservice-shipping/src/mcp/index.ts +533 -0
  54. package/microservices/microservice-social/package.json +27 -0
  55. package/microservices/microservice-social/src/cli/index.ts +689 -0
  56. package/microservices/microservice-social/src/db/database.ts +93 -0
  57. package/microservices/microservice-social/src/db/migrations.ts +88 -0
  58. package/microservices/microservice-social/src/db/social.ts +1046 -0
  59. package/microservices/microservice-social/src/index.ts +46 -0
  60. package/microservices/microservice-social/src/mcp/index.ts +655 -0
  61. package/microservices/microservice-subscriptions/package.json +27 -0
  62. package/microservices/microservice-subscriptions/src/cli/index.ts +715 -0
  63. package/microservices/microservice-subscriptions/src/db/database.ts +93 -0
  64. package/microservices/microservice-subscriptions/src/db/migrations.ts +125 -0
  65. package/microservices/microservice-subscriptions/src/db/subscriptions.ts +1256 -0
  66. package/microservices/microservice-subscriptions/src/index.ts +41 -0
  67. package/microservices/microservice-subscriptions/src/mcp/index.ts +631 -0
  68. package/package.json +1 -1
@@ -0,0 +1,709 @@
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
+ createJob,
8
+ getJob,
9
+ listJobs,
10
+ updateJob,
11
+ closeJob,
12
+ deleteJob,
13
+ createApplicant,
14
+ getApplicant,
15
+ listApplicants,
16
+ updateApplicant,
17
+ advanceApplicant,
18
+ rejectApplicant,
19
+ searchApplicants,
20
+ listByStage,
21
+ getPipeline,
22
+ getHiringStats,
23
+ createInterview,
24
+ getInterview,
25
+ listInterviews,
26
+ updateInterview,
27
+ addInterviewFeedback,
28
+ deleteInterview,
29
+ bulkImportApplicants,
30
+ generateOffer,
31
+ getHiringForecast,
32
+ submitStructuredFeedback,
33
+ bulkReject,
34
+ getReferralStats,
35
+ saveJobAsTemplate,
36
+ createJobFromTemplate,
37
+ listJobTemplates,
38
+ deleteJobTemplate,
39
+ } from "../db/hiring.js";
40
+ import { scoreApplicant, rankApplicants } from "../lib/scoring.js";
41
+
42
+ const server = new McpServer({
43
+ name: "microservice-hiring",
44
+ version: "0.0.1",
45
+ });
46
+
47
+ // --- Jobs ---
48
+
49
+ server.registerTool(
50
+ "create_job",
51
+ {
52
+ title: "Create Job",
53
+ description: "Create a new job posting.",
54
+ inputSchema: {
55
+ title: z.string(),
56
+ department: z.string().optional(),
57
+ location: z.string().optional(),
58
+ type: z.enum(["full-time", "part-time", "contract"]).optional(),
59
+ description: z.string().optional(),
60
+ requirements: z.array(z.string()).optional(),
61
+ salary_range: z.string().optional(),
62
+ posted_at: z.string().optional(),
63
+ },
64
+ },
65
+ async (params) => {
66
+ const job = createJob(params);
67
+ return { content: [{ type: "text", text: JSON.stringify(job, null, 2) }] };
68
+ }
69
+ );
70
+
71
+ server.registerTool(
72
+ "get_job",
73
+ {
74
+ title: "Get Job",
75
+ description: "Get a job posting by ID.",
76
+ inputSchema: { id: z.string() },
77
+ },
78
+ async ({ id }) => {
79
+ const job = getJob(id);
80
+ if (!job) {
81
+ return { content: [{ type: "text", text: `Job '${id}' not found.` }], isError: true };
82
+ }
83
+ return { content: [{ type: "text", text: JSON.stringify(job, null, 2) }] };
84
+ }
85
+ );
86
+
87
+ server.registerTool(
88
+ "list_jobs",
89
+ {
90
+ title: "List Jobs",
91
+ description: "List job postings with optional filters.",
92
+ inputSchema: {
93
+ status: z.enum(["open", "closed", "paused"]).optional(),
94
+ department: z.string().optional(),
95
+ type: z.enum(["full-time", "part-time", "contract"]).optional(),
96
+ limit: z.number().optional(),
97
+ },
98
+ },
99
+ async (params) => {
100
+ const jobs = listJobs(params);
101
+ return {
102
+ content: [{ type: "text", text: JSON.stringify({ jobs, count: jobs.length }, null, 2) }],
103
+ };
104
+ }
105
+ );
106
+
107
+ server.registerTool(
108
+ "update_job",
109
+ {
110
+ title: "Update Job",
111
+ description: "Update a job posting.",
112
+ inputSchema: {
113
+ id: z.string(),
114
+ title: z.string().optional(),
115
+ department: z.string().optional(),
116
+ location: z.string().optional(),
117
+ type: z.enum(["full-time", "part-time", "contract"]).optional(),
118
+ status: z.enum(["open", "closed", "paused"]).optional(),
119
+ description: z.string().optional(),
120
+ requirements: z.array(z.string()).optional(),
121
+ salary_range: z.string().optional(),
122
+ },
123
+ },
124
+ async ({ id, ...input }) => {
125
+ const job = updateJob(id, input);
126
+ if (!job) {
127
+ return { content: [{ type: "text", text: `Job '${id}' not found.` }], isError: true };
128
+ }
129
+ return { content: [{ type: "text", text: JSON.stringify(job, null, 2) }] };
130
+ }
131
+ );
132
+
133
+ server.registerTool(
134
+ "close_job",
135
+ {
136
+ title: "Close Job",
137
+ description: "Close a job posting.",
138
+ inputSchema: { id: z.string() },
139
+ },
140
+ async ({ id }) => {
141
+ const job = closeJob(id);
142
+ if (!job) {
143
+ return { content: [{ type: "text", text: `Job '${id}' not found.` }], isError: true };
144
+ }
145
+ return { content: [{ type: "text", text: JSON.stringify(job, null, 2) }] };
146
+ }
147
+ );
148
+
149
+ server.registerTool(
150
+ "delete_job",
151
+ {
152
+ title: "Delete Job",
153
+ description: "Delete a job posting by ID.",
154
+ inputSchema: { id: z.string() },
155
+ },
156
+ async ({ id }) => {
157
+ const deleted = deleteJob(id);
158
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
159
+ }
160
+ );
161
+
162
+ // --- Applicants ---
163
+
164
+ server.registerTool(
165
+ "add_applicant",
166
+ {
167
+ title: "Add Applicant",
168
+ description: "Add a new applicant to a job.",
169
+ inputSchema: {
170
+ job_id: z.string(),
171
+ name: z.string(),
172
+ email: z.string().optional(),
173
+ phone: z.string().optional(),
174
+ resume_url: z.string().optional(),
175
+ source: z.string().optional(),
176
+ notes: z.string().optional(),
177
+ },
178
+ },
179
+ async (params) => {
180
+ const applicant = createApplicant(params);
181
+ return { content: [{ type: "text", text: JSON.stringify(applicant, null, 2) }] };
182
+ }
183
+ );
184
+
185
+ server.registerTool(
186
+ "get_applicant",
187
+ {
188
+ title: "Get Applicant",
189
+ description: "Get an applicant by ID.",
190
+ inputSchema: { id: z.string() },
191
+ },
192
+ async ({ id }) => {
193
+ const applicant = getApplicant(id);
194
+ if (!applicant) {
195
+ return { content: [{ type: "text", text: `Applicant '${id}' not found.` }], isError: true };
196
+ }
197
+ return { content: [{ type: "text", text: JSON.stringify(applicant, null, 2) }] };
198
+ }
199
+ );
200
+
201
+ server.registerTool(
202
+ "list_applicants",
203
+ {
204
+ title: "List Applicants",
205
+ description: "List applicants with optional filters.",
206
+ inputSchema: {
207
+ job_id: z.string().optional(),
208
+ status: z.enum(["applied", "screening", "interviewing", "offered", "hired", "rejected"]).optional(),
209
+ source: z.string().optional(),
210
+ limit: z.number().optional(),
211
+ },
212
+ },
213
+ async (params) => {
214
+ const applicants = listApplicants(params);
215
+ return {
216
+ content: [
217
+ { type: "text", text: JSON.stringify({ applicants, count: applicants.length }, null, 2) },
218
+ ],
219
+ };
220
+ }
221
+ );
222
+
223
+ server.registerTool(
224
+ "update_applicant",
225
+ {
226
+ title: "Update Applicant",
227
+ description: "Update an applicant.",
228
+ inputSchema: {
229
+ id: z.string(),
230
+ name: z.string().optional(),
231
+ email: z.string().optional(),
232
+ phone: z.string().optional(),
233
+ resume_url: z.string().optional(),
234
+ status: z.enum(["applied", "screening", "interviewing", "offered", "hired", "rejected"]).optional(),
235
+ stage: z.string().optional(),
236
+ rating: z.number().optional(),
237
+ notes: z.string().optional(),
238
+ source: z.string().optional(),
239
+ },
240
+ },
241
+ async ({ id, ...input }) => {
242
+ const applicant = updateApplicant(id, input);
243
+ if (!applicant) {
244
+ return { content: [{ type: "text", text: `Applicant '${id}' not found.` }], isError: true };
245
+ }
246
+ return { content: [{ type: "text", text: JSON.stringify(applicant, null, 2) }] };
247
+ }
248
+ );
249
+
250
+ server.registerTool(
251
+ "advance_applicant",
252
+ {
253
+ title: "Advance Applicant",
254
+ description: "Advance an applicant to a new status in the hiring pipeline.",
255
+ inputSchema: {
256
+ id: z.string(),
257
+ status: z.enum(["screening", "interviewing", "offered", "hired"]),
258
+ },
259
+ },
260
+ async ({ id, status }) => {
261
+ const applicant = advanceApplicant(id, status);
262
+ if (!applicant) {
263
+ return { content: [{ type: "text", text: `Applicant '${id}' not found.` }], isError: true };
264
+ }
265
+ return { content: [{ type: "text", text: JSON.stringify(applicant, null, 2) }] };
266
+ }
267
+ );
268
+
269
+ server.registerTool(
270
+ "reject_applicant",
271
+ {
272
+ title: "Reject Applicant",
273
+ description: "Reject an applicant with an optional reason.",
274
+ inputSchema: {
275
+ id: z.string(),
276
+ reason: z.string().optional(),
277
+ },
278
+ },
279
+ async ({ id, reason }) => {
280
+ const applicant = rejectApplicant(id, reason);
281
+ if (!applicant) {
282
+ return { content: [{ type: "text", text: `Applicant '${id}' not found.` }], isError: true };
283
+ }
284
+ return { content: [{ type: "text", text: JSON.stringify(applicant, null, 2) }] };
285
+ }
286
+ );
287
+
288
+ server.registerTool(
289
+ "search_applicants",
290
+ {
291
+ title: "Search Applicants",
292
+ description: "Search applicants by name, email, notes, or source.",
293
+ inputSchema: { query: z.string() },
294
+ },
295
+ async ({ query }) => {
296
+ const results = searchApplicants(query);
297
+ return {
298
+ content: [
299
+ { type: "text", text: JSON.stringify({ results, count: results.length }, null, 2) },
300
+ ],
301
+ };
302
+ }
303
+ );
304
+
305
+ server.registerTool(
306
+ "list_by_stage",
307
+ {
308
+ title: "List by Stage",
309
+ description: "List applicants by stage.",
310
+ inputSchema: { stage: z.string() },
311
+ },
312
+ async ({ stage }) => {
313
+ const applicants = listByStage(stage);
314
+ return {
315
+ content: [
316
+ { type: "text", text: JSON.stringify({ applicants, count: applicants.length }, null, 2) },
317
+ ],
318
+ };
319
+ }
320
+ );
321
+
322
+ server.registerTool(
323
+ "get_pipeline",
324
+ {
325
+ title: "Get Pipeline",
326
+ description: "Get the hiring pipeline (applicant count by status) for a job.",
327
+ inputSchema: { job_id: z.string() },
328
+ },
329
+ async ({ job_id }) => {
330
+ const pipeline = getPipeline(job_id);
331
+ return { content: [{ type: "text", text: JSON.stringify(pipeline, null, 2) }] };
332
+ }
333
+ );
334
+
335
+ server.registerTool(
336
+ "get_hiring_stats",
337
+ {
338
+ title: "Get Hiring Stats",
339
+ description: "Get overall hiring statistics.",
340
+ inputSchema: {},
341
+ },
342
+ async () => {
343
+ const stats = getHiringStats();
344
+ return { content: [{ type: "text", text: JSON.stringify(stats, null, 2) }] };
345
+ }
346
+ );
347
+
348
+ // --- Interviews ---
349
+
350
+ server.registerTool(
351
+ "schedule_interview",
352
+ {
353
+ title: "Schedule Interview",
354
+ description: "Schedule an interview for an applicant.",
355
+ inputSchema: {
356
+ applicant_id: z.string(),
357
+ interviewer: z.string().optional(),
358
+ scheduled_at: z.string().optional(),
359
+ duration_min: z.number().optional(),
360
+ type: z.enum(["phone", "video", "onsite"]).optional(),
361
+ },
362
+ },
363
+ async (params) => {
364
+ const interview = createInterview(params);
365
+ return { content: [{ type: "text", text: JSON.stringify(interview, null, 2) }] };
366
+ }
367
+ );
368
+
369
+ server.registerTool(
370
+ "get_interview",
371
+ {
372
+ title: "Get Interview",
373
+ description: "Get an interview by ID.",
374
+ inputSchema: { id: z.string() },
375
+ },
376
+ async ({ id }) => {
377
+ const interview = getInterview(id);
378
+ if (!interview) {
379
+ return { content: [{ type: "text", text: `Interview '${id}' not found.` }], isError: true };
380
+ }
381
+ return { content: [{ type: "text", text: JSON.stringify(interview, null, 2) }] };
382
+ }
383
+ );
384
+
385
+ server.registerTool(
386
+ "list_interviews",
387
+ {
388
+ title: "List Interviews",
389
+ description: "List interviews with optional filters.",
390
+ inputSchema: {
391
+ applicant_id: z.string().optional(),
392
+ status: z.enum(["scheduled", "completed", "canceled"]).optional(),
393
+ type: z.enum(["phone", "video", "onsite"]).optional(),
394
+ limit: z.number().optional(),
395
+ },
396
+ },
397
+ async (params) => {
398
+ const interviews = listInterviews(params);
399
+ return {
400
+ content: [
401
+ { type: "text", text: JSON.stringify({ interviews, count: interviews.length }, null, 2) },
402
+ ],
403
+ };
404
+ }
405
+ );
406
+
407
+ server.registerTool(
408
+ "update_interview",
409
+ {
410
+ title: "Update Interview",
411
+ description: "Update an interview.",
412
+ inputSchema: {
413
+ id: z.string(),
414
+ interviewer: z.string().optional(),
415
+ scheduled_at: z.string().optional(),
416
+ duration_min: z.number().optional(),
417
+ type: z.enum(["phone", "video", "onsite"]).optional(),
418
+ status: z.enum(["scheduled", "completed", "canceled"]).optional(),
419
+ feedback: z.string().optional(),
420
+ rating: z.number().optional(),
421
+ },
422
+ },
423
+ async ({ id, ...input }) => {
424
+ const interview = updateInterview(id, input);
425
+ if (!interview) {
426
+ return { content: [{ type: "text", text: `Interview '${id}' not found.` }], isError: true };
427
+ }
428
+ return { content: [{ type: "text", text: JSON.stringify(interview, null, 2) }] };
429
+ }
430
+ );
431
+
432
+ server.registerTool(
433
+ "add_interview_feedback",
434
+ {
435
+ title: "Add Interview Feedback",
436
+ description: "Add feedback and optional rating to an interview.",
437
+ inputSchema: {
438
+ id: z.string(),
439
+ feedback: z.string(),
440
+ rating: z.number().optional(),
441
+ },
442
+ },
443
+ async ({ id, feedback, rating }) => {
444
+ const interview = addInterviewFeedback(id, feedback, rating);
445
+ if (!interview) {
446
+ return { content: [{ type: "text", text: `Interview '${id}' not found.` }], isError: true };
447
+ }
448
+ return { content: [{ type: "text", text: JSON.stringify(interview, null, 2) }] };
449
+ }
450
+ );
451
+
452
+ server.registerTool(
453
+ "delete_interview",
454
+ {
455
+ title: "Delete Interview",
456
+ description: "Delete an interview by ID.",
457
+ inputSchema: { id: z.string() },
458
+ },
459
+ async ({ id }) => {
460
+ const deleted = deleteInterview(id);
461
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
462
+ }
463
+ );
464
+
465
+ // --- Bulk Import ---
466
+
467
+ server.registerTool(
468
+ "bulk_import_applicants",
469
+ {
470
+ title: "Bulk Import Applicants",
471
+ description: "Import applicants from CSV data (columns: name,email,phone,job_id,source,resume_url).",
472
+ inputSchema: {
473
+ csv_data: z.string().describe("CSV string with header row"),
474
+ },
475
+ },
476
+ async ({ csv_data }) => {
477
+ const result = bulkImportApplicants(csv_data);
478
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
479
+ }
480
+ );
481
+
482
+ // --- AI Scoring ---
483
+
484
+ server.registerTool(
485
+ "score_applicant",
486
+ {
487
+ title: "Score Applicant",
488
+ description: "AI-score an applicant against job requirements. Returns match percentage, strengths, gaps, and recommendation.",
489
+ inputSchema: { id: z.string() },
490
+ },
491
+ async ({ id }) => {
492
+ try {
493
+ const score = await scoreApplicant(id);
494
+ return { content: [{ type: "text", text: JSON.stringify(score, null, 2) }] };
495
+ } catch (err) {
496
+ return { content: [{ type: "text", text: String(err instanceof Error ? err.message : err) }], isError: true };
497
+ }
498
+ }
499
+ );
500
+
501
+ server.registerTool(
502
+ "rank_applicants",
503
+ {
504
+ title: "Rank Applicants",
505
+ description: "AI-rank all applicants for a job by fit score, sorted best-first.",
506
+ inputSchema: { job_id: z.string() },
507
+ },
508
+ async ({ job_id }) => {
509
+ try {
510
+ const ranked = await rankApplicants(job_id);
511
+ return { content: [{ type: "text", text: JSON.stringify(ranked, null, 2) }] };
512
+ } catch (err) {
513
+ return { content: [{ type: "text", text: String(err instanceof Error ? err.message : err) }], isError: true };
514
+ }
515
+ }
516
+ );
517
+
518
+ // --- Offer Letter ---
519
+
520
+ server.registerTool(
521
+ "generate_offer",
522
+ {
523
+ title: "Generate Offer Letter",
524
+ description: "Generate a Markdown offer letter for an applicant.",
525
+ inputSchema: {
526
+ id: z.string().describe("Applicant ID"),
527
+ salary: z.number().describe("Annual salary"),
528
+ start_date: z.string().describe("Start date (YYYY-MM-DD)"),
529
+ position_title: z.string().optional(),
530
+ department: z.string().optional(),
531
+ benefits: z.string().optional(),
532
+ equity: z.string().optional(),
533
+ signing_bonus: z.number().optional(),
534
+ },
535
+ },
536
+ async ({ id, salary, start_date, ...rest }) => {
537
+ try {
538
+ const letter = generateOffer(id, { salary, start_date, ...rest });
539
+ return { content: [{ type: "text", text: letter }] };
540
+ } catch (err) {
541
+ return { content: [{ type: "text", text: String(err instanceof Error ? err.message : err) }], isError: true };
542
+ }
543
+ }
544
+ );
545
+
546
+ // --- Pipeline Velocity / Forecast ---
547
+
548
+ server.registerTool(
549
+ "hiring_forecast",
550
+ {
551
+ title: "Hiring Forecast",
552
+ description: "Estimate days-to-fill based on average time between pipeline stages.",
553
+ inputSchema: { job_id: z.string() },
554
+ },
555
+ async ({ job_id }) => {
556
+ try {
557
+ const forecast = getHiringForecast(job_id);
558
+ return { content: [{ type: "text", text: JSON.stringify(forecast, null, 2) }] };
559
+ } catch (err) {
560
+ return { content: [{ type: "text", text: String(err instanceof Error ? err.message : err) }], isError: true };
561
+ }
562
+ }
563
+ );
564
+
565
+ // --- Structured Feedback ---
566
+
567
+ server.registerTool(
568
+ "submit_structured_feedback",
569
+ {
570
+ title: "Submit Structured Interview Feedback",
571
+ description: "Submit scored interview feedback with dimensions (technical, communication, culture_fit, etc.).",
572
+ inputSchema: {
573
+ id: z.string().describe("Interview ID"),
574
+ feedback_text: z.string().optional(),
575
+ technical: z.number().min(1).max(5).optional(),
576
+ communication: z.number().min(1).max(5).optional(),
577
+ culture_fit: z.number().min(1).max(5).optional(),
578
+ problem_solving: z.number().min(1).max(5).optional(),
579
+ leadership: z.number().min(1).max(5).optional(),
580
+ overall: z.number().min(1).max(5).optional(),
581
+ },
582
+ },
583
+ async ({ id, feedback_text, ...scores }) => {
584
+ const interview = submitStructuredFeedback(id, scores, feedback_text);
585
+ if (!interview) {
586
+ return { content: [{ type: "text", text: `Interview '${id}' not found.` }], isError: true };
587
+ }
588
+ return { content: [{ type: "text", text: JSON.stringify(interview, null, 2) }] };
589
+ }
590
+ );
591
+
592
+ // --- Bulk Rejection ---
593
+
594
+ server.registerTool(
595
+ "bulk_reject",
596
+ {
597
+ title: "Bulk Reject Applicants",
598
+ description: "Bulk reject all applicants for a job matching a specific status.",
599
+ inputSchema: {
600
+ job_id: z.string(),
601
+ status: z.enum(["applied", "screening", "interviewing", "offered"]),
602
+ reason: z.string().optional(),
603
+ },
604
+ },
605
+ async ({ job_id, status, reason }) => {
606
+ const result = bulkReject(job_id, status, reason);
607
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
608
+ }
609
+ );
610
+
611
+ // --- Referral Stats ---
612
+
613
+ server.registerTool(
614
+ "referral_stats",
615
+ {
616
+ title: "Referral Stats",
617
+ description: "Show conversion rates by applicant source/referral channel.",
618
+ inputSchema: {},
619
+ },
620
+ async () => {
621
+ const stats = getReferralStats();
622
+ return { content: [{ type: "text", text: JSON.stringify(stats, null, 2) }] };
623
+ }
624
+ );
625
+
626
+ // --- Job Templates ---
627
+
628
+ server.registerTool(
629
+ "save_job_template",
630
+ {
631
+ title: "Save Job as Template",
632
+ description: "Save an existing job posting as a reusable template.",
633
+ inputSchema: {
634
+ job_id: z.string(),
635
+ name: z.string().describe("Unique template name"),
636
+ },
637
+ },
638
+ async ({ job_id, name }) => {
639
+ try {
640
+ const template = saveJobAsTemplate(job_id, name);
641
+ return { content: [{ type: "text", text: JSON.stringify(template, null, 2) }] };
642
+ } catch (err) {
643
+ return { content: [{ type: "text", text: String(err instanceof Error ? err.message : err) }], isError: true };
644
+ }
645
+ }
646
+ );
647
+
648
+ server.registerTool(
649
+ "create_job_from_template",
650
+ {
651
+ title: "Create Job from Template",
652
+ description: "Create a new job posting from an existing template.",
653
+ inputSchema: {
654
+ template_name: z.string(),
655
+ title: z.string().optional(),
656
+ department: z.string().optional(),
657
+ location: z.string().optional(),
658
+ salary_range: z.string().optional(),
659
+ },
660
+ },
661
+ async ({ template_name, ...overrides }) => {
662
+ try {
663
+ const job = createJobFromTemplate(template_name, overrides);
664
+ return { content: [{ type: "text", text: JSON.stringify(job, null, 2) }] };
665
+ } catch (err) {
666
+ return { content: [{ type: "text", text: String(err instanceof Error ? err.message : err) }], isError: true };
667
+ }
668
+ }
669
+ );
670
+
671
+ server.registerTool(
672
+ "list_job_templates",
673
+ {
674
+ title: "List Job Templates",
675
+ description: "List all saved job templates.",
676
+ inputSchema: {},
677
+ },
678
+ async () => {
679
+ const templates = listJobTemplates();
680
+ return {
681
+ content: [{ type: "text", text: JSON.stringify({ templates, count: templates.length }, null, 2) }],
682
+ };
683
+ }
684
+ );
685
+
686
+ server.registerTool(
687
+ "delete_job_template",
688
+ {
689
+ title: "Delete Job Template",
690
+ description: "Delete a job template by ID.",
691
+ inputSchema: { id: z.string() },
692
+ },
693
+ async ({ id }) => {
694
+ const deleted = deleteJobTemplate(id);
695
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
696
+ }
697
+ );
698
+
699
+ // --- Start ---
700
+ async function main() {
701
+ const transport = new StdioServerTransport();
702
+ await server.connect(transport);
703
+ console.error("microservice-hiring MCP server running on stdio");
704
+ }
705
+
706
+ main().catch((error) => {
707
+ console.error("Fatal error:", error);
708
+ process.exit(1);
709
+ });