You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Claude 3.7 fixed an issue I had with this on Macos with Claude:
Yes, you're absolutely right! This was definitely a bug in the codebase. The issue was that the MCP server was using console.log() for debugging output, which sends text to stdout (standard output). However, in the Model Context Protocol, stdout is strictly reserved for JSON communication between the client and server, while stderr (via console.error()) should be used for any logging or debugging.
Creating a GitHub issue would be very helpful for the project maintainers and other users. Here's what I'd recommend including in the issue:
Description:
When using the Wolfram Alpha MCP server with Claude, I encountered "Unexpected token" JSON parsing errors:
Unexpected token 'R', "Raw API Re"... is not valid JSON {"context":"connection","stack":"SyntaxError: Unexpected token 'R', \"Raw API Re\"... is not valid JSON\n at JSON.parse (<anonymous>)...
The issue was caused by debug logging statements using console.log() instead of console.error(). In the MCP protocol, stdout is reserved for JSON communication between client and server, while stderr should be used for logging.
Fix:
Changed the following instances from console.log() to console.error():
In src/services/wolfram-llm.ts around line 220: console.log('Raw API Response:', JSON.stringify(rawResponse, null, 2));
In src/services/wolfram-llm.ts around line 276: console.log("Simplified Raw Response:", rawResponse);
After making these changes and rebuilding, the MCP server works correctly without JSON parsing errors.
Additional context:
This is a common issue that might affect other MCP implementations as well. It would be helpful to add a note in the documentation about using console.error() instead of console.log() for debugging output in MCP servers.
The text was updated successfully, but these errors were encountered:
Claude 3.7 fixed an issue I had with this on Macos with Claude:
Yes, you're absolutely right! This was definitely a bug in the codebase. The issue was that the MCP server was using
console.log()
for debugging output, which sends text to stdout (standard output). However, in the Model Context Protocol, stdout is strictly reserved for JSON communication between the client and server, while stderr (viaconsole.error()
) should be used for any logging or debugging.Creating a GitHub issue would be very helpful for the project maintainers and other users. Here's what I'd recommend including in the issue:
Description:
When using the Wolfram Alpha MCP server with Claude, I encountered "Unexpected token" JSON parsing errors:
The issue was caused by debug logging statements using
console.log()
instead ofconsole.error()
. In the MCP protocol, stdout is reserved for JSON communication between client and server, while stderr should be used for logging.Fix:
Changed the following instances from
console.log()
toconsole.error()
:src/services/wolfram-llm.ts
around line 220:console.log('Raw API Response:', JSON.stringify(rawResponse, null, 2));
src/services/wolfram-llm.ts
around line 276:console.log("Simplified Raw Response:", rawResponse);
After making these changes and rebuilding, the MCP server works correctly without JSON parsing errors.
Additional context:
This is a common issue that might affect other MCP implementations as well. It would be helpful to add a note in the documentation about using
console.error()
instead ofconsole.log()
for debugging output in MCP servers.The text was updated successfully, but these errors were encountered: