@nekzus/mcp-server 1.0.30 → 1.0.32
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/biome.json +45 -0
- package/dist/index.js +1 -1
- package/index.ts +210 -0
- package/package.json +3 -12
package/biome.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
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/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import 'dotenv/config';
|
|
6
6
|
const TOOLS = [
|
|
7
7
|
{
|
package/index.ts
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
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();
|
package/package.json
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nekzus/mcp-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
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
|
-
"types": "dist/index.d.ts",
|
|
8
7
|
"bin": {
|
|
9
8
|
"mcp-server": "dist/index.js"
|
|
10
9
|
},
|
|
11
|
-
"files": [
|
|
12
|
-
"dist"
|
|
13
|
-
],
|
|
14
10
|
"scripts": {
|
|
15
11
|
"build": "tsc && shx chmod +x dist/*.js",
|
|
16
12
|
"dev": "tsx src/index.ts",
|
|
@@ -22,8 +18,7 @@
|
|
|
22
18
|
"commit": "git-cz",
|
|
23
19
|
"semantic-release": "semantic-release --branches main",
|
|
24
20
|
"prepare": "npm run build",
|
|
25
|
-
"watch": "tsc --watch"
|
|
26
|
-
"ci": "npm run check && npm run build && npm test"
|
|
21
|
+
"watch": "tsc --watch"
|
|
27
22
|
},
|
|
28
23
|
"keywords": [
|
|
29
24
|
"mcp",
|
|
@@ -45,8 +40,7 @@
|
|
|
45
40
|
"homepage": "https://github.com/Nekzus/mcp-server#readme",
|
|
46
41
|
"dependencies": {
|
|
47
42
|
"@modelcontextprotocol/sdk": "1.7.0",
|
|
48
|
-
"dotenv": "16.4.7"
|
|
49
|
-
"zod": "3.24.2"
|
|
43
|
+
"dotenv": "16.4.7"
|
|
50
44
|
},
|
|
51
45
|
"devDependencies": {
|
|
52
46
|
"@biomejs/biome": "1.9.4",
|
|
@@ -65,9 +59,6 @@
|
|
|
65
59
|
"tsx": "4.19.3",
|
|
66
60
|
"typescript": "5.8.2"
|
|
67
61
|
},
|
|
68
|
-
"engines": {
|
|
69
|
-
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
|
70
|
-
},
|
|
71
62
|
"config": {
|
|
72
63
|
"commitizen": {
|
|
73
64
|
"path": "./node_modules/cz-conventional-changelog"
|