Skip to content

Non-JSON output (emoji) to STDOUT breaks MCP handshake #51

@moltrus

Description

@moltrus

Bug Report: Non-JSON output (emoji) to STDOUT breaks MCP handshake

Description

When the POLYMARKET_PRIVATE_KEY environment variable is provided, the server prints a success message (✅ Trading enabled) directly to stdout. Since the Model Context Protocol (MCP) relies on stdout for JSON-RPC communication, this non-JSON string causes a SyntaxError on the client side (e.g., Claude Desktop), preventing the tools from loading.

Steps to Reproduce

  1. Install the MCP server using npx -y @iqai/mcp-polymarket.
  2. Configure the server in claude_desktop_config.json including the POLYMARKET_PRIVATE_KEY env variable.
  3. Restart the Claude Desktop app.
  4. Shows an error and does not load the trading tools

Actual Behavior

The server outputs the following string before the JSON-RPC initialization:
✅ Trading enabled

The client log shows:
[error] Unexpected token '✅', "✅ Trading "... is not valid JSON

Expected Behavior

The server should only output valid JSON-RPC messages to stdout. All log messages, success indicators, or "friendly" status updates should be directed to stderr.

Environment

  • Package Version: 0.0.16
  • OS: Windows 10
  • Client: Claude Desktop (Claude 1.1.6679 (f8f4ff))

Suggested Fix

Remove the emojies (eg: ✅ ) from logs.
I have submitted the PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions