Skip to main content
Glama

update_file_content

Modify file content in QuantConnect projects to update trading strategies, algorithms, or research documents.

Instructions

Update the content of a file in a QuantConnect project.

Args: project_id: ID of the project containing the file name: Name of the file to update content: New content for the file

Returns: Dictionary containing update result

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
nameYes
contentYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'update_file_content' tool, decorated with @mcp.tool() and implementing the logic to update file content in a QuantConnect project via authenticated API request.
    @mcp.tool()
    async def update_file_content(
        project_id: int, name: str, content: str
    ) -> Dict[str, Any]:
        """
        Update the content of a file in a QuantConnect project.
    
        Args:
            project_id: ID of the project containing the file
            name: Name of the file to update
            content: New content 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, "name": name, "content": content}
    
            # 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,
                        "file_name": name,
                        "content_length": len(content),
                        "message": f"Successfully updated content of file '{name}' in project {project_id}",
                    }
                else:
                    # API returned success=false
                    errors = data.get("errors", ["Unknown error"])
                    return {
                        "status": "error",
                        "error": "File content update 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 update file content: {str(e)}",
                "project_id": project_id,
                "file_name": name,
            }
  • Entry point registration block calling register_file_tools(mcp), which registers the update_file_content tool among file tools.
    safe_print("🔧 Registering QuantConnect tools...")
    register_auth_tools(mcp)
    register_project_tools(mcp)
    register_file_tools(mcp)
    register_backtest_tools(mcp)
    register_live_tools(mcp)
    register_optimization_tools(mcp)
  • Server core registration block calling register_file_tools(mcp) to register the file tools including update_file_content.
    safe_print("🔧 Registering QuantConnect tools...")
    register_auth_tools(mcp)
    register_project_tools(mcp)
    register_file_tools(mcp)
    register_backtest_tools(mcp)
    register_live_tools(mcp)
    register_optimization_tools(mcp)
  • The register_file_tools function definition, which contains the @mcp.tool() decorators for all file tools including update_file_content.
    def register_file_tools(mcp: FastMCP):
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states this is an update operation (implies mutation) but doesn't disclose behavioral traits like whether it overwrites or merges content, permission requirements, rate limits, or what the 'update result' contains. The description is minimal beyond basic functionality.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with a clear purpose statement followed by parameter and return documentation. It's front-loaded with the core functionality. The Args/Returns sections are structured but could be more integrated with the main description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, 0% schema coverage, but an output schema exists (so return values are documented elsewhere), the description is minimally complete. It covers what the tool does and parameters but lacks behavioral context, error handling, and usage guidance needed for a mutation tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description provides basic semantics for all 3 parameters (project_id, name, content). However, it doesn't add meaningful context beyond what's evident from parameter names (e.g., format of project_id, file naming conventions, content encoding). With 0% schema coverage, this is adequate but not comprehensive.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool updates file content in a QuantConnect project with specific parameters. It distinguishes from siblings like 'update_file_name' (which modifies metadata) and 'create_file' (which creates new files), but doesn't explicitly contrast with 'read_file' or other file operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like 'create_file' or 'delete_file'. The description doesn't mention prerequisites (e.g., file must exist) or error conditions (e.g., what happens if file doesn't exist).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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