update_file_name
Modify file names within QuantConnect projects by specifying the project ID, current file name, and desired new name. Simplifies file management for strategy design and implementation.
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 |
|---|---|---|---|
| new_name | Yes | ||
| old_file_name | Yes | ||
| project_id | Yes |
Implementation Reference
- The handler function for the 'update_file_name' tool. It authenticates with QuantConnect, prepares a request to the 'files/update' endpoint with oldFileName and newName parameters, and handles the API response to rename the file in the specified project.@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)Calls register_file_tools(mcp) which defines and registers the update_file_name tool among other file tools.register_file_tools(mcp)
- quantconnect_mcp/src/server.py:76-76 (registration)Alternative entry point calling register_file_tools(mcp) to register the file tools including update_file_name.register_file_tools(mcp)