{"record":{"id":"4dd5805ad0180ef8","repo":"different-ai/openwork","slug":"internalerror","errorCode":"InternalError","errorMessage":"This MCP connection needs to be reconnected in OpenWork. (or) This MCP tool catalog could not be loaded. Retry the request.","messagePattern":"This MCP connection needs to be reconnected in OpenWork\\. \\(or\\) This MCP tool catalog could not be loaded\\. Retry the request\\.","errorType":"error_code","errorClass":"McpError","httpStatus":null,"severity":"error","filePath":"apps/server/src/local-managed-mcp.ts","lineNumber":1268,"sourceCode":"  const stored = await withVaultRead(config, (vault) => requireConnection(vault, workspaceId, name));\n  if (!stored.enabled) {\n    return new Response(JSON.stringify({ error: \"connection_disabled\" }), {\n      status: 503,\n      headers: { \"content-type\": \"application/json\" },\n    });\n  }\n  const redirectUri = localManagedMcpCallbackUrl(config);\n  const server = new Server(\n    { name: `openwork-local-${name}`, version: \"1.0.0\" },\n    { capabilities: { tools: {} } },\n  );\n  server.setRequestHandler(ListToolsRequestSchema, async () => {\n    try {\n      const connection = await enterpriseConnection(config, workspaceId, name);\n      return { tools: await enterpriseClient().listTools({ connection, redirectUri }) };\n    } catch (error) {\n      const reconnect = await markReconnectWhenCredentialIsGone(config, workspaceId, name, error, \"Tool discovery failed\");\n      throw new McpError(\n        ErrorCode.InternalError,\n        reconnect\n          ? \"This MCP connection needs to be reconnected in OpenWork.\"\n          : \"This MCP tool catalog could not be loaded. Retry the request.\",\n      );\n    }\n  });\n  server.setRequestHandler(CallToolRequestSchema, async (call) => {\n    try {\n      const connection = await enterpriseConnection(config, workspaceId, name);\n      const args = call.params.arguments ?? {};\n      return await enterpriseClient().callTool({\n        connection,\n        redirectUri,\n        toolName: call.params.name,\n        arguments: args,\n      });\n    } catch (error) {","sourceCodeStart":1250,"sourceCodeEnd":1286,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/server/src/local-managed-mcp.ts#L1250-L1286","documentation":"The ListTools handler for a managed enterprise MCP connection wraps any failure from resolving the connection or fetching its tool catalog into an MCP InternalError. If markReconnectWhenCredentialIsGone detects the stored credential is missing/revoked, the message tells the user to reconnect; otherwise it is a transient catalog-load failure the client should retry.","triggerScenarios":"Sending tools/list to the managed MCP server when enterpriseConnection() fails (connection not found, vault read failure, upstream provider error) or enterpriseClient().listTools() throws; credential explicitly missing/expired yields the reconnect variant.","commonSituations":"OAuth token for the upstream MCP provider expired or was revoked; user deleted the connection's credential; upstream provider is down or rate-limiting; connection renamed in OpenWork while a client session is open.","solutions":["Check the connection status in OpenWork and re-run its OAuth connect flow if credentials are missing or revoked.","Retry tools/list — the fallback message explicitly indicates a transient failure.","Verify the workspaceId/name used to connect still matches an existing enterprise connection.","Inspect server logs for 'Tool discovery failed' to see the underlying error from the upstream provider."],"exampleFix":"// before\nconst tools = await client.listTools() // throws InternalError, catalog gone\n// after\nif (await connectionNeedsReconnect(connection)) await reconnectManagedMcp(connection)\nconst tools = await client.listTools()","handlingStrategy":"retry","validationCode":"const conn = await getManagedMcpConnection(workspaceId, name)\nif (!conn || conn.status !== 'connected') throw new Error('connection missing or disconnected — reconnect first')","typeGuard":"function isConnected(conn: { status?: string } | null | undefined): conn is { status: 'connected' } {\n  return conn?.status === 'connected'\n}","tryCatchPattern":"try {\n  tools = await client.listTools()\n} catch (e) {\n  if (e instanceof McpError && e.code === ErrorCode.InternalError && /reconnected in OpenWork/.test(e.message)) {\n    await promptUserToReconnect(name)\n  } else if (e instanceof McpError && e.code === ErrorCode.InternalError) {\n    await backoffRetry(() => client.listTools(), 3)\n  } else throw e\n}","preventionTips":["Monitor token expiry and refresh/reconnect before sessions start failing","Keep connection names/workspaces stable while clients are connected","Add exponential backoff for transient catalog-load failures","Alert on server-side 'Tool discovery failed' log lines"],"tags":["mcp","tool-discovery","credential-expired","internal-error"],"backgroundTag":"mcp-connection-reconnect-required","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}