Support windows

This fix made it work on windows for me.

based on https://stackoverflow.com/questions/34842738/if-name-main-equivalent-in-javascript-es6-modules/63193714#63193714
This commit is contained in:
Thomas Payne
2025-07-15 23:33:39 -04:00
committed by GitHub
parent a91a108a0d
commit 03a381274a
+4 -2
View File
@@ -4,6 +4,8 @@
process.env.NODE_DISABLE_COLORS = '1'; process.env.NODE_DISABLE_COLORS = '1';
process.env.NO_COLOR = '1'; process.env.NO_COLOR = '1';
import { fileURLToPath } from "url";
import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { import {
@@ -1016,11 +1018,11 @@ if (process.env.DEBUG === 'true') {
} }
// Start the server if this file is run directly // Start the server if this file is run directly
if (import.meta.url === `file://${process.argv[1]}`) { if (fileURLToPath(import.meta.url) === process.argv[1]) {
runServer().catch(error => { runServer().catch(error => {
logger.error('Failed to start server:', error); logger.error('Failed to start server:', error);
process.exit(1); process.exit(1);
}); });
} }
export default runServer; export default runServer;