{"record":{"id":"51788fee59673698","repo":"paperclipai/paperclip","slug":"remote-mcp-error","errorCode":"remote_mcp_error","errorMessage":"Remote MCP context request returned an error","messagePattern":"Remote MCP context request returned an error","errorType":"http","errorClass":"ToolGatewayHttpError","httpStatus":502,"severity":"error","filePath":"server/src/services/tool-gateway.ts","lineNumber":5174,"sourceCode":"      );\n    } catch {\n      throw new ToolGatewayHttpError(\n        502,\n        \"Remote MCP context response was invalid\",\n        \"mcp_remote_invalid_json\",\n        {\n          connectionId: input.connection.id,\n          method: input.method,\n        },\n      );\n    }\n    const record = asRecord(payload);\n    if (\n      !record ||\n      record.error !== undefined ||\n      !Object.prototype.hasOwnProperty.call(record, \"result\")\n    ) {\n      throw new ToolGatewayHttpError(\n        502,\n        \"Remote MCP context request returned an error\",\n        \"remote_mcp_error\",\n        {\n          connectionId: input.connection.id,\n          method: input.method,\n        },\n      );\n    }\n    await markRemoteConnectionHealth(\n      input.connection,\n      \"ok\",\n      `Remote MCP server responded to ${input.method}.`,\n    );\n    return record.result;\n  }\n\n  async function callAssignedConnectionProtocol(input: {","sourceCodeStart":5156,"sourceCodeEnd":5192,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/server/src/services/tool-gateway.ts#L5156-L5192","documentation":"Remote MCP forwarding failure wrapper: the upstream request failed at the transport/execution level (network error, malformed response, or other non-HTTP-error failure). The 502 mcp_remote_failed surfaces the underlying problem with execution details so callers can distinguish upstream failure from policy denial.","triggerScenarios":"Thrown at server/src/services/tool-gateway.ts:3133 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The remote MCP server returned a protocol error. Inspect the error code/message and fix the request or the remote server."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-09-18T08:03:59.046Z","contentChangedAt":"2026-09-18T08:03:59.046Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}