@nekzus/mcp-server 1.0.32 → 1.0.33
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 +7 -15
- package/package.json +9 -4
- package/biome.json +0 -45
- package/index.ts +0 -210
package/dist/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
4
|
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
-
import 'dotenv/config';
|
|
6
5
|
const TOOLS = [
|
|
7
6
|
{
|
|
8
7
|
name: 'greeting',
|
|
@@ -121,7 +120,7 @@ async function handleToolCall(name, args) {
|
|
|
121
120
|
content: [
|
|
122
121
|
{
|
|
123
122
|
type: 'text',
|
|
124
|
-
text: `
|
|
123
|
+
text: `Unknown tool: ${name}`,
|
|
125
124
|
},
|
|
126
125
|
],
|
|
127
126
|
isError: true,
|
|
@@ -129,7 +128,7 @@ async function handleToolCall(name, args) {
|
|
|
129
128
|
}
|
|
130
129
|
}
|
|
131
130
|
const server = new Server({
|
|
132
|
-
name: '@nekzus/
|
|
131
|
+
name: '@nekzus/server-nekzus',
|
|
133
132
|
version: '0.1.0',
|
|
134
133
|
description: 'MCP Server implementation for development',
|
|
135
134
|
}, {
|
|
@@ -137,23 +136,16 @@ const server = new Server({
|
|
|
137
136
|
tools: {},
|
|
138
137
|
},
|
|
139
138
|
});
|
|
140
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
});
|
|
145
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
146
|
-
const { name, arguments: args } = request.params;
|
|
147
|
-
return handleToolCall(name, args ?? {});
|
|
148
|
-
});
|
|
139
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
140
|
+
tools: TOOLS,
|
|
141
|
+
}));
|
|
142
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => handleToolCall(request.params.name, request.params.arguments ?? {}));
|
|
149
143
|
async function runServer() {
|
|
150
144
|
try {
|
|
151
145
|
const transport = new StdioServerTransport();
|
|
152
146
|
await server.connect(transport);
|
|
153
147
|
console.log('[Server] MCP Server is running');
|
|
154
148
|
console.log('[Server] Available tools:', TOOLS.map((t) => t.name).join(', '));
|
|
155
|
-
process.on('SIGTERM', () => cleanup());
|
|
156
|
-
process.on('SIGINT', () => cleanup());
|
|
157
149
|
process.stdin.on('close', () => {
|
|
158
150
|
console.log('[Server] Input stream closed');
|
|
159
151
|
cleanup();
|
|
@@ -175,4 +167,4 @@ async function cleanup() {
|
|
|
175
167
|
process.exit(1);
|
|
176
168
|
}
|
|
177
169
|
}
|
|
178
|
-
runServer();
|
|
170
|
+
runServer().catch(console.error);
|
package/package.json
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nekzus/mcp-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.33",
|
|
4
4
|
"description": "Personal MCP Server implementation providing extensible utility functions and tools for development and testing purposes",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
7
|
"bin": {
|
|
8
|
-
"mcp-server": "dist/index.js"
|
|
8
|
+
"mcp-server": "./dist/index.js"
|
|
9
9
|
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
10
15
|
"scripts": {
|
|
11
|
-
"build": "tsc && shx chmod +x dist
|
|
16
|
+
"build": "tsc && shx chmod +x dist/index.js",
|
|
12
17
|
"dev": "tsx src/index.ts",
|
|
13
18
|
"start": "node dist/index.js",
|
|
14
19
|
"test": "jest --passWithNoTests",
|
package/biome.json
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
|
3
|
-
"vcs": {
|
|
4
|
-
"enabled": true,
|
|
5
|
-
"clientKind": "git",
|
|
6
|
-
"useIgnoreFile": true
|
|
7
|
-
},
|
|
8
|
-
"files": {
|
|
9
|
-
"ignoreUnknown": false,
|
|
10
|
-
"ignore": []
|
|
11
|
-
},
|
|
12
|
-
"formatter": {
|
|
13
|
-
"enabled": true,
|
|
14
|
-
"formatWithErrors": false,
|
|
15
|
-
"ignore": [],
|
|
16
|
-
"indentStyle": "tab",
|
|
17
|
-
"lineEnding": "lf",
|
|
18
|
-
"lineWidth": 100
|
|
19
|
-
},
|
|
20
|
-
"organizeImports": {
|
|
21
|
-
"enabled": true
|
|
22
|
-
},
|
|
23
|
-
"linter": {
|
|
24
|
-
"enabled": true,
|
|
25
|
-
"rules": {
|
|
26
|
-
"recommended": true,
|
|
27
|
-
"style": {
|
|
28
|
-
"noNonNullAssertion": "off"
|
|
29
|
-
},
|
|
30
|
-
"suspicious": {
|
|
31
|
-
"noExplicitAny": "off"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"javascript": {
|
|
36
|
-
"formatter": {
|
|
37
|
-
"quoteStyle": "single"
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
"json": {
|
|
41
|
-
"formatter": {
|
|
42
|
-
"indentStyle": "space"
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
package/index.ts
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
4
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
|
-
import type { CallToolResult, Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
6
|
-
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
-
import 'dotenv/config';
|
|
8
|
-
|
|
9
|
-
// Available tools definition
|
|
10
|
-
const TOOLS: Tool[] = [
|
|
11
|
-
{
|
|
12
|
-
name: 'greeting',
|
|
13
|
-
description: 'Generate a personalized greeting message for the specified person',
|
|
14
|
-
inputSchema: {
|
|
15
|
-
type: 'object',
|
|
16
|
-
properties: {
|
|
17
|
-
name: {
|
|
18
|
-
type: 'string',
|
|
19
|
-
description: 'Name of the recipient for the greeting',
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
required: ['name'],
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: 'card',
|
|
27
|
-
description: 'Draw a random card from a standard 52-card poker deck',
|
|
28
|
-
inputSchema: {
|
|
29
|
-
type: 'object',
|
|
30
|
-
properties: {
|
|
31
|
-
random_string: {
|
|
32
|
-
type: 'string',
|
|
33
|
-
description: 'Dummy parameter for no-parameter tools',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
required: ['random_string'],
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: 'datetime',
|
|
41
|
-
description: 'Get the current date and time for a specific timezone',
|
|
42
|
-
inputSchema: {
|
|
43
|
-
type: 'object',
|
|
44
|
-
properties: {
|
|
45
|
-
timeZone: {
|
|
46
|
-
type: 'string',
|
|
47
|
-
description: 'Timezone identifier (e.g., "America/New_York")',
|
|
48
|
-
},
|
|
49
|
-
locale: {
|
|
50
|
-
type: 'string',
|
|
51
|
-
description: 'Locale identifier (e.g., "en-US")',
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
];
|
|
57
|
-
|
|
58
|
-
// Tool handlers
|
|
59
|
-
async function handleGreeting(args: { name: string }): Promise<CallToolResult> {
|
|
60
|
-
const { name } = args;
|
|
61
|
-
return {
|
|
62
|
-
content: [
|
|
63
|
-
{
|
|
64
|
-
type: 'text',
|
|
65
|
-
text: `¡Hola ${name}! ¿Cómo estás?`,
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
isError: false,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async function handleCard(): Promise<CallToolResult> {
|
|
73
|
-
const suits = ['♠', '♥', '♦', '♣'];
|
|
74
|
-
const values = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'];
|
|
75
|
-
|
|
76
|
-
const suit = suits[Math.floor(Math.random() * suits.length)];
|
|
77
|
-
const value = values[Math.floor(Math.random() * values.length)];
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
content: [
|
|
81
|
-
{
|
|
82
|
-
type: 'text',
|
|
83
|
-
text: `${value}${suit}`,
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
isError: false,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async function handleDateTime(args: {
|
|
91
|
-
timeZone?: string;
|
|
92
|
-
locale?: string;
|
|
93
|
-
}): Promise<CallToolResult> {
|
|
94
|
-
const { timeZone = 'UTC', locale = 'en-US' } = args;
|
|
95
|
-
|
|
96
|
-
try {
|
|
97
|
-
const date = new Date();
|
|
98
|
-
const formattedDate = new Intl.DateTimeFormat(locale, {
|
|
99
|
-
timeZone,
|
|
100
|
-
dateStyle: 'full',
|
|
101
|
-
timeStyle: 'long',
|
|
102
|
-
}).format(date);
|
|
103
|
-
|
|
104
|
-
return {
|
|
105
|
-
content: [
|
|
106
|
-
{
|
|
107
|
-
type: 'text',
|
|
108
|
-
text: formattedDate,
|
|
109
|
-
},
|
|
110
|
-
],
|
|
111
|
-
isError: false,
|
|
112
|
-
};
|
|
113
|
-
} catch (error) {
|
|
114
|
-
return {
|
|
115
|
-
content: [
|
|
116
|
-
{
|
|
117
|
-
type: 'text',
|
|
118
|
-
text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
isError: true,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Tool call handler
|
|
127
|
-
async function handleToolCall(name: string, args: any): Promise<CallToolResult> {
|
|
128
|
-
switch (name) {
|
|
129
|
-
case 'greeting':
|
|
130
|
-
return handleGreeting(args);
|
|
131
|
-
case 'card':
|
|
132
|
-
return handleCard();
|
|
133
|
-
case 'datetime':
|
|
134
|
-
return handleDateTime(args);
|
|
135
|
-
default:
|
|
136
|
-
return {
|
|
137
|
-
content: [
|
|
138
|
-
{
|
|
139
|
-
type: 'text',
|
|
140
|
-
text: `Error: Unknown tool '${name}'`,
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
isError: true,
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Server configuration
|
|
149
|
-
const server = new Server(
|
|
150
|
-
{
|
|
151
|
-
name: '@nekzus/mcp-server',
|
|
152
|
-
version: '0.1.0',
|
|
153
|
-
description: 'MCP Server implementation for development',
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
capabilities: {
|
|
157
|
-
tools: {},
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
// Request handlers configuration
|
|
163
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
164
|
-
return {
|
|
165
|
-
tools: TOOLS,
|
|
166
|
-
};
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
170
|
-
const { name, arguments: args } = request.params;
|
|
171
|
-
return handleToolCall(name, args ?? {});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
// Server startup
|
|
175
|
-
async function runServer() {
|
|
176
|
-
try {
|
|
177
|
-
const transport = new StdioServerTransport();
|
|
178
|
-
await server.connect(transport);
|
|
179
|
-
console.log('[Server] MCP Server is running');
|
|
180
|
-
console.log('[Server] Available tools:', TOOLS.map((t) => t.name).join(', '));
|
|
181
|
-
|
|
182
|
-
// Termination signal handlers
|
|
183
|
-
process.on('SIGTERM', () => cleanup());
|
|
184
|
-
process.on('SIGINT', () => cleanup());
|
|
185
|
-
|
|
186
|
-
// Handle stdin close
|
|
187
|
-
process.stdin.on('close', () => {
|
|
188
|
-
console.log('[Server] Input stream closed');
|
|
189
|
-
cleanup();
|
|
190
|
-
});
|
|
191
|
-
} catch (error) {
|
|
192
|
-
console.error('[Server] Failed to start MCP Server:', error);
|
|
193
|
-
process.exit(1);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Cleanup function for server shutdown
|
|
198
|
-
async function cleanup() {
|
|
199
|
-
try {
|
|
200
|
-
await server.close();
|
|
201
|
-
console.log('[Server] MCP Server stopped gracefully');
|
|
202
|
-
process.exit(0);
|
|
203
|
-
} catch (error) {
|
|
204
|
-
console.error('[Server] Error during cleanup:', error);
|
|
205
|
-
process.exit(1);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Start the server
|
|
210
|
-
runServer();
|