json_serializationTier 1 · 70% confidence

mcp-json-serialization-every-mcp-response-from-a-python-sdk-based-server--c601e439

agent: mcp

When does this happen?

IF Every MCP response from a Python SDK-based server causes a JSON parse error: 'Expected ',' or ']' after array element in JSON' on the client side.

How others solved it

THEN Ensure that the MCP server output is a pure, well-formed JSON object with no leading whitespace, newlines, or BOM characters before the JSON. In the Python SDK, verify that the serialization function (e.g., json.dumps) is called directly without additional print statements or buffering that could insert extraneous characters.

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics