Skip to main content
Glama

create_file

Add a new file to a QuantConnect project by specifying project ID, filename, and content for algorithmic trading strategy development.

Instructions

Create a new file in a QuantConnect project.

Args: project_id: ID of the project to add the file to name: Name of the file (e.g., "main.py", "algorithm.cs") content: Content of the file

Returns: Dictionary containing file creation 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 'create_file' tool. It authenticates with QuantConnect, sends a POST request to the 'files/create' endpoint with project_id, name, and content, and returns a status dictionary based on the response.
    @mcp.tool()
    async def create_file(project_id: int, name: str, content: str) -> Dict[str, Any]:
        """
        Create a new file in a QuantConnect project.
    
        Args:
            project_id: ID of the project to add the file to
            name: Name of the file (e.g., "main.py", "algorithm.cs")
            content: Content of the file
    
        Returns:
            Dictionary containing file creation 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/create", 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 created file '{name}' in project {project_id}",
                    }
                else:
                    # API returned success=false
                    errors = data.get("errors", ["Unknown error"])
                    return {
                        "status": "error",
                        "error": "File creation 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 create file: {str(e)}",
                "project_id": project_id,
                "file_name": name,
            }
  • Top-level registration call in the main entry point that invokes register_file_tools to add the create_file tool (among others) to the MCP server.
    register_file_tools(mcp)
  • Registration call in the server module's main function, which registers the file tools including create_file.
    register_file_tools(mcp)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('Create a new file') but lacks critical details: it doesn't specify required permissions, whether the operation is idempotent, potential side effects (e.g., overwriting existing files), rate limits, or error conditions. The mention of 'Returns: Dictionary containing file creation result' is vague and doesn't clarify output behavior. This leaves significant gaps for a mutation tool.

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 well-structured and appropriately sized. It starts with a clear purpose statement, followed by a bullet-point list for parameters and returns, making it easy to scan. Every sentence adds value, with no redundant information. A slight improvement could be integrating the parameter explanations more seamlessly, but it's highly efficient overall.

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 the complexity (a mutation tool with 3 parameters, no annotations, but an output schema exists), the description is moderately complete. It covers the basic purpose and parameters but lacks behavioral context like permissions or error handling. The output schema should handle return values, so the vague 'Returns' statement is acceptable. However, for a creation tool in a collaborative environment, more guidance on usage and constraints would enhance completeness.

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

Parameters4/5

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

The description adds meaningful semantics beyond the input schema, which has 0% description coverage. It explains each parameter's purpose: 'project_id: ID of the project to add the file to', 'name: Name of the file (e.g., "main.py", "algorithm.cs")', and 'content: Content of the file'. The examples for 'name' are particularly helpful. Since the schema lacks descriptions, this compensates well, though it could detail constraints like file naming rules.

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's purpose: 'Create a new file in a QuantConnect project.' It specifies the verb ('Create') and resource ('file'), and while it doesn't explicitly differentiate from siblings like 'update_file_content' or 'delete_file', the action is distinct enough given the context of file operations. However, it lacks explicit sibling comparison, preventing a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing project), exclusions, or comparisons to siblings like 'update_file_content' or 'read_file'. Without such context, the agent must infer usage from the tool name alone, which is insufficient for optimal selection.

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