@nekzus/mcp-server 1.0.32 → 1.0.34

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.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import 'dotenv/config';
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ 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
5
  import 'dotenv/config';
6
+ // Define the tools once to avoid repetition
6
7
  const TOOLS = [
7
8
  {
8
9
  name: 'greeting',
@@ -50,6 +51,7 @@ const TOOLS = [
50
51
  },
51
52
  },
52
53
  ];
54
+ // Tool handlers
53
55
  async function handleGreeting(args) {
54
56
  const { name } = args;
55
57
  return {
@@ -108,6 +110,7 @@ async function handleDateTime(args) {
108
110
  };
109
111
  }
110
112
  }
113
+ // Tool call handler
111
114
  async function handleToolCall(name, args) {
112
115
  switch (name) {
113
116
  case 'greeting':
@@ -121,13 +124,14 @@ async function handleToolCall(name, args) {
121
124
  content: [
122
125
  {
123
126
  type: 'text',
124
- text: `Error: Unknown tool '${name}'`,
127
+ text: `Unknown tool: ${name}`,
125
128
  },
126
129
  ],
127
130
  isError: true,
128
131
  };
129
132
  }
130
133
  }
134
+ // Server configuration
131
135
  const server = new Server({
132
136
  name: '@nekzus/mcp-server',
133
137
  version: '0.1.0',
@@ -137,23 +141,19 @@ const server = new Server({
137
141
  tools: {},
138
142
  },
139
143
  });
140
- server.setRequestHandler(ListToolsRequestSchema, async () => {
141
- return {
142
- tools: TOOLS,
143
- };
144
- });
145
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
146
- const { name, arguments: args } = request.params;
147
- return handleToolCall(name, args ?? {});
148
- });
144
+ // Setup request handlers
145
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
146
+ tools: TOOLS,
147
+ }));
148
+ server.setRequestHandler(CallToolRequestSchema, async (request) => handleToolCall(request.params.name, request.params.arguments ?? {}));
149
+ // Server startup
149
150
  async function runServer() {
150
151
  try {
151
152
  const transport = new StdioServerTransport();
152
153
  await server.connect(transport);
153
154
  console.log('[Server] MCP Server is running');
154
155
  console.log('[Server] Available tools:', TOOLS.map((t) => t.name).join(', '));
155
- process.on('SIGTERM', () => cleanup());
156
- process.on('SIGINT', () => cleanup());
156
+ // Handle stdin close
157
157
  process.stdin.on('close', () => {
158
158
  console.log('[Server] Input stream closed');
159
159
  cleanup();
@@ -164,6 +164,7 @@ async function runServer() {
164
164
  process.exit(1);
165
165
  }
166
166
  }
167
+ // Cleanup function
167
168
  async function cleanup() {
168
169
  try {
169
170
  await server.close();
@@ -175,4 +176,5 @@ async function cleanup() {
175
176
  process.exit(1);
176
177
  }
177
178
  }
178
- runServer();
179
+ // Start the server
180
+ runServer().catch(console.error);
package/package.json CHANGED
@@ -1,14 +1,19 @@
1
1
  {
2
2
  "name": "@nekzus/mcp-server",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
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/*.js",
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();