MCP server fails to start on Windows due to path comparison bug
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 72.8k
- Forks
- 8.6k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 82
Description
Bug Description
The MCP server silently fails to start on Windows when running npx claude-flow mcp start. The server process spawns but exits immediately without doing anything.
Root Cause
In src/mcp/mcp-server.js at line 2637, the entry point check uses an incorrect file URL format:
if (import.meta.url === `file://${process.argv[1]}`) {
startMCPServer().catch(console.error);
}
This fails on Windows because:
import.meta.urlreturns a proper file URL like:file:///C:/Users/username/path/to/mcp-server.js- But
`file://${process.argv[1]}`creates:file://C:\Users\username\path\to\mcp-server.js
The differences:
- File URLs require 3 slashes (
file:///) for absolute paths, not 2 (file://) - Windows paths use backslashes (
\) but URLs use forward slashes (/) - Backslashes in template literals are interpreted as escape sequences (e.g.,
\tbecomes a tab)
As a result, the comparison always fails on Windows, startMCPServer() is never called, and the server silently exits.
Environment
- OS: Windows 11
- Node.js: v22.18.0
- claude-flow version: 2.7.47
Fix
The fix is straightforward - use Node's pathToFileURL function for proper cross-platform path handling:
1. Update the import (line 10):
// Before:
import { fileURLToPath } from 'url';
// After:
import { fileURLToPath, pathToFileURL } from 'url';
2. Fix the entry point check (line 2637):
// Before:
if (import.meta.url === `file://${process.argv[1]}`) {
startMCPServer().catch(console.error);
}
// After:
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
startMCPServer().catch(console.error);
}
Verification
After applying the fix, the server starts correctly:
[2025-12-21T20:20:02.428Z] INFO [claude-flow-mcp] Claude-Flow MCP server starting in stdio mode
{"arch":"x64","mode":"mcp-stdio","nodeVersion":"v22.18.0","pid":36928,"platform":"win32","protocol":"stdio","sessionId":"session-cf-1766348402427-4q1l","version":"2.7.47"}
{"jsonrpc":"2.0","method":"server.initialized","params":{"serverInfo":{"name":"claude-flow","version":"2.7.47",...}}}
[2025-12-21T20:20:02.437Z] INFO [claude-flow-mcp] Shared memory store initialized (same as npx)
[2025-12-21T20:20:02.437Z] INFO [claude-flow-mcp] Using SQLite storage
Additional Notes
This same pattern issue may exist in other files. A quick search for similar patterns would be advisable:
grep -r 'file://\${process.argv' src/
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/mcp/mcp-server.js at the import near line 10 and the entry-point check near line 2637; review Node's pathToFileURL behavior and search for similar patterns with grep -r 'file://${process.argv' src/. Done means the MCP server starts under Windows and the existing entry-point behavior remains valid on other platforms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100