different-ai/openwork · error · Error
Failed to inspect MCP tools (${response.status}).
Error message
Failed to inspect MCP tools (${response.status}). What it means
Thrown by useMcpConnectionTools when GET /v1/mcp-connections/:id/tools returns a non-ok status (30000ms timeout). getRequestError reports the server's error message or 'Failed to inspect MCP tools (<status>)'. The inspection then cannot produce a tool catalog or a parsed ExternalMcpToolPolicy.
Source
Thrown at ee/apps/den-web/app/(den)/dashboard/_components/mcp-connections-data.tsx:307
disabledTools: value.disabledTools,
updatedBy: value.updatedBy,
updatedAt: value.updatedAt,
};
}
export function useMcpConnectionTools(connectionId: string, enabled: boolean) {
const { orgId } = useOrgDashboard();
return useQuery({
enabled: enabled && Boolean(orgId),
queryKey: mcpConnectionQueryKeys.tools(orgId, connectionId),
queryFn: async (): Promise<ExternalMcpToolCatalog> => {
const { response, payload } = await requestJson(
`/v1/mcp-connections/${encodeURIComponent(connectionId)}/tools`,
{ headers: getOrgScopeHeaders(requireOrgId(orgId)) },
30000,
);
if (!response.ok) {
throw getRequestError(payload, response, `Failed to inspect MCP tools (${response.status}).`);
}
if (!isRecord(payload) || !Array.isArray(payload.tools)) {
throw new Error("MCP tool catalog response was incomplete.");
}
const policy = parseExternalMcpToolPolicy(payload.policy);
if (!policy || !payload.tools.every(isExternalMcpTool)) {
throw new Error("MCP tool catalog response was incomplete.");
}
return { tools: payload.tools, policy };
},
});
}
export function useUpdateMcpConnectionToolPolicy(connectionId: string) {
const queryClient = useQueryClient();
const { orgId } = useOrgDashboard();
return useMutation({
mutationFn: async (input: Pick<ExternalMcpToolPolicyView, "allDisabled" | "disabledTools">): Promise<ExternalMcpToolPolicyView> => {View on GitHub (pinned to 2b7df46e8a)
Solutions
- For 401/403, re-authenticate and ensure a valid org id is passed (requireOrgId throws earlier if absent).
- For 404, refresh the connections list; the connection was deleted or the id is stale.
- For 502/504/timeout, verify the remote MCP server is reachable/healthy and retry; consider raising the timeout.
- For 5xx, retry with backoff and inspect Den server logs.
- Handle isReauthRequiredError to start the re-auth flow.
Example fix
// before
const { data } = useMcpConnectionTools(orgId, connectionId);
// after
const { data, error } = useMcpConnectionTools(orgId, connectionId);
if (error) {
if (isReauthRequiredError(error)) startReauth();
else if (/\((404)\)/.test(error.message)) refetchConnections();
else showError(error.message);
} Defensive patterns
Strategy: retry
Validate before calling
// before fetching tools
if (!orgId) throw new Error("Select an organization first");
if (!connections.some(c => c.id === connectionId)) throw new Error("Unknown MCP connection"); Type guard
function isTransientToolError(err: unknown): boolean {
return err instanceof Error && /\((502|503|504|408)\)/.test(err.message);
} Try / catch
useQuery({
queryKey: mcpConnectionQueryKeys.tools(orgId, connectionId),
queryFn: () => fetchTools(),
retry: (count, err) => count < 2 && isTransientToolError(err),
}); Prevention
- Ensure the remote MCP server is healthy before running tool inspection
- Keep connection lists fresh so stale ids are not inspected
- Always supply the org id for scope headers
- Use TanStack Query retry for 5xx/timeout statuses only
When it happens
Trigger: Non-ok response when fetching the tool catalog for a connection: 401/403 when org scope headers (requireOrgId(orgId)) are missing or the user lacks access to the connection, 404 when the connection id is wrong or removed, 408/504 when the remote MCP server is slow to enumerate tools (30s timeout exceeded server-side), 502 when the upstream MCP server is unreachable from Den, 5xx server faults.
Common situations: Inspecting a connection whose remote MCP server is offline or slow; deleted/stale connection row in the UI; missing org selection so scope headers are invalid; remote server auth (OAuth) expired so Den cannot list its tools.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Failed to configure plugin connection (${response.status}).
- Failed to update MCP tool policy (${response.status}).
- Failed to load MCP connectors (${response.status}).
- Failed to load MCP presets (${response.status}).
- Failed to look up the MCP server (${response.status}).
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/e6d614fed3959c06.
Report an issue: GitHub.