@letoribo/mcp-graphql-enhanced 3.5.0 → 3.5.1
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/dist/index.js +26 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -375,18 +375,38 @@ async function handleHttpRequest(req, res) {
|
|
|
375
375
|
}
|
|
376
376
|
// --- STARTUP ---
|
|
377
377
|
async function main() {
|
|
378
|
-
|
|
378
|
+
const rawEnableHttp = process.env.ENABLE_HTTP;
|
|
379
|
+
// Determine if we should open the HTTP port.
|
|
380
|
+
// 1. Check if we're not running inside the MCP Inspector.
|
|
381
|
+
// 2. Ensure the user hasn't explicitly disabled HTTP (ENABLE_HTTP="false").
|
|
382
|
+
const isInspector = !!(process.env.MCP_INSPECTOR || process.env.INSPECTOR_PORT);
|
|
383
|
+
const shouldOpenPort = rawEnableHttp !== "false" && !isInspector;
|
|
384
|
+
if (shouldOpenPort) {
|
|
379
385
|
const serverHttp = node_http_1.default.createServer(handleHttpRequest);
|
|
386
|
+
// Error handling to prevent crashes if the port is already in use
|
|
387
|
+
serverHttp.on('error', (e) => {
|
|
388
|
+
if (e.code !== 'EADDRINUSE')
|
|
389
|
+
console.error(`[HTTP-ERROR] ${e.message}`);
|
|
390
|
+
});
|
|
380
391
|
serverHttp.listen(env.MCP_PORT, () => {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
392
|
+
// Log URLs only if HTTP is explicitly enabled
|
|
393
|
+
if (env.ENABLE_HTTP === true) {
|
|
394
|
+
console.error(`[HTTP] Server started on http://localhost:${env.MCP_PORT}`);
|
|
395
|
+
console.error(`🎨 GraphiQL IDE: http://localhost:${env.MCP_PORT}/graphiql`);
|
|
396
|
+
}
|
|
397
|
+
console.error(`🤖 MCP Endpoint: http://localhost:${env.MCP_PORT}/mcp`);
|
|
384
398
|
});
|
|
385
399
|
}
|
|
386
400
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
387
401
|
await server.connect(transport);
|
|
388
|
-
|
|
389
|
-
|
|
402
|
+
// Maintain quiet mode when running inside the Inspector to avoid protocol interference
|
|
403
|
+
if (!isInspector) {
|
|
404
|
+
console.error(`[STDIO] MCP Server "${env.NAME}" v${getVersion()} started`);
|
|
405
|
+
}
|
|
406
|
+
getSchema().catch(e => {
|
|
407
|
+
if (!isInspector)
|
|
408
|
+
console.error(`[SCHEMA] Warning: ${e.message}`);
|
|
409
|
+
});
|
|
390
410
|
}
|
|
391
411
|
process.on('SIGINT', () => process.exit(0));
|
|
392
412
|
process.on('SIGTERM', () => process.exit(0));
|
package/package.json
CHANGED