Skip to main content
Glama

delete_file

Remove files from QuantConnect projects to manage project organization and eliminate unnecessary content.

Instructions

Delete a file from a QuantConnect project.

Args: project_id: ID of the project containing the file to delete name: Name of the file to delete

Returns: Dictionary containing deletion result

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
nameYes

Implementation Reference

  • The handler function for the 'delete_file' tool. It authenticates with QuantConnect, prepares a request with project_id and file name, sends a POST to the 'files/delete' endpoint, and returns success/error based on the response.
    @mcp.tool()
    async def delete_file(project_id: int, name: str) -> Dict[str, Any]:
        """
        Delete a file from a QuantConnect project.
    
        Args:
            project_id: ID of the project containing the file to delete
            name: Name of the file to delete
    
        Returns:
            Dictionary containing deletion result
        """
        auth = get_auth_instance()
        if auth is None:
            return {
                "status": "error",
                "error": "QuantConnect authentication not configured. Use configure_auth() first.",
            }
    
        try:
            # Prepare request data
            request_data = {"projectId": project_id, "name": name}
    
            # Make API request
            response = await auth.make_authenticated_request(
                endpoint="files/delete", method="POST", json=request_data
            )
    
            # Parse response
            if response.status_code == 200:
                data = response.json()
    
                if data.get("success", False):
                    return {
                        "status": "success",
                        "project_id": project_id,
                        "file_name": name,
                        "message": f"Successfully deleted file '{name}' from project {project_id}",
                    }
                else:
                    # API returned success=false
                    errors = data.get("errors", ["Unknown error"])
                    return {
                        "status": "error",
                        "error": "File deletion failed",
                        "details": errors,
                        "project_id": project_id,
                        "file_name": name,
                    }
    
            elif response.status_code == 401:
                return {
                    "status": "error",
                    "error": "Authentication failed. Check your credentials and ensure they haven't expired.",
                }
    
            else:
                return {
                    "status": "error",
                    "error": f"API request failed with status {response.status_code}",
                    "response_text": (
                        response.text[:500]
                        if hasattr(response, "text")
                        else "No response text"
                    ),
                }
    
        except Exception as e:
            return {
                "status": "error",
                "error": f"Failed to delete file: {str(e)}",
                "project_id": project_id,
                "file_name": name,
            }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/taylorwilsdon/quantconnect-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server