{"record":{"id":"237ef4fda2ba3659","repo":"ComposioHQ/composio","slug":"failed-to-parse-mcp-retrieve-response","errorCode":null,"errorMessage":"Failed to parse MCP retrieve response","messagePattern":"Failed to parse MCP retrieve response","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"ts/packages/core/src/utils/transformers/mcp.ts","lineNumber":95,"sourceCode":"export function transformMcpRetrieveResponse(\n  response: McpRetrieveResponseRaw\n): McpRetrieveResponse {\n  const result = McpRetrieveResponseSchema.safeParse({\n    id: response.id,\n    name: response.name,\n    createdAt: response.created_at,\n    updatedAt: response.updated_at,\n    status: (response as unknown as Record<string, unknown>).status,\n    toolkits: response.toolkits,\n    tools: response.allowed_tools,\n    managedAuthViaComposio: response.managed_auth_via_composio,\n    authConfigIds: response.auth_config_ids,\n    mcpUrl: response.mcp_url,\n    commands: response.commands,\n  });\n\n  if (!result.success) {\n    throw new ValidationError('Failed to parse MCP retrieve response', {\n      cause: result.error,\n    });\n  }\n\n  return result.data;\n}\n\n/**\n * Transform MCP delete response from snake_case to camelCase\n */\nexport function transformMcpDeleteResponse(response: McpDeleteResponseRaw): McpDeleteResponse {\n  const result = McpDeleteResponseSchema.safeParse({\n    id: (response as unknown as Record<string, unknown>).id,\n    deleted: (response as unknown as Record<string, unknown>).deleted,\n    message: (response as unknown as Record<string, unknown>).message,\n  });\n\n  if (!result.success) {","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/core/src/utils/transformers/mcp.ts#L77-L113","documentation":"transformMcpRetrieveResponse validates a single MCP server's retrieved payload (toolkits, authConfigIds, commands, mcpUrl, etc.) against Zod; failure throws ValidationError with the parse error as cause.","triggerScenarios":"Retrieving an MCP server by id (composio.mcp.get/retrieve) where the backend response contains fields in unexpected types/shapes, e.g. commands not matching the expected schema.","commonSituations":"Version skew between SDK transformer and backend; newly introduced MCP server states or command formats; self-hosted backend with divergent contract.","solutions":["Upgrade @composio/core","Read error.cause ZodError to pinpoint the failing field","Confirm the MCP server id is valid and fully provisioned before retrieval","Report contract drift with the raw JSON if versions are aligned"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { const server = await composio.mcp.get(id); } catch (e) { if (e instanceof ValidationError && e.cause) { /* log issues, verify id, upgrade */ } throw e; }","preventionTips":["Validate MCP ids before retrieval","Upgrade @composio/core alongside backend changes","Capture raw responses in debug logs for contract-drift reports"],"tags":["mcp","validation","zod","api-mismatch"],"backgroundTag":"schema-validation-failed","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}