@nekzus/mcp-server 1.0.36 ā 1.1.1
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/dist/index.js +532 -0
- package/package.json +9 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import 'dotenv/config';
|
|
6
|
+
// Logger function that uses stderr
|
|
7
|
+
const log = (...args) => console.error(...args);
|
|
8
|
+
// Define the tools once to avoid repetition
|
|
9
|
+
const TOOLS = [
|
|
10
|
+
{
|
|
11
|
+
name: 'greeting',
|
|
12
|
+
description: 'Generate a personalized greeting message for the specified person',
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
name: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
description: 'Name of the recipient for the greeting',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
required: ['name'],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'card',
|
|
26
|
+
description: 'Draw a random card from a standard 52-card poker deck',
|
|
27
|
+
inputSchema: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'datetime',
|
|
34
|
+
description: 'Get the current date and time for a specific timezone',
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: {
|
|
38
|
+
timeZone: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
description: 'Timezone identifier (e.g., "America/New_York")',
|
|
41
|
+
},
|
|
42
|
+
locale: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
description: 'Locale identifier (e.g., "en-US")',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'calculator',
|
|
51
|
+
description: 'Perform mathematical calculations with support for basic and advanced operations',
|
|
52
|
+
inputSchema: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
expression: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
description: 'Mathematical expression to evaluate (e.g., "2 + 2 * 3")',
|
|
58
|
+
},
|
|
59
|
+
precision: {
|
|
60
|
+
type: 'number',
|
|
61
|
+
description: 'Number of decimal places for the result (default: 2)',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
required: ['expression'],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'passwordGen',
|
|
69
|
+
description: 'Generate a secure password with customizable options',
|
|
70
|
+
inputSchema: {
|
|
71
|
+
type: 'object',
|
|
72
|
+
properties: {
|
|
73
|
+
length: {
|
|
74
|
+
type: 'number',
|
|
75
|
+
description: 'Length of the password (default: 16)',
|
|
76
|
+
},
|
|
77
|
+
includeNumbers: {
|
|
78
|
+
type: 'boolean',
|
|
79
|
+
description: 'Include numbers in the password (default: true)',
|
|
80
|
+
},
|
|
81
|
+
includeSymbols: {
|
|
82
|
+
type: 'boolean',
|
|
83
|
+
description: 'Include special symbols in the password (default: true)',
|
|
84
|
+
},
|
|
85
|
+
includeUppercase: {
|
|
86
|
+
type: 'boolean',
|
|
87
|
+
description: 'Include uppercase letters in the password (default: true)',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'qrGen',
|
|
94
|
+
description: 'Generate a QR code for the given text or URL',
|
|
95
|
+
inputSchema: {
|
|
96
|
+
type: 'object',
|
|
97
|
+
properties: {
|
|
98
|
+
text: {
|
|
99
|
+
type: 'string',
|
|
100
|
+
description: 'Text or URL to encode in the QR code',
|
|
101
|
+
},
|
|
102
|
+
size: {
|
|
103
|
+
type: 'number',
|
|
104
|
+
description: 'Size of the QR code in pixels (default: 200)',
|
|
105
|
+
},
|
|
106
|
+
dark: {
|
|
107
|
+
type: 'string',
|
|
108
|
+
description: 'Color for dark modules (default: "#000000")',
|
|
109
|
+
},
|
|
110
|
+
light: {
|
|
111
|
+
type: 'string',
|
|
112
|
+
description: 'Color for light modules (default: "#ffffff")',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
required: ['text'],
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: 'kitchenConvert',
|
|
120
|
+
description: 'Convert between common kitchen measurements and weights',
|
|
121
|
+
inputSchema: {
|
|
122
|
+
type: 'object',
|
|
123
|
+
properties: {
|
|
124
|
+
value: {
|
|
125
|
+
type: 'number',
|
|
126
|
+
description: 'Value to convert',
|
|
127
|
+
},
|
|
128
|
+
from: {
|
|
129
|
+
type: 'string',
|
|
130
|
+
description: 'Source unit (e.g., "cup", "tbsp", "g", "oz", "ml")',
|
|
131
|
+
},
|
|
132
|
+
to: {
|
|
133
|
+
type: 'string',
|
|
134
|
+
description: 'Target unit (e.g., "cup", "tbsp", "g", "oz", "ml")',
|
|
135
|
+
},
|
|
136
|
+
ingredient: {
|
|
137
|
+
type: 'string',
|
|
138
|
+
description: 'Optional ingredient for accurate volume-to-weight conversions',
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
required: ['value', 'from', 'to'],
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
];
|
|
145
|
+
// Tool handlers
|
|
146
|
+
async function handleGreeting(args) {
|
|
147
|
+
const { name } = args;
|
|
148
|
+
return {
|
|
149
|
+
content: [
|
|
150
|
+
{
|
|
151
|
+
type: 'text',
|
|
152
|
+
text: `š Hello ${name}! Welcome to the MCP server!`,
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
isError: false,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
async function handleCard() {
|
|
159
|
+
const suits = {
|
|
160
|
+
'ā ': 'Spades',
|
|
161
|
+
'ā„': 'Hearts',
|
|
162
|
+
'ā¦': 'Diamonds',
|
|
163
|
+
'ā£': 'Clubs',
|
|
164
|
+
};
|
|
165
|
+
const values = {
|
|
166
|
+
A: 'Ace',
|
|
167
|
+
'2': 'Two',
|
|
168
|
+
'3': 'Three',
|
|
169
|
+
'4': 'Four',
|
|
170
|
+
'5': 'Five',
|
|
171
|
+
'6': 'Six',
|
|
172
|
+
'7': 'Seven',
|
|
173
|
+
'8': 'Eight',
|
|
174
|
+
'9': 'Nine',
|
|
175
|
+
'10': 'Ten',
|
|
176
|
+
J: 'Jack',
|
|
177
|
+
Q: 'Queen',
|
|
178
|
+
K: 'King',
|
|
179
|
+
};
|
|
180
|
+
const suitSymbols = Object.keys(suits);
|
|
181
|
+
const valueSymbols = Object.keys(values);
|
|
182
|
+
const suitSymbol = suitSymbols[Math.floor(Math.random() * suitSymbols.length)];
|
|
183
|
+
const valueSymbol = valueSymbols[Math.floor(Math.random() * valueSymbols.length)];
|
|
184
|
+
return {
|
|
185
|
+
content: [
|
|
186
|
+
{
|
|
187
|
+
type: 'text',
|
|
188
|
+
text: `š“ You drew: ${values[valueSymbol]} of ${suitSymbol} ${suits[suitSymbol]}`,
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
isError: false,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
async function handleDateTime(args) {
|
|
195
|
+
const { timeZone = 'UTC', locale = 'en-US' } = args;
|
|
196
|
+
try {
|
|
197
|
+
const date = new Date();
|
|
198
|
+
const dateFormatter = new Intl.DateTimeFormat(locale, {
|
|
199
|
+
timeZone,
|
|
200
|
+
dateStyle: 'long',
|
|
201
|
+
});
|
|
202
|
+
const timeFormatter = new Intl.DateTimeFormat(locale, {
|
|
203
|
+
timeZone,
|
|
204
|
+
timeStyle: 'medium',
|
|
205
|
+
});
|
|
206
|
+
const formattedDate = dateFormatter.format(date);
|
|
207
|
+
const formattedTime = timeFormatter.format(date);
|
|
208
|
+
return {
|
|
209
|
+
content: [
|
|
210
|
+
{
|
|
211
|
+
type: 'text',
|
|
212
|
+
text: `šļø Date: ${formattedDate}\nā° Time: ${formattedTime}\nš Timezone: ${timeZone}`,
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
isError: false,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
return {
|
|
220
|
+
content: [
|
|
221
|
+
{
|
|
222
|
+
type: 'text',
|
|
223
|
+
text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
isError: true,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
// New tool handlers
|
|
231
|
+
async function handleCalculator(args) {
|
|
232
|
+
const { expression, precision = 2 } = args;
|
|
233
|
+
try {
|
|
234
|
+
// Sanitize and validate the expression
|
|
235
|
+
const sanitizedExpression = expression.replace(/[^0-9+\-*/().%\s]/g, '');
|
|
236
|
+
if (sanitizedExpression !== expression) {
|
|
237
|
+
throw new Error('Invalid characters in expression');
|
|
238
|
+
}
|
|
239
|
+
// Use Function constructor instead of eval for better security
|
|
240
|
+
const calculate = new Function(`return ${sanitizedExpression}`);
|
|
241
|
+
const result = calculate();
|
|
242
|
+
if (typeof result !== 'number' || !Number.isFinite(result)) {
|
|
243
|
+
throw new Error('Invalid mathematical expression');
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
content: [
|
|
247
|
+
{
|
|
248
|
+
type: 'text',
|
|
249
|
+
text: `š§® Expression: ${expression}\nš Result: ${result.toFixed(precision)}`,
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
isError: false,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
return {
|
|
257
|
+
content: [
|
|
258
|
+
{
|
|
259
|
+
type: 'text',
|
|
260
|
+
text: `ā Error: ${error instanceof Error ? error.message : 'Invalid expression'}`,
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
isError: true,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
async function handlePasswordGen(args) {
|
|
268
|
+
const { length = 16, includeNumbers = true, includeSymbols = true, includeUppercase = true, } = args;
|
|
269
|
+
try {
|
|
270
|
+
if (length < 8 || length > 128) {
|
|
271
|
+
throw new Error('Password length must be between 8 and 128 characters');
|
|
272
|
+
}
|
|
273
|
+
const lowercase = 'abcdefghijklmnopqrstuvwxyz';
|
|
274
|
+
const uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
275
|
+
const numbers = '0123456789';
|
|
276
|
+
const symbols = '!@#$%^&*()_+-=[]{}|;:,.<>?';
|
|
277
|
+
let chars = lowercase;
|
|
278
|
+
if (includeUppercase)
|
|
279
|
+
chars += uppercase;
|
|
280
|
+
if (includeNumbers)
|
|
281
|
+
chars += numbers;
|
|
282
|
+
if (includeSymbols)
|
|
283
|
+
chars += symbols;
|
|
284
|
+
let password = '';
|
|
285
|
+
for (let i = 0; i < length; i++) {
|
|
286
|
+
password += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
287
|
+
}
|
|
288
|
+
// Ensure at least one character from each selected type
|
|
289
|
+
const types = [
|
|
290
|
+
{ char: lowercase.charAt(Math.floor(Math.random() * lowercase.length)), condition: true },
|
|
291
|
+
{
|
|
292
|
+
char: uppercase.charAt(Math.floor(Math.random() * uppercase.length)),
|
|
293
|
+
condition: includeUppercase,
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
char: numbers.charAt(Math.floor(Math.random() * numbers.length)),
|
|
297
|
+
condition: includeNumbers,
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
char: symbols.charAt(Math.floor(Math.random() * symbols.length)),
|
|
301
|
+
condition: includeSymbols,
|
|
302
|
+
},
|
|
303
|
+
];
|
|
304
|
+
types.forEach(({ char, condition }, index) => {
|
|
305
|
+
if (condition) {
|
|
306
|
+
const pos = Math.floor(Math.random() * length);
|
|
307
|
+
password = password.slice(0, pos) + char + password.slice(pos + 1);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
return {
|
|
311
|
+
content: [
|
|
312
|
+
{
|
|
313
|
+
type: 'text',
|
|
314
|
+
text: `š Generated Password:\n${password}\n\nš Password Properties:\n⢠Length: ${length}\n⢠Includes Numbers: ${includeNumbers ? 'ā
' : 'ā'}\n⢠Includes Symbols: ${includeSymbols ? 'ā
' : 'ā'}\n⢠Includes Uppercase: ${includeUppercase ? 'ā
' : 'ā'}`,
|
|
315
|
+
},
|
|
316
|
+
],
|
|
317
|
+
isError: false,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
return {
|
|
322
|
+
content: [
|
|
323
|
+
{
|
|
324
|
+
type: 'text',
|
|
325
|
+
text: `ā Error: ${error instanceof Error ? error.message : 'Failed to generate password'}`,
|
|
326
|
+
},
|
|
327
|
+
],
|
|
328
|
+
isError: true,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
async function handleQRGen(args) {
|
|
333
|
+
const { text, size = 200, dark = '#000000', light = '#ffffff' } = args;
|
|
334
|
+
try {
|
|
335
|
+
if (!text) {
|
|
336
|
+
throw new Error('Text is required');
|
|
337
|
+
}
|
|
338
|
+
if (size < 100 || size > 1000) {
|
|
339
|
+
throw new Error('Size must be between 100 and 1000 pixels');
|
|
340
|
+
}
|
|
341
|
+
// Validate color format
|
|
342
|
+
const colorRegex = /^#[0-9A-Fa-f]{6}$/;
|
|
343
|
+
if (!colorRegex.test(dark) || !colorRegex.test(light)) {
|
|
344
|
+
throw new Error('Invalid color format. Use hexadecimal format (e.g., #000000)');
|
|
345
|
+
}
|
|
346
|
+
// Here we would normally generate the QR code
|
|
347
|
+
// For now, we'll return a placeholder message
|
|
348
|
+
return {
|
|
349
|
+
content: [
|
|
350
|
+
{
|
|
351
|
+
type: 'text',
|
|
352
|
+
text: `š± QR Code Properties:\n⢠Content: ${text}\n⢠Size: ${size}px\n⢠Dark Color: ${dark}\n⢠Light Color: ${light}\n\nš QR Code generation successful! (Implementation pending)`,
|
|
353
|
+
},
|
|
354
|
+
],
|
|
355
|
+
isError: false,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
catch (error) {
|
|
359
|
+
return {
|
|
360
|
+
content: [
|
|
361
|
+
{
|
|
362
|
+
type: 'text',
|
|
363
|
+
text: `ā Error: ${error instanceof Error ? error.message : 'Failed to generate QR code'}`,
|
|
364
|
+
},
|
|
365
|
+
],
|
|
366
|
+
isError: true,
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
async function handleKitchenConvert(args) {
|
|
371
|
+
const { value, from, to, ingredient } = args;
|
|
372
|
+
// Conversion factors (base unit: milliliters for volume, grams for weight)
|
|
373
|
+
const volumeConversions = {
|
|
374
|
+
ml: 1, // milliliters
|
|
375
|
+
l: 1000, // liters
|
|
376
|
+
cup: 236.588, // US cup
|
|
377
|
+
tbsp: 14.787, // tablespoon
|
|
378
|
+
tsp: 4.929, // teaspoon
|
|
379
|
+
floz: 29.574, // fluid ounce
|
|
380
|
+
};
|
|
381
|
+
const weightConversions = {
|
|
382
|
+
g: 1, // grams
|
|
383
|
+
kg: 1000, // kilograms
|
|
384
|
+
oz: 28.3495, // ounces
|
|
385
|
+
lb: 453.592, // pounds
|
|
386
|
+
};
|
|
387
|
+
// Common ingredient densities (g/ml)
|
|
388
|
+
const densities = {
|
|
389
|
+
water: 1.0, // water density at room temperature
|
|
390
|
+
milk: 1.03, // whole milk
|
|
391
|
+
flour: 0.593, // all-purpose flour
|
|
392
|
+
sugar: 0.845, // granulated sugar
|
|
393
|
+
'brown sugar': 0.721, // packed brown sugar
|
|
394
|
+
salt: 1.217, // table salt
|
|
395
|
+
butter: 0.911, // unsalted butter
|
|
396
|
+
oil: 0.918, // vegetable oil
|
|
397
|
+
honey: 1.42, // pure honey
|
|
398
|
+
'maple syrup': 1.37, // pure maple syrup
|
|
399
|
+
};
|
|
400
|
+
try {
|
|
401
|
+
// Validate units
|
|
402
|
+
const fromUnit = from.toLowerCase();
|
|
403
|
+
const toUnit = to.toLowerCase();
|
|
404
|
+
const ing = ingredient?.toLowerCase();
|
|
405
|
+
// Check if units exist
|
|
406
|
+
if (!volumeConversions[fromUnit] && !weightConversions[fromUnit]) {
|
|
407
|
+
throw new Error(`Invalid source unit: ${from}`);
|
|
408
|
+
}
|
|
409
|
+
if (!volumeConversions[toUnit] && !weightConversions[toUnit]) {
|
|
410
|
+
throw new Error(`Invalid target unit: ${to}`);
|
|
411
|
+
}
|
|
412
|
+
let result;
|
|
413
|
+
// Same type conversion (volume to volume or weight to weight)
|
|
414
|
+
if ((volumeConversions[fromUnit] && volumeConversions[toUnit]) ||
|
|
415
|
+
(weightConversions[fromUnit] && weightConversions[toUnit])) {
|
|
416
|
+
const conversions = volumeConversions[fromUnit] ? volumeConversions : weightConversions;
|
|
417
|
+
result = (value * conversions[fromUnit]) / conversions[toUnit];
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
// Volume to weight or weight to volume conversion
|
|
421
|
+
if (!ing || !densities[ing]) {
|
|
422
|
+
throw new Error(`Ingredient is required for volume-weight conversions. Available ingredients: ${Object.keys(densities).join(', ')}`);
|
|
423
|
+
}
|
|
424
|
+
// Convert to base units first (ml or g)
|
|
425
|
+
let baseValue;
|
|
426
|
+
if (volumeConversions[fromUnit]) {
|
|
427
|
+
baseValue = value * volumeConversions[fromUnit] * densities[ing];
|
|
428
|
+
result = baseValue / weightConversions[toUnit];
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
baseValue = value * weightConversions[fromUnit];
|
|
432
|
+
result = baseValue / (volumeConversions[toUnit] * densities[ing]);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return {
|
|
436
|
+
content: [
|
|
437
|
+
{
|
|
438
|
+
type: 'text',
|
|
439
|
+
text: `š Conversion Result:\n⢠${value} ${from} ${ingredient ? `of ${ingredient} ` : ''}= ${result.toFixed(2)} ${to}\n\nš Note: ${ingredient ? 'Conversion includes ingredient density' : 'Direct unit conversion'}`,
|
|
440
|
+
},
|
|
441
|
+
],
|
|
442
|
+
isError: false,
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
catch (error) {
|
|
446
|
+
return {
|
|
447
|
+
content: [
|
|
448
|
+
{
|
|
449
|
+
type: 'text',
|
|
450
|
+
text: `ā Error: ${error instanceof Error ? error.message : 'Invalid conversion'}`,
|
|
451
|
+
},
|
|
452
|
+
],
|
|
453
|
+
isError: true,
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
// Tool call handler
|
|
458
|
+
async function handleToolCall(name, args) {
|
|
459
|
+
switch (name) {
|
|
460
|
+
case 'greeting':
|
|
461
|
+
return handleGreeting(args);
|
|
462
|
+
case 'card':
|
|
463
|
+
return handleCard();
|
|
464
|
+
case 'datetime':
|
|
465
|
+
return handleDateTime(args);
|
|
466
|
+
case 'calculator':
|
|
467
|
+
return handleCalculator(args);
|
|
468
|
+
case 'passwordGen':
|
|
469
|
+
return handlePasswordGen(args);
|
|
470
|
+
case 'qrGen':
|
|
471
|
+
return handleQRGen(args);
|
|
472
|
+
case 'kitchenConvert':
|
|
473
|
+
return handleKitchenConvert(args);
|
|
474
|
+
default:
|
|
475
|
+
return {
|
|
476
|
+
content: [
|
|
477
|
+
{
|
|
478
|
+
type: 'text',
|
|
479
|
+
text: `Unknown tool: ${name}`,
|
|
480
|
+
},
|
|
481
|
+
],
|
|
482
|
+
isError: true,
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
// Server configuration
|
|
487
|
+
const server = new Server({
|
|
488
|
+
name: '@nekzus/mcp-server',
|
|
489
|
+
version: '0.1.0',
|
|
490
|
+
description: 'MCP Server implementation for development',
|
|
491
|
+
}, {
|
|
492
|
+
capabilities: {
|
|
493
|
+
tools: {},
|
|
494
|
+
},
|
|
495
|
+
});
|
|
496
|
+
// Setup request handlers
|
|
497
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
498
|
+
tools: TOOLS,
|
|
499
|
+
}));
|
|
500
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => handleToolCall(request.params.name, request.params.arguments ?? {}));
|
|
501
|
+
// Server startup
|
|
502
|
+
async function runServer() {
|
|
503
|
+
try {
|
|
504
|
+
const transport = new StdioServerTransport();
|
|
505
|
+
await server.connect(transport);
|
|
506
|
+
log('[Server] MCP Server is running');
|
|
507
|
+
log('[Server] Available tools:', TOOLS.map((t) => t.name).join(', '));
|
|
508
|
+
// Handle stdin close
|
|
509
|
+
process.stdin.on('close', () => {
|
|
510
|
+
log('[Server] Input stream closed');
|
|
511
|
+
cleanup();
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
catch (error) {
|
|
515
|
+
log('[Server] Failed to start MCP Server:', error);
|
|
516
|
+
process.exit(1);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
// Cleanup function
|
|
520
|
+
async function cleanup() {
|
|
521
|
+
try {
|
|
522
|
+
await server.close();
|
|
523
|
+
log('[Server] MCP Server stopped gracefully');
|
|
524
|
+
process.exit(0);
|
|
525
|
+
}
|
|
526
|
+
catch (error) {
|
|
527
|
+
log('[Server] Error during cleanup:', error);
|
|
528
|
+
process.exit(1);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
// Start the server
|
|
532
|
+
runServer().catch((error) => log('[Server] Unhandled error:', error));
|
package/package.json
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nekzus/mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Personal MCP Server implementation providing extensible utility functions and tools for development and testing purposes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"mcp-server": "
|
|
7
|
+
"mcp-server": "dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "tsc &&
|
|
13
|
+
"build": "tsc && shx chmod +x dist/*.js",
|
|
14
|
+
"dev": "tsx src/index.ts",
|
|
14
15
|
"start": "node dist/index.js",
|
|
15
16
|
"test": "jest --passWithNoTests",
|
|
16
17
|
"format": "biome format --write .",
|
|
17
18
|
"lint": "biome lint --write .",
|
|
18
19
|
"check": "biome check --apply .",
|
|
19
20
|
"commit": "git-cz",
|
|
20
|
-
"semantic-release": "semantic-release --branches main"
|
|
21
|
+
"semantic-release": "semantic-release --branches main",
|
|
22
|
+
"prepare": "npm run build",
|
|
23
|
+
"watch": "tsc --watch"
|
|
21
24
|
},
|
|
22
25
|
"keywords": [
|
|
23
26
|
"mcp",
|
|
@@ -53,7 +56,9 @@
|
|
|
53
56
|
"cz-conventional-changelog": "3.3.0",
|
|
54
57
|
"jest": "29.7.0",
|
|
55
58
|
"semantic-release": "24.2.3",
|
|
59
|
+
"shx": "0.4.0",
|
|
56
60
|
"ts-jest": "29.2.6",
|
|
61
|
+
"tsx": "4.19.3",
|
|
57
62
|
"typescript": "5.8.2"
|
|
58
63
|
},
|
|
59
64
|
"config": {
|