ComposioHQ/composio · error · ValidationError

Failed to delete MCP server {server_id}

Error message

Failed to delete MCP server {server_id}

What it means

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.

Source

Thrown at python/composio/core/models/mcp.py:438

        Example:
            >>> # Delete a server
            >>> result = composio.experimental.mcp.delete('mcp_12345')
            >>>
            >>> if result['deleted']:
            ...     print(f"Server {result['id']} has been successfully deleted")
            >>> else:
            ...     print(f"Failed to delete server {result['id']}")
        """
        try:
            response = self._client.mcp.delete(server_id)

            return {
                "id": server_id,
                "deleted": getattr(response, "deleted", True),
            }

        except Exception as e:
            raise ValidationError(f"Failed to delete MCP server {server_id}") from e

    def generate(
        self,
        user_id: str,
        mcp_config_id: str,
        manually_manage_connections: t.Optional[bool] = None,
    ) -> MCPServerInstance:
        """
        Get server URLs for an existing MCP server.

        This matches the TypeScript implementation exactly.

        :param user_id: External user ID from your database
        :param mcp_config_id: MCP configuration ID
        :param manually_manage_connections: Whether to manually manage connections (optional)
        :return: MCP server instance

        Example:

View on GitHub (pinned to 64b1b85502)

Solutions

  1. Check e.__cause__ for HTTP status; 404 means already deleted
  2. List servers first to confirm the ID is present
  3. Ensure the config is not in use by an active tool-router/MCP session before deleting
Defensive patterns

Strategy: try-catch

Validate before calling

ids = {s.id for s in composio.mcp.list()}
assert server_id in ids

Try / catch

try:
    composio.mcp.delete(server_id)
except ValidationError as e:
    if getattr(e.__cause__, 'status_code', None) == 404:
        return  # already gone
    raise

Prevention

When it happens

Trigger: Calling composio.mcp.delete(server_id) for an already-deleted or nonexistent server, or when auth/network causes the delete request to raise.

Common situations: Double-deleting (UI + SDK), deleting a config referenced by an active session, wrong workspace API key.

Related errors


AI-assisted analysis of ComposioHQ/composio@64b1b85502 (2026-08-28). Data as JSON: /api/errors/5142640ac9e2e72b. Report an issue: GitHub.