-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Error from MCP server: SyntaxError: Unexpected token 'E', "Error: typ"... is not valid JSON #409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I encountered the same issue. The error message I got was (like yours): It seems related to the following error: In my case, the problem was that the required packages weren’t installed in the environment I was using. I resolved it by running: pip install -U mcp[cli]
pip install -U typer After that, everything worked as expected. For reference, here are the package versions I'm using:
Another common possibility is a Python version mismatch: |
I'm also facing similar issues
|
Got the same error on mac, python=3.11.11
|
Any solutions? I got the same problem as @wyxpku .... |
modelcontextprotocol/inspector#295 someone fixed it, but not merged yet |
We're waiting for steps to reproduce. |
OBSERVATIONS
OUTPUT RELEVANT TO THIS ISSUE
CONCLUSIONWhat's happening is that something other than a valid JSONRPCMessage is being emitted from those servers on STDOUT. They are writing plain error or log messages. The spec for STDIO servers says:
If you want to log messages from your STDIO server, you can do that on on STDERR. |
Got it working using the venv generated by : (see here uv init mcp-server-demo
cd mcp-server-demo/
uv add "mcp[cli]"
mcp dev mcp-server-demo.py After that I can connect to http://127.0.0.1:6274 and test the server. The server has to be launched in the correct environment. This is also true when using |
When i run the app with
cmd = mcp dev server.py
then when i click on connect button i got this issue
Stdio transport: command=C:\Users\User\AppData\Local\Programs\Python\Python310\Scripts\uv.exe, args=run,--with,mcp,mcp,run,server.py
Spawned stdio transport
Connected MCP client to backing server transport
Created web app transport
Created web app transport
Set up MCP proxy
Error from MCP server: SyntaxError: Unexpected token 'E', "Error: typ"... is not valid JSON
at JSON.parse ()
at deserializeMessage (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js:26:44)
at ReadBuffer.readMessage (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js:19:16)
at StdioClientTransport.processReadBuffer (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js:114:50)
at Socket. (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js:93:22)
at Socket.emit (node:events:518:28)
at addChunk (node:internal/streams/readable:561:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
at Readable.push (node:internal/streams/readable:392:5)
at Pipe.onStreamRead (node:internal/stream_base_commons:189:23)
Error from MCP server: SyntaxError: Unexpected token 'E', "Error: typ"... is not valid JSON
at JSON.parse ()
at deserializeMessage (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js:26:44)
at ReadBuffer.readMessage (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js:19:16)
at StdioClientTransport.processReadBuffer (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js:114:50)
at Socket. (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js:93:22)
at Socket.emit (node:events:518:28)
at addChunk (node:internal/streams/readable:561:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
at Readable.push (node:internal/streams/readable:392:5)
at Pipe.onStreamRead (node:internal/stream_base_commons:189:23)
Error from MCP server: SyntaxError: Unexpected token 'E', "Error: typ"... is not valid JSON
at JSON.parse ()
at deserializeMessage (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js:26:44)
at ReadBuffer.readMessage (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js:19:16)
at StdioClientTransport.processReadBuffer (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js:114:50)
at Socket. (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js:93:22)
at Socket.emit (node:events:518:28)
at addChunk (node:internal/streams/readable:561:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
at Readable.push (node:internal/streams/readable:392:5)
at Pipe.onStreamRead (node:internal/stream_base_commons:189:23)
Error from MCP server: SyntaxError: Unexpected token 'E', "Error: typ"... is not valid JSON
at JSON.parse ()
at deserializeMessage (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js:26:44)
at ReadBuffer.readMessage (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js:19:16)
at StdioClientTransport.processReadBuffer (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js:114:50)
at Socket. (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js:93:22)
at Socket.emit (node:events:518:28)
at addChunk (node:internal/streams/readable:561:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
at Readable.push (node:internal/streams/readable:392:5)
at Pipe.onStreamRead (node:internal/stream_base_commons:189:23)
Error from MCP server: SyntaxError: Unexpected token 'E', "Error: typ"... is not valid JSON
at JSON.parse ()
at deserializeMessage (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js:26:44)
at ReadBuffer.readMessage (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js:19:16)
at StdioClientTransport.processReadBuffer (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js:114:50)
at Socket. (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js:93:22)
at Socket.emit (node:events:518:28)
at addChunk (node:internal/streams/readable:561:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
at Readable.push (node:internal/streams/readable:392:5)
at Pipe.onStreamRead (node:internal/stream_base_commons:189:23)
Received message for sessionId ac082c68-292e-4cbd-b85e-42046b434b38
Error in /message route: Error: SSE connection not established
at SSEServerTransport.handlePostMessage (file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sse.js:53:19)
at file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/inspector/server/build/index.js:129:25
at Layer.handle [as handle_request] (C:\Users\User\AppData\Local\npm-cache_npx\5a9d879542beca3a\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\User\AppData\Local\npm-cache_npx\5a9d879542beca3a\node_modules\express\lib\router\route.js:149:13)
at Route.dispatch (C:\Users\User\AppData\Local\npm-cache_npx\5a9d879542beca3a\node_modules\express\lib\router\route.js:119:3)
at Layer.handle [as handle_request] (C:\Users\User\AppData\Local\npm-cache_npx\5a9d879542beca3a\node_modules\express\lib\router\layer.js:95:5)
at C:\Users\User\AppData\Local\npm-cache_npx\5a9d879542beca3a\node_modules\express\lib\router\index.js:284:15
at Function.process_params (C:\Users\User\AppData\Local\npm-cache_npx\5a9d879542beca3a\node_modules\express\lib\router\index.js:346:12)
at next (C:\Users\User\AppData\Local\npm-cache_npx\5a9d879542beca3a\node_modules\express\lib\router\index.js:280:10)
at cors (C:\Users\User\AppData\Local\npm-cache_npx\5a9d879542beca3a\node_modules\cors\lib\index.js:188:7)
node:_http_outgoing:699
throw new ERR_HTTP_HEADERS_SENT('set');
^
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ServerResponse.setHeader (node:_http_outgoing:699:11)
at ServerResponse.header (C:\Users\User\AppData\Local\npm-cache_npx\5a9d879542beca3a\node_modules\express\lib\response.js:794:10)
at ServerResponse.json (C:\Users\User\AppData\Local\npm-cache_npx\5a9d879542beca3a\node_modules\express\lib\response.js:275:10)
at file:///C:/Users/User/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/inspector/server/build/index.js:133:25
at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
code: 'ERR_HTTP_HEADERS_SENT'
}
Node.js v22.14.0
The text was updated successfully, but these errors were encountered: