@socketsecurity/mcp 0.0.13 → 0.0.14

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 +25 -30
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -210,6 +210,30 @@ if (useHttp) {
210
210
  logger.info(`Starting HTTP server on port ${port}`);
211
211
  let httpTransport = null;
212
212
  const httpServer = createServer(async (req, res) => {
213
+ let url;
214
+ try {
215
+ url = new URL(req.url, `http://localhost:${port}`);
216
+ }
217
+ catch (error) {
218
+ logger.warn(`Invalid URL in request: ${req.url} - ${error}`);
219
+ res.writeHead(400, { 'Content-Type': 'application/json' });
220
+ res.end(JSON.stringify({
221
+ jsonrpc: '2.0',
222
+ error: { code: -32000, message: 'Bad Request: Invalid URL' },
223
+ id: null
224
+ }));
225
+ return;
226
+ }
227
+ if (url.pathname === '/health') {
228
+ res.writeHead(200, { 'Content-Type': 'application/json' });
229
+ res.end(JSON.stringify({
230
+ status: 'healthy',
231
+ service: 'socket-mcp',
232
+ version: VERSION,
233
+ timestamp: new Date().toISOString()
234
+ }));
235
+ return;
236
+ }
213
237
  const origin = req.headers.origin;
214
238
  const allowedOrigins = [
215
239
  'http://localhost:3000',
@@ -228,12 +252,7 @@ if (useHttp) {
228
252
  }));
229
253
  return;
230
254
  }
231
- if (origin && isValidOrigin) {
232
- res.setHeader('Access-Control-Allow-Origin', origin);
233
- }
234
- else {
235
- res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000');
236
- }
255
+ res.setHeader('Access-Control-Allow-Origin', origin);
237
256
  res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS');
238
257
  res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Accept');
239
258
  if (req.method === 'OPTIONS') {
@@ -241,30 +260,6 @@ if (useHttp) {
241
260
  res.end();
242
261
  return;
243
262
  }
244
- let url;
245
- try {
246
- url = new URL(req.url, `http://localhost:${port}`);
247
- }
248
- catch (error) {
249
- logger.warn(`Invalid URL in request: ${req.url} - ${error}`);
250
- res.writeHead(400, { 'Content-Type': 'application/json' });
251
- res.end(JSON.stringify({
252
- jsonrpc: '2.0',
253
- error: { code: -32000, message: 'Bad Request: Invalid URL' },
254
- id: null
255
- }));
256
- return;
257
- }
258
- if (url.pathname === '/health') {
259
- res.writeHead(200, { 'Content-Type': 'application/json' });
260
- res.end(JSON.stringify({
261
- status: 'healthy',
262
- service: 'socket-mcp',
263
- version: VERSION,
264
- timestamp: new Date().toISOString()
265
- }));
266
- return;
267
- }
268
263
  if (url.pathname === '/') {
269
264
  if (req.method === 'POST') {
270
265
  let body = '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socketsecurity/mcp",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {