{"record":{"id":"c5e5852025bd03f5","repo":"paperclipai/paperclip","slug":"mcp-remote-invalid-json","errorCode":"mcp_remote_invalid_json","errorMessage":"Remote MCP server returned invalid JSON","messagePattern":"Remote MCP server returned invalid JSON","errorType":"http","errorClass":"ToolGatewayHttpError","httpStatus":502,"severity":"error","filePath":"server/src/services/tool-gateway.ts","lineNumber":3118,"sourceCode":"    const href = `/${company?.issuePrefix ?? \"\"}/apps/${connection.id}/setup`;\n    const idempotencyKey = `connection-delegation:${connection.id}:${userId}:${session.agentId}`;\n    const payload = {\n      version: 1 as const,\n      prompt: `Allow this agent to use your ${connection.name} account for autonomous runs`,\n      acceptLabel: \"Review delegation\",\n      rejectLabel: \"Not now\",\n      detailsMarkdown: \"This autonomous run is paused. Paperclip will not use your personal identity until you explicitly delegate it to this named agent.\",\n      target: {\n        type: \"custom\" as const,\n        key: `connection:${connection.uid}:delegation:${userId}:${session.agentId}`,\n        revisionId: connection.updatedAt.toISOString(),\n        label: `Delegate ${connection.name}`,\n        href,\n      },\n    };\n    const [existing] = await db.select({ id: issueThreadInteractions.id }).from(issueThreadInteractions).where(and(\n      eq(issueThreadInteractions.companyId, session.companyId),\n      eq(issueThreadInteractions.issueId, session.issueId),\n      eq(issueThreadInteractions.idempotencyKey, idempotencyKey),\n    )).limit(1);\n    if (existing) {\n      await db.update(issueThreadInteractions).set({\n        status: \"pending\",\n        continuationPolicy: \"wake_assignee\",\n        requestedResolverPolicy: \"human_only\",\n        effectiveResolverPolicy: \"human_only\",\n        resolverPolicyProvenance: \"explicit\",\n        effectiveResolverPolicySource: \"requested\",\n        addresseeUserId: userId,\n        payload,\n        result: null,\n        resolvedAt: null,\n        updatedAt: new Date(),\n      }).where(eq(issueThreadInteractions.id, existing.id));\n      return;\n    }","sourceCodeStart":3100,"sourceCodeEnd":3136,"githubUrl":"https://github.com/paperclipai/paperclip/blob/5716fe907e596ce73501408fc6efdb19fb61edf2/server/src/services/tool-gateway.ts#L3100-L3136","documentation":"Remote MCP response body could not be parsed as JSON (or the content-type Negotiation failed in parseMcpHttpResponseBody). The connection is marked unhealthy and a 502 mcp_remote_invalid_json is thrown with the execution context; the upstream server returned a malformed or non-JSON payload such as an HTML error page.","triggerScenarios":"Thrown at server/src/services/tool-gateway.ts:3118 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The remote MCP server returned malformed JSON. Verify the endpoint speaks MCP/JSON-RPC and inspect the raw response."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5716fe907e596ce73501408fc6efdb19fb61edf2","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}