@@ -96,6 +96,13 @@ server.tool(
96
96
async ( { packages } ) => {
97
97
logger . info ( `Received request for ${ packages . length } packages` ) ;
98
98
99
+ const SOCKET_HEADERS = {
100
+ "user-agent" : `socket-mcp/${ VERSION } ` ,
101
+ "accept" : "application/x-ndjson" ,
102
+ "content-type" : "application/json" ,
103
+ "authorization" : `Bearer ${ SOCKET_API_KEY } `
104
+ } ;
105
+
99
106
// Build components array for the API request
100
107
const components = packages . map ( pkg => {
101
108
const cleanedVersion = pkg . version . replace ( / [ \^ ~ ] / g, '' ) ; // Remove ^ and ~ from version
@@ -124,14 +131,14 @@ server.tool(
124
131
logger . error ( errorMsg ) ;
125
132
return {
126
133
content : [ { type : "text" , text : errorMsg } ] ,
127
- isError : false
134
+ isError : true
128
135
} ;
129
136
} else if ( ! responseText . trim ( ) ) {
130
137
const errorMsg = `No packages were found.` ;
131
138
logger . error ( errorMsg ) ;
132
139
return {
133
140
content : [ { type : "text" , text : errorMsg } ] ,
134
- isError : false
141
+ isError : true
135
142
} ;
136
143
}
137
144
@@ -230,14 +237,6 @@ if (!SOCKET_API_KEY) {
230
237
}
231
238
}
232
239
233
- // Now that we have the API key, set up the headers
234
- const SOCKET_HEADERS = {
235
- "user-agent" : `socket-mcp/${ VERSION } ` ,
236
- "accept" : "application/x-ndjson" ,
237
- "content-type" : "application/json" ,
238
- "authorization" : `Bearer ${ SOCKET_API_KEY } `
239
- } ;
240
-
241
240
if ( useHttp ) {
242
241
// HTTP mode with Server-Sent Events
243
242
logger . info ( `Starting HTTP server on port ${ port } ` ) ;
@@ -268,7 +267,7 @@ if (useHttp) {
268
267
return ;
269
268
}
270
269
271
- if ( url . pathname === '/mcp ' ) {
270
+ if ( url . pathname === '/' ) {
272
271
if ( req . method === 'POST' ) {
273
272
// Handle JSON-RPC messages
274
273
let body = '' ;
@@ -366,7 +365,7 @@ if (useHttp) {
366
365
367
366
httpServer . listen ( port , ( ) => {
368
367
logger . info ( `Socket MCP HTTP server version ${ VERSION } started successfully on port ${ port } ` ) ;
369
- logger . info ( `Connect to: http://localhost:${ port } /mcp ` ) ;
368
+ logger . info ( `Connect to: http://localhost:${ port } /` ) ;
370
369
} ) ;
371
370
372
371
} else {
0 commit comments