{"record":{"id":"5142640ac9e2e72b","repo":"ComposioHQ/composio","slug":"failed-to-delete-mcp-server-server-id","errorCode":null,"errorMessage":"Failed to delete MCP server {server_id}","messagePattern":"Failed to delete MCP server (.+?)","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"python/composio/core/models/mcp.py","lineNumber":438,"sourceCode":"        Example:\n            >>> # Delete a server\n            >>> result = composio.experimental.mcp.delete('mcp_12345')\n            >>>\n            >>> if result['deleted']:\n            ...     print(f\"Server {result['id']} has been successfully deleted\")\n            >>> else:\n            ...     print(f\"Failed to delete server {result['id']}\")\n        \"\"\"\n        try:\n            response = self._client.mcp.delete(server_id)\n\n            return {\n                \"id\": server_id,\n                \"deleted\": getattr(response, \"deleted\", True),\n            }\n\n        except Exception as e:\n            raise ValidationError(f\"Failed to delete MCP server {server_id}\") from e\n\n    def generate(\n        self,\n        user_id: str,\n        mcp_config_id: str,\n        manually_manage_connections: t.Optional[bool] = None,\n    ) -> MCPServerInstance:\n        \"\"\"\n        Get server URLs for an existing MCP server.\n\n        This matches the TypeScript implementation exactly.\n\n        :param user_id: External user ID from your database\n        :param mcp_config_id: MCP configuration ID\n        :param manually_manage_connections: Whether to manually manage connections (optional)\n        :return: MCP server instance\n\n        Example:","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/python/composio/core/models/mcp.py#L420-L456","documentation":"Raised when the delete call for an MCP server config fails at the HTTP/client level. On success the method returns {'id': server_id, 'deleted': ...}; any exception before that is wrapped into ValidationError with the server_id included.","triggerScenarios":"Calling composio.mcp.delete(server_id) for an already-deleted or nonexistent server, or when auth/network causes the delete request to raise.","commonSituations":"Double-deleting (UI + SDK), deleting a config referenced by an active session, wrong workspace API key.","solutions":["Check e.__cause__ for HTTP status; 404 means already deleted","List servers first to confirm the ID is present","Ensure the config is not in use by an active tool-router/MCP session before deleting"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"ids = {s.id for s in composio.mcp.list()}\nassert server_id in ids","typeGuard":null,"tryCatchPattern":"try:\n    composio.mcp.delete(server_id)\nexcept ValidationError as e:\n    if getattr(e.__cause__, 'status_code', None) == 404:\n        return  # already gone\n    raise","preventionTips":["Treat 404 delete as idempotent success","Detach sessions before deleting"],"tags":["mcp","python","delete","api-error"],"backgroundTag":"api-request-failed","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}