{"record":{"id":"9b85b5ca2bf8d650","repo":"paperclipai/paperclip","slug":"mcp-remote-fetch-failed","errorCode":"mcp_remote_fetch_failed","errorMessage":"Remote MCP tool call failed","messagePattern":"Remote MCP tool call failed","errorType":"http","errorClass":"ToolGatewayHttpError","httpStatus":502,"severity":"error","filePath":"server/src/services/tool-gateway.ts","lineNumber":3244,"sourceCode":"      summary: grantKind === \"organization\"\n        ? \"Organization authorization is required before this run can continue.\"\n        : \"Personal authorization is required before this run can continue.\",\n      createdByAgentId: session.agentId,\n      addresseeUserId: userId,\n      payload,\n    });\n  }\n\n  async function resolveConnectionGrant(\n    session: ToolGatewaySession,\n    connection: typeof toolConnections.$inferSelect,\n  ): Promise<typeof connectionGrants.$inferSelect> {\n    const [run] = session.runId && !session.identityContextId\n      ? await db.select({\n          responsibleUserId: heartbeatRuns.responsibleUserId,\n          invocationSource: heartbeatRuns.invocationSource,\n        }).from(heartbeatRuns).where(and(\n          eq(heartbeatRuns.id, session.runId),\n          eq(heartbeatRuns.companyId, session.companyId),\n        )).limit(1)\n      : [];\n    const actingUserId = session.identityContextId ? session.responsibleUserId ?? null : run?.responsibleUserId ?? session.responsibleUserId ?? null;\n    if (session.identityContextId && session.agentId && (\n      connection.config.sourceTemplateKey === \"github\" || connection.transportConfig?.sourceTemplateKey === \"github\"\n    )) {\n      const captured = githubOperationCredentials.get(session);\n      const selected = captured\n        ? { grant: captured.grant, error: undefined }\n        : await resolveManagedGitHubIdentitySelection(db, session.companyId, {\n          agentId: session.agentId, responsibleUserId: session.responsibleUserId, allowStandingDelegation: false,\n        });\n      if (!selected.grant || selected.grant.connectionId !== connection.id) {\n        throw new ToolGatewayHttpError(409, selected.error ?? \"GitHub identity changed; retry through the managed tool\", \"github_identity_unavailable\");\n      }\n      if (selected.grant.kind === \"user\") {\n        const [member] = await db.select({ role: companyMemberships.membershipRole }).from(companyMemberships).where(and(","sourceCodeStart":3226,"sourceCodeEnd":3262,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/tool-gateway.ts#L3226-L3262","documentation":"Catch-all in the remote MCP call path: the fetch or response handling threw a non-ToolGatewayHttpError, non-timeout exception (DNS failure, socket reset, unexpected parser crash). Connection health is marked error and the error propagates as a gateway 502 with execution details attached for diagnosis.","triggerScenarios":"Thrown at server/src/services/tool-gateway.ts:3166 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The remote MCP call failed at the transport level. Check network connectivity and remote server status, then retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}