@nekzus/mcp-server 1.1.6 → 1.1.7

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.
Files changed (2) hide show
  1. package/dist/index.js +41 -42
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3,8 +3,15 @@ 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
- // Logger function that uses stderr
7
- const log = (...args) => console.error(...args);
6
+ // Logger function that uses stderr - only for critical errors
7
+ const log = (...args) => {
8
+ // Filter out server status messages
9
+ const message = args[0];
10
+ if (typeof message === 'string' &&
11
+ (!message.startsWith('[Server]') || message.includes('error') || message.includes('Error'))) {
12
+ console.error(...args);
13
+ }
14
+ };
8
15
  // Define the tools once to avoid repetition
9
16
  const TOOLS = [
10
17
  {
@@ -498,65 +505,57 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
498
505
  tools: TOOLS,
499
506
  }));
500
507
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
501
- const result = await handleToolCall(request.params.name, request.params.arguments ?? {});
502
- return result;
508
+ return handleToolCall(request.params.name, request.params.arguments ?? {});
503
509
  });
504
- // Server startup
510
+ // Server startup with improved error handling
505
511
  async function runServer() {
512
+ const transport = new StdioServerTransport();
513
+ // Handle cleanup gracefully
514
+ const cleanup = async () => {
515
+ try {
516
+ await server.close();
517
+ process.exit(0);
518
+ }
519
+ catch {
520
+ process.exit(1);
521
+ }
522
+ };
506
523
  try {
507
- const transport = new StdioServerTransport();
508
- // Handle messages directly
524
+ // Handle direct messages
509
525
  process.stdin.on('data', async (data) => {
510
526
  try {
511
527
  const message = JSON.parse(data.toString());
512
528
  if (message.method === 'tools/call') {
513
529
  const result = await handleToolCall(message.params.name, message.params.arguments ?? {});
514
- const response = {
530
+ process.stdout.write(`${JSON.stringify({
515
531
  jsonrpc: '2.0',
516
532
  result,
517
533
  id: message.id,
518
- };
519
- process.stdout.write(`${JSON.stringify(response)}\n`);
534
+ })}\n`);
520
535
  }
521
536
  }
522
537
  catch (error) {
523
- log('[Server] Error processing message:', error);
538
+ if (error instanceof Error) {
539
+ process.stdout.write(`${JSON.stringify({
540
+ jsonrpc: '2.0',
541
+ error: {
542
+ code: -32000,
543
+ message: error.message,
544
+ },
545
+ })}\n`);
546
+ }
524
547
  }
525
548
  });
549
+ // Connect transport
526
550
  await server.connect(transport);
527
- log('[Server] MCP Server is running');
528
- log('[Server] Available tools:', TOOLS.map((t) => t.name).join(', '));
529
- // Handle stdin close
530
- process.stdin.on('close', async () => {
531
- log('[Server] Input stream closed');
532
- await cleanup();
533
- });
534
- // Add signal handlers for graceful shutdown
535
- process.on('SIGINT', async () => {
536
- log('[Server] Received SIGINT signal');
537
- await cleanup();
538
- });
539
- process.on('SIGTERM', async () => {
540
- log('[Server] Received SIGTERM signal');
541
- await cleanup();
542
- });
543
- }
544
- catch (error) {
545
- log('[Server] Failed to start MCP Server:', error);
546
- process.exit(1);
551
+ // Setup signal handlers
552
+ process.stdin.on('close', cleanup);
553
+ process.on('SIGINT', cleanup);
554
+ process.on('SIGTERM', cleanup);
547
555
  }
548
- }
549
- // Cleanup function
550
- async function cleanup() {
551
- try {
552
- await server.close();
553
- log('[Server] MCP Server stopped gracefully');
554
- process.exit(0);
555
- }
556
- catch (error) {
557
- log('[Server] Error during cleanup:', error);
556
+ catch {
558
557
  process.exit(1);
559
558
  }
560
559
  }
561
560
  // Start the server
562
- runServer().catch((error) => log('[Server] Unhandled error:', error));
561
+ runServer();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nekzus/mcp-server",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "Personal MCP Server implementation providing extensible utility functions and tools for development and testing purposes",
5
5
  "type": "module",
6
6
  "bin": {