tool_rename_assignment
Change the title of an existing assignment on Gradescope to update course materials or correct naming errors.
Instructions
Rename an assignment on Gradescope.
Requires instructor or TA access.
Args:
course_id: The Gradescope course ID.
assignment_id: The assignment ID.
new_title: The new title for the assignment.
confirm_write: Must be True to perform the rename.Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| course_id | Yes | ||
| assignment_id | Yes | ||
| new_title | Yes | ||
| confirm_write | No |
Implementation Reference
- src/gradescope_mcp/server.py:223-239 (handler)The MCP tool definition and registration for tool_rename_assignment.
def tool_rename_assignment( course_id: str, assignment_id: str, new_title: str, confirm_write: bool = False, ) -> str: """Rename an assignment on Gradescope. Requires instructor or TA access. Args: course_id: The Gradescope course ID. assignment_id: The assignment ID. new_title: The new title for the assignment. confirm_write: Must be True to perform the rename. """ return rename_assignment(course_id, assignment_id, new_title, confirm_write) - The core implementation logic for renaming an assignment, which interfaces with the Gradescope API.
def rename_assignment( course_id: str, assignment_id: str, new_title: str, confirm_write: bool = False, ) -> str: """Rename an assignment. Args: course_id: The Gradescope course ID. assignment_id: The assignment ID. new_title: The new title for the assignment. Cannot be all whitespace. confirm_write: Must be True to perform the rename. """ if not all([course_id, assignment_id, new_title]): return "Error: course_id, assignment_id, and new_title are all required." if not new_title.strip(): return "Error: new_title cannot be all whitespace." if not confirm_write: return write_confirmation_required( "rename_assignment", [ f"course_id=`{course_id}`", f"assignment_id=`{assignment_id}`", f"new_title={new_title}", ], ) try: conn = get_connection() success = update_assignment_title( session=conn.session, course_id=course_id, assignment_id=assignment_id, assignment_name=new_title, ) except AuthError as e: return f"Authentication error: {e}" except Exception as e: error_msg = str(e) if "invalid" in error_msg.lower(): return f"Error: The title '{new_title}' is invalid." return f"Error renaming assignment: {e}" if success: return f"✅ Assignment `{assignment_id}` renamed to '{new_title}'." else: return f"❌ Failed to rename assignment `{assignment_id}`. Check your permissions."