canvas_create_assignment
Create and configure assignments in Canvas courses with specific details like name, description, due date, points, submission types, and file extensions directly via the Canvas MCP Server V2.0.
Instructions
Create a new assignment in a Canvas course
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| allowed_extensions | No | Allowed file extensions for submissions | |
| course_id | Yes | ID of the course | |
| description | No | Assignment description/instructions | |
| due_at | No | Due date (ISO format) | |
| name | Yes | Name of the assignment | |
| points_possible | No | Maximum points possible | |
| published | No | Whether the assignment is published | |
| submission_types | No | Allowed submission types |
Implementation Reference
- src/client.ts:283-289 (handler)Core implementation of the assignment creation logic, making the POST request to Canvas API endpoint /courses/{course_id}/assignmentsasync createAssignment(args: CreateAssignmentArgs): Promise<CanvasAssignment> { const { course_id, ...assignmentData } = args; const response = await this.client.post(`/courses/${course_id}/assignments`, { assignment: assignmentData }); return response.data; }
- src/index.ts:1163-1172 (handler)MCP server tool handler for canvas_create_assignment: validates arguments and delegates to CanvasClientcase "canvas_create_assignment": { const assignmentArgs = args as unknown as CreateAssignmentArgs; if (!assignmentArgs.course_id || !assignmentArgs.name) { throw new Error("Missing required fields: course_id and name"); } const assignment = await this.client.createAssignment(assignmentArgs); return { content: [{ type: "text", text: JSON.stringify(assignment, null, 2) }] }; }
- src/index.ts:166-189 (registration)Tool registration in the TOOLS array, including name, description, and input schemaname: "canvas_create_assignment", description: "Create a new assignment in a Canvas course", inputSchema: { type: "object", properties: { course_id: { type: "number", description: "ID of the course" }, name: { type: "string", description: "Name of the assignment" }, description: { type: "string", description: "Assignment description/instructions" }, due_at: { type: "string", description: "Due date (ISO format)" }, points_possible: { type: "number", description: "Maximum points possible" }, submission_types: { type: "array", items: { type: "string" }, description: "Allowed submission types" }, allowed_extensions: { type: "array", items: { type: "string" }, description: "Allowed file extensions for submissions" }, published: { type: "boolean", description: "Whether the assignment is published" } }, required: ["course_id", "name"] }
- src/types.ts:598-618 (schema)TypeScript interface defining the structure of CreateAssignmentArgs used for type safety and validationexport interface CreateAssignmentArgs { course_id: number; name: string; description?: string; due_at?: string; lock_at?: string; unlock_at?: string; points_possible?: number; grading_type?: CanvasGradingType; submission_types?: CanvasSubmissionType[]; allowed_extensions?: string[]; assignment_group_id?: number; position?: number; peer_reviews?: boolean; automatic_peer_reviews?: boolean; notify_of_update?: boolean; group_category_id?: number; published?: boolean; omit_from_final_grade?: boolean; hide_in_gradebook?: boolean; }