`PYTHONIOENCODING` needs to be set for fetch server on Windows
OS: Windows 10 Using: Claude Desktop App MCP: Fetch Issue: Timeout
Happens every time I use the MCP
config file:
{
"mcpServers": {
"fetch-uvx": {
"command": "uvx",
"args": [
"mcp-server-fetch",
"--ignore-robots-txt"
]
}
}
}
Inspector logs:
[server] 'PORT' is not recognized as an internal or external command,
[server] operable program or batch file.
[server] PORT= node C:\Users\Jaco\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\@modelcontextprotocol\inspector\server\build\index.js --env uvx --args="mcp-server-fetch" exited with code 1
[server] PORT= node C:\Users\Jaco\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\@modelcontextprotocol\inspector\server\build\index.js --env uvx --args="mcp-server-fetch" restarted
[client] 'PORT' is not recognized as an internal or external command,
[client] operable program or batch file.
[client] PORT= node C:\Users\Jaco\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\@modelcontextprotocol\inspector\client\bin\cli.js exited with code 1
[server] 'PORT' is not recognized as an internal or external command,
[server] operable program or batch file.
[client] PORT= node C:\Users\Jaco\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\@modelcontextprotocol\inspector\client\bin\cli.js restarted
[server] PORT= node C:\Users\Jaco\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\@modelcontextprotocol\inspector\server\build\index.js --env uvx --args="mcp-server-fetch" exited with code 1
[server] PORT= node C:\Users\Jaco\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\@modelcontextprotocol\inspector\server\build\index.js --env uvx --args="mcp-server-fetch" restarted
[client] 'PORT' is not recognized as an internal or external command,
[client] operable program or batch file.
[client] PORT= node C:\Users\Jaco\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\@modelcontextprotocol\inspector\client\bin\cli.js exited with code 1
[server] 'PORT' is not recognized as an internal or external command,
[server] operable program or batch file.
[client] PORT= node C:\Users\Jaco\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\@modelcontextprotocol\inspector\client\bin\cli.js restarted
[server] PORT= node C:\Users\Jaco\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\@modelcontextprotocol\inspector\server\build\index.js --env uvx --args="mcp-server-fetch" exited with code 1
[client] 'PORT' is not recognized as an internal or external command,
[client] operable program or batch file.
[server] PORT= node C:\Users\Jaco\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\@modelcontextprotocol\inspector\server\build\index.js --env uvx --args="mcp-server-fetch" restarted
[client] PORT= node C:\Users\Jaco\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\@modelcontextprotocol\inspector\client\bin\cli.js exited with code 1
[client] PORT= node C:\Users\Jaco\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\@modelcontextprotocol\inspector\client\bin\cli.js restarted
[server] 'PORT' is not recognized as an internal or external command,
[server] operable program or batch file.
[server] PORT= node C:\Users\Jaco\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\@modelcontextprotocol\inspector\server\build\index.js --env uvx --args="mcp-server-fetch" exited with code 1
--> Sending SIGTERM to other processes..
[client] 'PORT' is not recognized as an internal or external command,
[client] operable program or batch file.
[client] PORT= node C:\Users\Jaco\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\@modelcontextprotocol\inspector\client\bin\cli.js exited with code 1
An error occurred: [
{
command: Command {
killProcess: [Function (anonymous)],
spawn: [Function: spawn],
spawnOpts: [Object],
index: 0,
name: 'server',
command: 'PORT= node C:\\Users\\Jaco\\AppData\\Local\\npm-cache\\_npx\\5a9d879542beca3a\\node_modules\\@modelcontextprotocol\\inspector\\server\\build\\index.js --env uvx --args="mcp-server-fetch"',
prefixColor: '',
env: {},
cwd: '',
ipc: undefined,
close: [Subject],
error: [Subject],
stdout: [Subject],
stderr: [Subject],
timer: [Subject],
messages: [Object],
process: undefined,
subscriptions: [],
stdin: [Socket],
pid: 24504,
killed: false,
exited: false,
state: 'exited'
},
index: 0,
exitCode: 1,
killed: false,
timings: {
startDate: 2024-11-26T18:27:37.383Z,
endDate: 2024-11-26T18:27:37.393Z,
durationSeconds: 0.0092797
}
},
{
command: Command {
killProcess: [Function (anonymous)],
spawn: [Function: spawn],
spawnOpts: [Object],
index: 1,
name: 'client',
command: 'PORT= node C:\\Users\\Jaco\\AppData\\Local\\npm-cache\\_npx\\5a9d879542beca3a\\node_modules\\@modelcontextprotocol\\inspector\\client\\bin\\cli.js',
prefixColor: '',
env: {},
cwd: '',
ipc: undefined,
close: [Subject],
error: [Subject],
stdout: [Subject],
stderr: [Subject],
timer: [Subject],
messages: [Object],
process: undefined,
subscriptions: [],
stdin: [Socket],
pid: 7024,
killed: true,
exited: false,
state: 'exited'
},
index: 1,
exitCode: 1,
killed: true,
timings: {
startDate: 2024-11-26T18:27:37.391Z,
endDate: 2024-11-26T18:27:37.404Z,
durationSeconds: 0.0133724
}
}
]
Potentially related https://github.com/modelcontextprotocol/servers/issues/37 It fixed fetch for me.
{
"mcpServers": {
"fetch": {
"command": "/path/to/uvx",
"args": ["--python", "/path/to/python", "mcp-server-fetch"]
}
}
}
Potentially related #37 It fixed fetch for me.
{ "mcpServers": { "fetch": { "command": "/path/to/uvx", "args": ["--python", "/path/to/python", "mcp-server-fetch"] } } }
Thanks for the reply, Issue persists on my side. Claude recognizes the MCP but I get the timeout error
Potentially related #37 It fixed fetch for me.
{ "mcpServers": { "fetch": { "command": "/path/to/uvx", "args": ["--python", "/path/to/python", "mcp-server-fetch"] } } }Thanks for the reply, Issue persists on my side. Claude recognizes the MCP but I get the timeout error
"fetch": {
"command": "uvx",
"args": ["mcp-server-fetch"],
"env": {
"PYTHONIOENCODING": "utf-8"
}
}
same problem,what about now?
Potentially related #37 It fixed fetch for me.
{ "mcpServers": { "fetch": { "command": "/path/to/uvx", "args": ["--python", "/path/to/python", "mcp-server-fetch"] } } }Thanks for the reply, Issue persists on my side. Claude recognizes the MCP but I get the timeout error
"fetch": { "command": "uvx", "args": ["mcp-server-fetch"], "env": { "PYTHONIOENCODING": "utf-8" } }
This fixed it for me. Thanks for sharing.
@claude could you investigate whether this would still happen in the current version of the fetch server, and make a suggestion on how we could resolve it if its still a valid issue? If its not relevant anymore, then we should close it.
Claude finished @olaservo's task —— View job
Investigation: PYTHONIOENCODING Windows Issue Analysis
I'll investigate whether the PYTHONIOENCODING timeout issue still affects the current fetch server and recommend a solution.
Todo List:
- [x] Investigate current fetch server implementation for encoding issues
- [x] Check if PYTHONIOENCODING issue still exists in current version
- [x] Review Windows-specific configurations and documentation
- [x] Provide recommendation on resolution or issue closure
Analysis Results
After reviewing the current fetch server implementation and the reported issue, here are my findings:
Technical Analysis
Current Implementation
The current fetch server (v0.6.3) is a Python-based MCP server that:
- Uses
httpxfor HTTP requests with async/await pattern - Uses
stdio_server()from mcp.server.stdio for input/output communication - Has proper error handling and timeout management (30s timeout)
- Implements robust content processing with readabilipy and markdownify
Issue Root Cause
The original issue appears to be related to:
- Character encoding problems on Windows: Python's default encoding behavior on Windows can cause issues with stdio communication
- MCP Inspector compatibility: The error logs show the MCP Inspector having trouble with environment variable syntax on Windows (
PORT= node ...not being recognized)
Current Status
The issue likely still exists because:
- No Windows-specific encoding fixes have been implemented in the server code
- The server relies on Python's default stdio handling, which can be problematic on Windows
- No documentation exists for Windows-specific configuration
Recommendation: Keep Issue Open with Documentation Fix
This issue should remain open as it represents a legitimate Windows compatibility problem. Here's my recommended solution:
Immediate Fix (Documentation Update)
Add Windows-specific configuration guidance to the fetch server's README.md:
{
"mcpServers": {
"fetch": {
"command": "uvx",
"args": ["mcp-server-fetch"],
"env": {
"PYTHONIOENCODING": "utf-8"
}
}
}
}
Why This Fix Works
PYTHONIOENCODING=utf-8forces Python to use UTF-8 encoding for stdin/stdout/stderr- This prevents encoding-related timeout issues on Windows systems
- The fix has been confirmed working by multiple users in the issue comments
Additional Considerations
- Inspector Issues: The MCP Inspector tool also needs Windows compatibility fixes (separate issue)
- Alternative Solutions: Users can also specify explicit Python path with uvx:
--python /path/to/python - Long-term: Consider implementing explicit encoding handling in the server code
Would you like me to implement the documentation fix by updating the README.md file?
@claude yes, please update the Readme.
Claude finished @olaservo's task —— View job • claude/issue-65-20250817-1645 • Create PR ➔
Updated README with Windows Configuration Fix
Added Windows-specific documentation to address the PYTHONIOENCODING timeout issue.
Todo List:
- [x] Locate fetch server README.md file
- [x] Read current README structure and content
- [x] Add Windows troubleshooting section with PYTHONIOENCODING fix
- [x] Commit and push changes
- [x] Provide PR creation link
Changes Made
Added a new "Windows Configuration" section to /src/fetch/README.md that includes:
- Clear explanation of the Windows timeout issue
- Configuration examples for both uvx and pip installations
- Proper JSON formatting with the
PYTHONIOENCODING: utf-8environment variable - Collapsed details sections to keep the documentation clean
This matches the solution that multiple users in issue #65 confirmed as working, providing a permanent fix in the official documentation.