@socketsecurity/mcp 0.0.9 → 0.0.10

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/index.js +17 -4
  2. package/package.json +5 -3
package/index.js CHANGED
@@ -3,7 +3,7 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
3
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
4
  import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
5
5
  import { z } from 'zod';
6
- import { pino } from 'pino';
6
+ import pino from 'pino';
7
7
  import readline from 'readline';
8
8
  import { join } from 'path';
9
9
  import { readFileSync } from 'fs';
@@ -237,7 +237,20 @@ if (useHttp) {
237
237
  res.end();
238
238
  return;
239
239
  }
240
- const url = new URL(req.url, `http://localhost:${port}`);
240
+ let url;
241
+ try {
242
+ url = new URL(req.url, `http://localhost:${port}`);
243
+ }
244
+ catch (error) {
245
+ logger.warn(`Invalid URL in request: ${req.url} - ${error}`);
246
+ res.writeHead(400, { 'Content-Type': 'application/json' });
247
+ res.end(JSON.stringify({
248
+ jsonrpc: '2.0',
249
+ error: { code: -32000, message: 'Bad Request: Invalid URL' },
250
+ id: null
251
+ }));
252
+ return;
253
+ }
241
254
  if (url.pathname === '/health') {
242
255
  res.writeHead(200, { 'Content-Type': 'application/json' });
243
256
  res.end(JSON.stringify({
@@ -400,7 +413,7 @@ if (useHttp) {
400
413
  res.write(': heartbeat\n\n');
401
414
  }
402
415
  catch (error) {
403
- logger.error(`Heartbeat error for session ${sessionId}:`, error);
416
+ logger.error(error, `Heartbeat error for session ${sessionId}:`);
404
417
  clearInterval(heartbeat);
405
418
  }
406
419
  }, 30000);
@@ -409,7 +422,7 @@ if (useHttp) {
409
422
  }
410
423
  }
411
424
  catch (error) {
412
- logger.error(`SSE transport error for session ${sessionId}:`, error);
425
+ logger.error(error, `SSE transport error for session ${sessionId}:`);
413
426
  }
414
427
  }
415
428
  else if (req.method === 'DELETE') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socketsecurity/mcp",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -21,7 +21,9 @@
21
21
  "build:types": "tsc -p tsconfig.declaration.json",
22
22
  "build:permissions": "chmod +x ./index.js && (chmod +x ./mock-client/*.js 2>/dev/null || true)",
23
23
  "build-dtx": "run-s build build-dtx:*",
24
- "build-dtx:dtx-pack": "dtx-pack ./build/index.js",
24
+ "build-dtx:versions_match": "node --experimental-strip-types scripts/check-versions.ts",
25
+ "build-dtx:validate": "npx dxt validate ./",
26
+ "build-dtx:dtx-pack": "npx dxt pack ./",
25
27
  "clean": "./scripts/clean.sh",
26
28
  "debug-stdio": "node --experimental-strip-types ./mock-client/debug-client.ts",
27
29
  "debug-sdk": "node --experimental-strip-types ./mock-client/stdio-client.ts",
@@ -58,6 +60,6 @@
58
60
  "@types/triple-beam": "^1.3.5",
59
61
  "c8": "^10.0.0",
60
62
  "npm-run-all2": "^8.0.1",
61
- "typescript": "~5.8.2"
63
+ "typescript": "~5.9.2"
62
64
  }
63
65
  }