@nekzus/mcp-server 1.0.25 → 1.0.27
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 +39 -45
- package/dist/tools/index.js +10 -12
- package/dist/utils/datetime.js +27 -21
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
4
5
|
import 'dotenv/config';
|
|
5
|
-
import { z } from 'zod';
|
|
6
6
|
import availableTools from './tools/index.js';
|
|
7
|
-
import { schemaConverter } from './utils/schema.js';
|
|
8
7
|
export class McpUtilityServer {
|
|
9
8
|
constructor() {
|
|
10
9
|
this.server = new Server({
|
|
@@ -19,60 +18,55 @@ export class McpUtilityServer {
|
|
|
19
18
|
});
|
|
20
19
|
this.transport = new StdioServerTransport();
|
|
21
20
|
this.tools = availableTools;
|
|
22
|
-
//
|
|
23
|
-
this.
|
|
24
|
-
method: z.literal('tools/list'),
|
|
25
|
-
params: z.object({}).optional(),
|
|
26
|
-
}), async () => {
|
|
27
|
-
return {
|
|
28
|
-
tools: this.tools.map((tool) => ({
|
|
29
|
-
name: tool.name,
|
|
30
|
-
description: tool.description,
|
|
31
|
-
schema: tool.inputSchema,
|
|
32
|
-
})),
|
|
33
|
-
};
|
|
34
|
-
});
|
|
21
|
+
// Configurar los manejadores de solicitudes
|
|
22
|
+
this.setupRequestHandlers();
|
|
35
23
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
24
|
+
setupRequestHandlers() {
|
|
25
|
+
// Listar herramientas disponibles
|
|
26
|
+
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
27
|
+
tools: this.tools,
|
|
28
|
+
}));
|
|
29
|
+
// Manejar llamadas a herramientas
|
|
30
|
+
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
31
|
+
const { name, arguments: args = {} } = request.params;
|
|
32
|
+
try {
|
|
33
|
+
const tool = this.tools.find((t) => t.name === name);
|
|
34
|
+
if (!tool) {
|
|
35
|
+
throw new Error(`Tool not found: ${name}`);
|
|
36
|
+
}
|
|
37
|
+
const handler = tool.handler;
|
|
38
|
+
const result = await handler(args);
|
|
39
|
+
return {
|
|
40
|
+
content: result.content.map((content) => {
|
|
41
|
+
const mappedContent = {
|
|
42
|
+
type: content.type,
|
|
43
|
+
text: typeof content.text === 'string'
|
|
44
|
+
? content.text
|
|
45
|
+
: JSON.stringify(content.text, null, 2),
|
|
46
|
+
};
|
|
47
|
+
if (content.data !== undefined) {
|
|
48
|
+
return { ...mappedContent, data: content.data };
|
|
49
|
+
}
|
|
50
|
+
return mappedContent;
|
|
51
|
+
}),
|
|
52
|
+
isError: result.isError,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
50
56
|
return {
|
|
51
57
|
content: [
|
|
52
58
|
{
|
|
53
59
|
type: 'text',
|
|
54
|
-
text:
|
|
60
|
+
text: error instanceof Error ? error.message : String(error),
|
|
55
61
|
},
|
|
56
62
|
],
|
|
63
|
+
isError: true,
|
|
57
64
|
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
console.error(`[Tool Registration] Failed to register tool ${tool.name}:`, error);
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
initializeTools() {
|
|
67
|
-
console.log(`[Server] Initializing ${this.tools.length} tools...`);
|
|
68
|
-
for (const tool of this.tools) {
|
|
69
|
-
this.registerTool(tool);
|
|
70
|
-
}
|
|
71
|
-
console.log('[Server] Tool initialization completed successfully');
|
|
65
|
+
}
|
|
66
|
+
});
|
|
72
67
|
}
|
|
73
68
|
async start() {
|
|
74
69
|
try {
|
|
75
|
-
this.initializeTools();
|
|
76
70
|
await this.server.connect(this.transport);
|
|
77
71
|
console.log('[Server] MCP Utility Server is running');
|
|
78
72
|
console.log('[Server] Available tools:', this.tools.map((t) => t.name).join(', '));
|
package/dist/tools/index.js
CHANGED
|
@@ -10,7 +10,7 @@ export const greetingTool = {
|
|
|
10
10
|
},
|
|
11
11
|
required: ['name'],
|
|
12
12
|
},
|
|
13
|
-
handler: async (args
|
|
13
|
+
handler: async (args) => {
|
|
14
14
|
try {
|
|
15
15
|
return {
|
|
16
16
|
content: [
|
|
@@ -42,7 +42,7 @@ export const cardTool = {
|
|
|
42
42
|
properties: {},
|
|
43
43
|
required: [],
|
|
44
44
|
},
|
|
45
|
-
handler: async (
|
|
45
|
+
handler: async () => {
|
|
46
46
|
try {
|
|
47
47
|
const card = getRandomCard();
|
|
48
48
|
return {
|
|
@@ -69,28 +69,28 @@ export const cardTool = {
|
|
|
69
69
|
};
|
|
70
70
|
export const dateTimeTool = {
|
|
71
71
|
name: 'datetime',
|
|
72
|
-
description: 'Get current date and time for a specific timezone
|
|
72
|
+
description: 'Get the current date and time for a specific timezone',
|
|
73
73
|
inputSchema: {
|
|
74
74
|
type: 'object',
|
|
75
75
|
properties: {
|
|
76
76
|
timeZone: {
|
|
77
77
|
type: 'string',
|
|
78
|
-
description: 'Timezone identifier (e.g., America/New_York
|
|
78
|
+
description: 'Timezone identifier (e.g., "America/New_York")',
|
|
79
79
|
},
|
|
80
80
|
locale: {
|
|
81
81
|
type: 'string',
|
|
82
|
-
description: 'Locale identifier (e.g., en-US
|
|
82
|
+
description: 'Locale identifier (e.g., "en-US")',
|
|
83
83
|
},
|
|
84
84
|
},
|
|
85
85
|
},
|
|
86
|
-
handler: async (args
|
|
86
|
+
handler: async (args) => {
|
|
87
87
|
try {
|
|
88
|
-
const { date, time,
|
|
88
|
+
const { date, time, timezone } = getCurrentDateTime(args.timeZone, args.locale);
|
|
89
89
|
return {
|
|
90
90
|
content: [
|
|
91
91
|
{
|
|
92
92
|
type: 'text',
|
|
93
|
-
text: `🗓️ Date: ${date}\n⏰ Time: ${time}\n🌍 Timezone: ${
|
|
93
|
+
text: `🗓️ Date: ${date}\n⏰ Time: ${time}\n🌍 Timezone: ${timezone}`,
|
|
94
94
|
},
|
|
95
95
|
],
|
|
96
96
|
};
|
|
@@ -100,7 +100,7 @@ export const dateTimeTool = {
|
|
|
100
100
|
content: [
|
|
101
101
|
{
|
|
102
102
|
type: 'text',
|
|
103
|
-
text: 'Error
|
|
103
|
+
text: 'Error getting date and time',
|
|
104
104
|
},
|
|
105
105
|
],
|
|
106
106
|
isError: true,
|
|
@@ -108,6 +108,4 @@ export const dateTimeTool = {
|
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
110
|
};
|
|
111
|
-
|
|
112
|
-
const availableTools = [greetingTool, cardTool, dateTimeTool];
|
|
113
|
-
export default availableTools;
|
|
111
|
+
export default [greetingTool, cardTool, dateTimeTool];
|
package/dist/utils/datetime.js
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
export function getCurrentDateTime(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
time:
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
export function getCurrentDateTime(timeZone, locale) {
|
|
2
|
+
try {
|
|
3
|
+
const now = new Date();
|
|
4
|
+
const defaultTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
5
|
+
const options = {
|
|
6
|
+
timeZone: timeZone || defaultTimeZone,
|
|
7
|
+
dateStyle: 'full',
|
|
8
|
+
timeStyle: 'medium',
|
|
9
|
+
};
|
|
10
|
+
const formatter = new Intl.DateTimeFormat(locale || 'en-US', options);
|
|
11
|
+
const [datePart, timePart] = formatter.format(now).split(' at ');
|
|
12
|
+
return {
|
|
13
|
+
date: datePart,
|
|
14
|
+
time: timePart,
|
|
15
|
+
timezone: timeZone || defaultTimeZone,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
console.error('[DateTime] Error formatting date and time:', error);
|
|
20
|
+
const now = new Date();
|
|
21
|
+
const defaultTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
22
|
+
return {
|
|
23
|
+
date: now.toLocaleDateString(),
|
|
24
|
+
time: now.toLocaleTimeString(),
|
|
25
|
+
timezone: defaultTimeZone,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
22
28
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nekzus/mcp-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
4
4
|
"description": "Personal MCP Server implementation providing extensible utility functions and tools for development and testing purposes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"bin": {
|
|
9
|
-
"
|
|
9
|
+
"mcp-server": "dist/index.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"dist"
|