Skip to content

Commit 7782e3b

Browse files
fix: use path.resolve for robust isDirectRun comparison
Handles edge case where process.argv[1] is a relative path while import.meta.url resolves to absolute.
1 parent db855f7 commit 7782e3b

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env node
2+
import { resolve } from 'node:path';
23
import { fileURLToPath } from 'node:url';
34
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
45
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
@@ -244,7 +245,7 @@ async function main() {
244245
}
245246

246247
const currentFile = fileURLToPath(import.meta.url);
247-
const isDirectRun = process.argv[1] === currentFile;
248+
const isDirectRun = process.argv[1] && resolve(process.argv[1]) === currentFile;
248249

249250
if (isDirectRun) {
250251
main().catch((error) => {

0 commit comments

Comments
 (0)