@nekzus/mcp-server 1.0.22 → 1.0.23
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/README.md +0 -10
- package/dist/index.js +11 -4
- package/dist/utils/schema.js +10 -3
- package/package.json +2 -2
- package/dist/cli.js +0 -91
package/README.md
CHANGED
|
@@ -23,16 +23,6 @@ official MCP SDK and offers an extensible architecture for adding new tools_
|
|
|
23
23
|
- 🔒 Strict TypeScript Types
|
|
24
24
|
- 🧩 Extensible Architecture for New Tools
|
|
25
25
|
|
|
26
|
-
## 📦 Installation
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
# Global installation (recommended for CLI usage)
|
|
30
|
-
npm install -g @nekzus/mcp-server
|
|
31
|
-
|
|
32
|
-
# Local installation
|
|
33
|
-
npm install @nekzus/mcp-server
|
|
34
|
-
```
|
|
35
|
-
|
|
36
26
|
## 🛠️ Available Tools
|
|
37
27
|
|
|
38
28
|
### 1. greeting
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
4
|
import 'dotenv/config';
|
|
5
|
+
import { z } from 'zod';
|
|
5
6
|
import availableTools from './tools/index.js';
|
|
6
7
|
import { schemaConverter } from './utils/schema.js';
|
|
7
8
|
export class McpUtilityServer {
|
|
8
9
|
constructor() {
|
|
9
|
-
this.server = new
|
|
10
|
-
name: 'mcp-server',
|
|
10
|
+
this.server = new Server({
|
|
11
|
+
name: '@nekzus/mcp-server',
|
|
11
12
|
version: '1.0.0',
|
|
12
13
|
description: 'MCP Server implementation providing utility functions and tools for development and testing',
|
|
13
14
|
}, {
|
|
@@ -24,7 +25,13 @@ export class McpUtilityServer {
|
|
|
24
25
|
console.log(`[Tool Registration] Registering tool: ${tool.name}`);
|
|
25
26
|
const zodSchema = schemaConverter.toZod(tool.inputSchema);
|
|
26
27
|
const handler = tool.handler;
|
|
27
|
-
this.server.
|
|
28
|
+
this.server.setRequestHandler(z.object({
|
|
29
|
+
method: z.literal('tool'),
|
|
30
|
+
params: z.object({
|
|
31
|
+
name: z.literal(tool.name),
|
|
32
|
+
schema: zodSchema,
|
|
33
|
+
}),
|
|
34
|
+
}), async (args, extra) => {
|
|
28
35
|
const result = await handler(args, extra);
|
|
29
36
|
return {
|
|
30
37
|
content: [
|
package/dist/utils/schema.js
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
2
|
+
function convertProperty(prop) {
|
|
3
3
|
switch (prop.type) {
|
|
4
4
|
case 'string':
|
|
5
|
-
return
|
|
5
|
+
return z.string();
|
|
6
6
|
case 'number':
|
|
7
7
|
return z.number();
|
|
8
8
|
case 'boolean':
|
|
9
9
|
return z.boolean();
|
|
10
|
+
case 'array':
|
|
11
|
+
if (!prop.items) {
|
|
12
|
+
throw new Error('Array schema must have items property');
|
|
13
|
+
}
|
|
14
|
+
return z.array(convertProperty(prop.items));
|
|
15
|
+
case 'object':
|
|
16
|
+
return z.record(z.string(), z.unknown());
|
|
10
17
|
default:
|
|
11
18
|
return z.unknown();
|
|
12
19
|
}
|
|
13
|
-
}
|
|
20
|
+
}
|
|
14
21
|
export const schemaConverter = {
|
|
15
22
|
toZod: (schema) => {
|
|
16
23
|
if (schema.type !== 'object') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nekzus/mcp-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
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",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"dist"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "tsc && shx chmod +x dist
|
|
15
|
+
"build": "tsc && shx chmod +x dist/*.js",
|
|
16
16
|
"dev": "tsx src/index.ts",
|
|
17
17
|
"start": "node dist/index.js",
|
|
18
18
|
"test": "jest --passWithNoTests",
|
package/dist/cli.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
-
import 'dotenv/config';
|
|
5
|
-
import availableTools from './tools/index.js';
|
|
6
|
-
import { schemaConverter } from './utils/schema.js';
|
|
7
|
-
export class McpUtilityServer {
|
|
8
|
-
constructor() {
|
|
9
|
-
this.server = new McpServer({
|
|
10
|
-
name: 'mcp-server',
|
|
11
|
-
version: '1.0.0',
|
|
12
|
-
description: 'MCP Server implementation providing utility functions and tools for development and testing',
|
|
13
|
-
}, {
|
|
14
|
-
capabilities: {
|
|
15
|
-
resources: {},
|
|
16
|
-
tools: {},
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
this.transport = new StdioServerTransport();
|
|
20
|
-
this.tools = availableTools;
|
|
21
|
-
}
|
|
22
|
-
registerTool(tool) {
|
|
23
|
-
try {
|
|
24
|
-
console.log(`[Tool Registration] Registering tool: ${tool.name}`);
|
|
25
|
-
const zodSchema = schemaConverter.toZod(tool.inputSchema);
|
|
26
|
-
const handler = tool.handler;
|
|
27
|
-
this.server.tool(tool.name, tool.description || '', zodSchema.shape, async (args, extra) => {
|
|
28
|
-
const result = await handler(args, extra);
|
|
29
|
-
return {
|
|
30
|
-
content: [
|
|
31
|
-
{
|
|
32
|
-
type: 'text',
|
|
33
|
-
text: JSON.stringify(result),
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
console.log(`[Tool Registration] Successfully registered: ${tool.name}`);
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
console.error(`[Tool Registration] Failed to register tool ${tool.name}:`, error);
|
|
42
|
-
throw error;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
initializeTools() {
|
|
46
|
-
console.log(`[Server] Initializing ${this.tools.length} tools...`);
|
|
47
|
-
for (const tool of this.tools) {
|
|
48
|
-
this.registerTool(tool);
|
|
49
|
-
}
|
|
50
|
-
console.log('[Server] Tool initialization completed successfully');
|
|
51
|
-
}
|
|
52
|
-
async start() {
|
|
53
|
-
try {
|
|
54
|
-
this.initializeTools();
|
|
55
|
-
await this.server.connect(this.transport);
|
|
56
|
-
console.log('[Server] MCP Utility Server is running');
|
|
57
|
-
console.log('[Server] Available tools:', this.tools.map((t) => t.name).join(', '));
|
|
58
|
-
// Handle termination signals
|
|
59
|
-
process.on('SIGTERM', () => this.cleanup());
|
|
60
|
-
process.on('SIGINT', () => this.cleanup());
|
|
61
|
-
// Handle stdin close
|
|
62
|
-
process.stdin.on('close', () => {
|
|
63
|
-
console.log('[Server] Input stream closed');
|
|
64
|
-
this.cleanup();
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
console.error('[Server] Failed to start MCP Utility Server:', error);
|
|
69
|
-
throw error;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
async cleanup() {
|
|
73
|
-
try {
|
|
74
|
-
await this.transport.close();
|
|
75
|
-
console.log('[Server] MCP Utility Server stopped gracefully');
|
|
76
|
-
process.exit(0);
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
console.error('[Server] Error during cleanup:', error);
|
|
80
|
-
process.exit(1);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// Auto-start server if this is the main module
|
|
85
|
-
if (import.meta.url === new URL(import.meta.url).href) {
|
|
86
|
-
const server = new McpUtilityServer();
|
|
87
|
-
server.start().catch((error) => {
|
|
88
|
-
console.error('[Server] Fatal error:', error);
|
|
89
|
-
process.exit(1);
|
|
90
|
-
});
|
|
91
|
-
}
|