{"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":4150,"sourceCode":"        refHash: input.refHash,\n        versionSelector: String(versionSelector),\n        resolvedVersion: -1,\n      };\n    }\n  }\n\n  async function connectedCredentialVersionSnapshots(\n    connection: typeof toolConnections.$inferSelect,\n    grant: typeof connectionGrants.$inferSelect,\n    options: { requireResolved: boolean },\n  ): Promise<{\n    headerCredentialVersions: ConnectedCredentialVersionSnapshot[];\n    credentialSecretVersions: ConnectedCredentialVersionSnapshot[];\n  }> {\n    const headerCredentialVersions: ConnectedCredentialVersionSnapshot[] = [];\n    const credentialSecretVersions: ConnectedCredentialVersionSnapshot[] = [];\n\n    for (const ref of connection.credentialRefs ?? []) {\n      if (ref.placement !== \"header\" && ref.placement !== \"url\") continue;\n      const typedRef = ref as McpConnectionCredentialRef;\n      const grantRef = grantRefForCredential(grant, typedRef);\n      if (!grantRef) continue;\n      const configPath =\n        typedRef.placement === \"url\"\n          ? REMOTE_URL_SECRET_CONFIG_PATH\n          : `credentials.${typedRef.name}`;\n      headerCredentialVersions.push(\n        await resolveConnectedCredentialVersion(connection, {\n          secretId: grantRef.secretId,\n          versionSelector: grantRef.versionSelector,\n          configPath,\n          refHash: credentialVersionRefHash({\n            kind: typedRef.placement === \"url\" ? \"url\" : \"header\",\n            name: typedRef.name,\n            secretId: grantRef.secretId,\n            placement: typedRef.placement,","sourceCodeStart":4132,"sourceCodeEnd":4168,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/server/src/services/tool-gateway.ts#L4132-L4168","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":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}