update_file_name
Change file names within QuantConnect projects to organize trading strategies and research files for better project management.
Instructions
Update the name of a file in a QuantConnect project.
Args: project_id: ID of the project containing the file old_file_name: Current name of the file new_name: New name for the file
Returns: Dictionary containing update result
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | ||
| old_file_name | Yes | ||
| new_name | Yes |
Implementation Reference
- The core handler function for the 'update_file_name' tool. It is decorated with @mcp.tool() for automatic registration and implements the file renaming logic via QuantConnect API.@mcp.tool() async def update_file_name( project_id: int, old_file_name: str, new_name: str ) -> Dict[str, Any]: """ Update the name of a file in a QuantConnect project. Args: project_id: ID of the project containing the file old_file_name: Current name of the file new_name: New name for the file Returns: Dictionary containing update 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, "oldFileName": old_file_name, "newName": new_name, } # Make API request response = await auth.make_authenticated_request( endpoint="files/update", 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, "old_name": old_file_name, "new_name": new_name, "message": f"Successfully renamed file from '{old_file_name}' to '{new_name}' in project {project_id}", } else: # API returned success=false errors = data.get("errors", ["Unknown error"]) return { "status": "error", "error": "File name update failed", "details": errors, "project_id": project_id, "old_name": old_file_name, "new_name": new_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 update file name: {str(e)}", "project_id": project_id, "old_name": old_file_name, "new_name": new_name, }
- quantconnect_mcp/main.py:49-49 (registration)Invocation of register_file_tools(mcp) which defines and registers the update_file_name tool among file management tools.register_file_tools(mcp)
- quantconnect_mcp/src/server.py:76-76 (registration)Invocation of register_file_tools(mcp) in the server initialization, which defines and registers the update_file_name tool.register_file_tools(mcp)