Skip to main content
Glama

tool_upload_submission

Upload files to a Gradescope assignment by providing course ID, assignment ID, and file paths. Optionally set a leaderboard name and confirm the upload.

Instructions

Upload files as a submission to a Gradescope assignment.

Args:
    course_id: The Gradescope course ID.
    assignment_id: The assignment ID.
    file_paths: List of absolute file paths to upload.
    leaderboard_name: Optional leaderboard display name.
    confirm_write: Must be True to perform the upload.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
course_idYes
assignment_idYes
file_pathsYes
leaderboard_nameNo
confirm_writeNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The function `upload_submission` handles the file uploading logic to a Gradescope assignment, including validation of file paths and confirmation requirements.
    def upload_submission(
        course_id: str,
        assignment_id: str,
        file_paths: list[str],
        leaderboard_name: str | None = None,
        confirm_write: bool = False,
    ) -> str:
        """Upload files as a submission to a Gradescope assignment.
    
        Args:
            course_id: The Gradescope course ID.
            assignment_id: The assignment ID.
            file_paths: List of absolute file paths to upload.
            leaderboard_name: Optional leaderboard display name.
            confirm_write: Must be True to perform the upload.
        """
        if not course_id or not assignment_id:
            return "Error: both course_id and assignment_id are required."
    
        if not file_paths:
            return "Error: at least one file path is required."
    
        # Validate file paths
        validated_paths = []
        for fp in file_paths:
            original_path = pathlib.Path(fp)
            if not original_path.is_absolute():
                return f"Error: file path must be absolute: {fp}"
    
            path = original_path.resolve()
    
            if not path.exists():
                return f"Error: file not found: {fp}"
    
            if not path.is_file():
                return f"Error: not a file: {fp}"
    
            validated_paths.append(path)
    
        if not confirm_write:
            details = [
                f"course_id=`{course_id}`",
                f"assignment_id=`{assignment_id}`",
                f"files={', '.join(str(path) for path in validated_paths)}",
            ]
            if leaderboard_name:
                details.append(f"leaderboard_name={leaderboard_name}")
            return write_confirmation_required("upload_submission", details)
    
        try:
            conn = get_connection()
            file_handles = []
            try:
                for path in validated_paths:
                    file_handles.append(open(path, "rb"))
    
                result_url = upload_assignment(
                    session=conn.session,
                    course_id=course_id,
                    assignment_id=assignment_id,
                    *file_handles,
                    leaderboard_name=leaderboard_name,
                )
            finally:
                for fh in file_handles:
                    fh.close()
    
        except AuthError as e:
            return f"Authentication error: {e}"
        except Exception as e:
            return f"Error uploading submission: {e}"
    
        if result_url:
            filenames = [p.name for p in validated_paths]
            return (
                f"✅ Submission uploaded successfully!\n"
                f"- **Files:** {', '.join(filenames)}\n"
                f"- **Submission URL:** {result_url}"
            )
        else:
            return (
                "❌ Upload failed. Possible reasons:\n"
                "- Assignment is past the due date\n"
                "- You don't have permission to submit\n"
                "- Invalid course or assignment ID"
            )
  • The `tool_upload_submission` function registers the tool with the MCP server and calls the implementation in `submissions.py`.
    def tool_upload_submission(
        course_id: str,
        assignment_id: str,
        file_paths: list[str],
        leaderboard_name: str | None = None,
        confirm_write: bool = False,
    ) -> str:
        """Upload files as a submission to a Gradescope assignment.
    
        Args:
            course_id: The Gradescope course ID.
            assignment_id: The assignment ID.
            file_paths: List of absolute file paths to upload.
            leaderboard_name: Optional leaderboard display name.
            confirm_write: Must be True to perform the upload.
        """
        return upload_submission(
            course_id, assignment_id, file_paths, leaderboard_name, confirm_write
        )
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It implies a write operation ('Upload') and includes a 'confirm_write' parameter as a safety measure, but doesn't disclose permissions needed, rate limits, whether uploads are reversible, or what happens on success/failure. For a mutation tool with zero annotation coverage, this is inadequate.

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 efficiently structured with a clear purpose statement followed by a bullet-point-like parameter list. Every sentence serves a purpose, though the parameter explanations could be more detailed. It's appropriately sized for a 5-parameter tool.

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 tool's complexity (write operation, 5 parameters, no annotations) and the presence of an output schema (which reduces need to describe returns), the description is minimally adequate. It covers the core action and parameters but lacks behavioral context, usage guidelines, and detailed parameter semantics, leaving gaps for the agent.

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%, so the schema provides no parameter documentation. The description adds basic semantics by listing parameters with brief explanations (e.g., 'List of absolute file paths to upload'), but doesn't elaborate on formats (e.g., what constitutes a valid course_id) or constraints (e.g., file size limits). It compensates partially but not fully for the schema gap.

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 action ('Upload files') and target ('as a submission to a Gradescope assignment'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'tool_get_assignment_submissions' or 'tool_get_student_submission', which are read operations versus this write operation.

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 course/assignment access), exclusions, or comparisons to sibling tools like 'tool_assess_submission_readiness' or 'tool_export_assignment_scores'. The agent must infer usage from the purpose alone.

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/Yuanpeng-Li/gradescope-mcp'

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