Skip to main content
Glama

canvas_get_module_item

Retrieve detailed information about a specific module item in a Canvas course by providing the course, module, and item IDs. Facilitates precise module management and content organization in the Learning Management System.

Instructions

Get details of a specific module item

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
course_idYesID of the course
item_idYesID of the module item
module_idYesID of the module

Implementation Reference

  • src/index.ts:492-504 (registration)
    Tool registration in the TOOLS array, including name, description, and input schema for validation. Used by MCP ListToolsRequestHandler.
    {
      name: "canvas_get_module_item",
      description: "Get details of a specific module item",
      inputSchema: {
        type: "object",
        properties: {
          course_id: { type: "number", description: "ID of the course" },
          module_id: { type: "number", description: "ID of the module" },
          item_id: { type: "number", description: "ID of the module item" }
        },
        required: ["course_id", "module_id", "item_id"]
      }
    },
  • Executes the Canvas API call to retrieve specific module item details, including content_details. Called by the MCP tool handler.
    async getModuleItem(courseId: number, moduleId: number, itemId: number): Promise<CanvasModuleItem> {
      const response = await this.client.get(`/courses/${courseId}/modules/${moduleId}/items/${itemId}`, {
        params: {
          include: ['content_details']
        }
      });
      return response.data;
    }
  • TypeScript interface defining the structure of CanvasModuleItem response data.
    export interface CanvasModuleItem {
      id: number;
      title: string;
      type: CanvasModuleItemType;
      module_id: number;
      position: number;
      indent: number;
      html_url: string;
      url?: string;
      page_url?: string;
      external_url?: string;
      content_id?: number;
      content_details?: CanvasModuleItemContentDetails;
      completion_requirement?: CanvasModuleItemCompletionRequirement;
      published: boolean;
    }
  • src/index.ts:1071-1073 (registration)
    Registers the list of tools (including canvas_get_module_item) with the MCP server for tool discovery.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: TOOLS
    }));
  • MCP CallToolRequestHandler with switch dispatching tool calls. The case for 'canvas_get_module_item' extracts args and calls client.getModuleItem, formats response.
      this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
        try {
          const args = request.params.arguments || {};
          const toolName = request.params.name;
          
          console.error(`[Canvas MCP] Executing tool: ${toolName}`);
          
          switch (toolName) {
            // Health check
            case "canvas_health_check": {
              const health = await this.client.healthCheck();
              return {
                content: [{ type: "text", text: JSON.stringify(health, null, 2) }]
              };
            }
    
            // Course management
            case "canvas_list_courses": {
              const { include_ended = false } = args as { include_ended?: boolean };
              const courses = await this.client.listCourses(include_ended);
              return {
                content: [{ type: "text", text: JSON.stringify(courses, null, 2) }]
              };
            }
    
            case "canvas_get_course": {
              const { course_id } = args as { course_id: number };
              if (!course_id) throw new Error("Missing required field: course_id");
              
              const course = await this.client.getCourse(course_id);
              return {
                content: [{ type: "text", text: JSON.stringify(course, null, 2) }]
              };
            }
            
            case "canvas_create_course": {
              const courseArgs = args as unknown as CreateCourseArgs;
              if (!courseArgs.account_id || !courseArgs.name) {
                throw new Error("Missing required fields: account_id and name");
              }
              const course = await this.client.createCourse(courseArgs);
              return {
                content: [{ type: "text", text: JSON.stringify(course, null, 2) }]
              };
            }
            
            case "canvas_update_course": {
              const updateArgs = args as unknown as UpdateCourseArgs;
              if (!updateArgs.course_id) {
                throw new Error("Missing required field: course_id");
              }
              const updatedCourse = await this.client.updateCourse(updateArgs);
              return {
                content: [{ type: "text", text: JSON.stringify(updatedCourse, null, 2) }]
              };
            }
    
            // Assignment management
            case "canvas_list_assignments": {
              const { course_id, include_submissions = false } = args as { 
                course_id: number; 
                include_submissions?: boolean 
              };
              if (!course_id) throw new Error("Missing required field: course_id");
              
              const assignments = await this.client.listAssignments(course_id, include_submissions);
              return {
                content: [{ type: "text", text: JSON.stringify(assignments, null, 2) }]
              };
            }
    
            case "canvas_get_assignment": {
              const { course_id, assignment_id, include_submission = false } = args as { 
                course_id: number; 
                assignment_id: number;
                include_submission?: boolean;
              };
              if (!course_id || !assignment_id) {
                throw new Error("Missing required fields: course_id and assignment_id");
              }
              
              const assignment = await this.client.getAssignment(course_id, assignment_id, include_submission);
              return {
                content: [{ type: "text", text: JSON.stringify(assignment, null, 2) }]
              };
            }
            
            case "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) }]
              };
            }
            
            case "canvas_update_assignment": {
              const updateAssignmentArgs = args as unknown as UpdateAssignmentArgs;
              if (!updateAssignmentArgs.course_id || !updateAssignmentArgs.assignment_id) {
                throw new Error("Missing required fields: course_id and assignment_id");
              }
              const updatedAssignment = await this.client.updateAssignment(updateAssignmentArgs);
              return {
                content: [{ type: "text", text: JSON.stringify(updatedAssignment, null, 2) }]
              };
            }
    
            case "canvas_list_assignment_groups": {
              const { course_id } = args as { course_id: number };
              if (!course_id) throw new Error("Missing required field: course_id");
              
              const groups = await this.client.listAssignmentGroups(course_id);
              return {
                content: [{ type: "text", text: JSON.stringify(groups, null, 2) }]
              };
            }
    
            // Submissions
            case "canvas_get_submission": {
              const { course_id, assignment_id, user_id } = args as { 
                course_id: number; 
                assignment_id: number;
                user_id?: number;
              };
              if (!course_id || !assignment_id) {
                throw new Error("Missing required fields: course_id and assignment_id");
              }
              
              const submission = await this.client.getSubmission(course_id, assignment_id, user_id || 'self');
              return {
                content: [{ type: "text", text: JSON.stringify(submission, null, 2) }]
              };
            }
    
            case "canvas_submit_assignment": {
              const submitArgs = args as unknown as SubmitAssignmentArgs;
              const { course_id, assignment_id, submission_type } = submitArgs;
    
              if (!course_id || !assignment_id || !submission_type) {
                throw new Error("Missing required fields: course_id, assignment_id, and submission_type");
              }
    
              const submission = await this.client.submitAssignment(submitArgs);
              return {
                content: [{ type: "text", text: JSON.stringify(submission, null, 2) }]
              };
            }
            
            case "canvas_submit_grade": {
              const gradeArgs = args as unknown as SubmitGradeArgs;
              if (!gradeArgs.course_id || !gradeArgs.assignment_id || 
                  !gradeArgs.user_id || gradeArgs.grade === undefined) {
                throw new Error("Missing required fields for grade submission");
              }
              const submission = await this.client.submitGrade(gradeArgs);
              return {
                content: [{ type: "text", text: JSON.stringify(submission, null, 2) }]
              };
            }
    
            // Files
            case "canvas_list_files": {
              const { course_id, folder_id } = args as { course_id: number; folder_id?: number };
              if (!course_id) throw new Error("Missing required field: course_id");
              
              const files = await this.client.listFiles(course_id, folder_id);
              return {
                content: [{ type: "text", text: JSON.stringify(files, null, 2) }]
              };
            }
    
            case "canvas_get_file": {
              const { file_id } = args as { file_id: number };
              if (!file_id) throw new Error("Missing required field: file_id");
              
              const file = await this.client.getFile(file_id);
              return {
                content: [{ type: "text", text: JSON.stringify(file, null, 2) }]
              };
            }
    
            case "canvas_list_folders": {
              const { course_id } = args as { course_id: number };
              if (!course_id) throw new Error("Missing required field: course_id");
              
              const folders = await this.client.listFolders(course_id);
              return {
                content: [{ type: "text", text: JSON.stringify(folders, null, 2) }]
              };
            }
    
            // Pages
            case "canvas_list_pages": {
              const { course_id } = args as { course_id: number };
              if (!course_id) throw new Error("Missing required field: course_id");
              
              const pages = await this.client.listPages(course_id);
              return {
                content: [{ type: "text", text: JSON.stringify(pages, null, 2) }]
              };
            }
    
            case "canvas_get_page": {
              const { course_id, page_url } = args as { course_id: number; page_url: string };
              if (!course_id || !page_url) {
                throw new Error("Missing required fields: course_id and page_url");
              }
              
              const page = await this.client.getPage(course_id, page_url);
              return {
                content: [{ type: "text", text: JSON.stringify(page, null, 2) }]
              };
            }
    
            // Calendar
            case "canvas_list_calendar_events": {
              const { start_date, end_date } = args as { start_date?: string; end_date?: string };
              const events = await this.client.listCalendarEvents(start_date, end_date);
              return {
                content: [{ type: "text", text: JSON.stringify(events, null, 2) }]
              };
            }
    
            case "canvas_get_upcoming_assignments": {
              const { limit = 10 } = args as { limit?: number };
              const assignments = await this.client.getUpcomingAssignments(limit);
              return {
                content: [{ type: "text", text: JSON.stringify(assignments, null, 2) }]
              };
            }
    
            // Dashboard
            case "canvas_get_dashboard": {
              const dashboard = await this.client.getDashboard();
              return {
                content: [{ type: "text", text: JSON.stringify(dashboard, null, 2) }]
              };
            }
    
            case "canvas_get_dashboard_cards": {
              const cards = await this.client.getDashboardCards();
              return {
                content: [{ type: "text", text: JSON.stringify(cards, null, 2) }]
              };
            }
    
            // User management
            case "canvas_get_user_profile": {
              const profile = await this.client.getUserProfile();
              return {
                content: [{ type: "text", text: JSON.stringify(profile, null, 2) }]
              };
            }
    
            case "canvas_update_user_profile": {
              const profileData = args as Partial<{ name: string; short_name: string; bio: string; title: string; time_zone: string }>;
              const updatedProfile = await this.client.updateUserProfile(profileData);
              return {
                content: [{ type: "text", text: JSON.stringify(updatedProfile, null, 2) }]
              };
            }
    
            case "canvas_enroll_user": {
              const enrollArgs = args as unknown as EnrollUserArgs;
              if (!enrollArgs.course_id || !enrollArgs.user_id) {
                throw new Error("Missing required fields: course_id and user_id");
              }
              const enrollment = await this.client.enrollUser(enrollArgs);
              return {
                content: [{ type: "text", text: JSON.stringify(enrollment, null, 2) }]
              };
            }
    
            // Grades
            case "canvas_get_course_grades": {
              const { course_id } = args as { course_id: number };
              if (!course_id) throw new Error("Missing required field: course_id");
              
              const grades = await this.client.getCourseGrades(course_id);
              return {
                content: [{ type: "text", text: JSON.stringify(grades, null, 2) }]
              };
            }
    
            case "canvas_get_user_grades": {
              const grades = await this.client.getUserGrades();
              return {
                content: [{ type: "text", text: JSON.stringify(grades, null, 2) }]
              };
            }
    
            // Continue with all other tools...
            // [I'll include the rest in the same pattern]
            
            // Account Management
            case "canvas_get_account": {
              const { account_id } = args as { account_id: number };
              if (!account_id) throw new Error("Missing required field: account_id");
              
              const account = await this.client.getAccount(account_id);
              return {
                content: [{ type: "text", text: JSON.stringify(account, null, 2) }]
              };
            }
    
            case "canvas_list_account_courses": {
              const accountCoursesArgs = args as unknown as ListAccountCoursesArgs;
              if (!accountCoursesArgs.account_id) {
                throw new Error("Missing required field: account_id");
              }
              
              const courses = await this.client.listAccountCourses(accountCoursesArgs);
              return {
                content: [{ type: "text", text: JSON.stringify(courses, null, 2) }]
              };
            }
    
            case "canvas_list_account_users": {
              const accountUsersArgs = args as unknown as ListAccountUsersArgs;
              if (!accountUsersArgs.account_id) {
                throw new Error("Missing required field: account_id");
              }
              
              const users = await this.client.listAccountUsers(accountUsersArgs);
              return {
                content: [{ type: "text", text: JSON.stringify(users, null, 2) }]
              };
            }
    
            case "canvas_create_user": {
              const createUserArgs = args as unknown as CreateUserArgs;
              if (!createUserArgs.account_id || !createUserArgs.user || !createUserArgs.pseudonym) {
                throw new Error("Missing required fields: account_id, user, and pseudonym");
              }
              
              const user = await this.client.createUser(createUserArgs);
              return {
                content: [{ type: "text", text: JSON.stringify(user, null, 2) }]
              };
            }
    
            case "canvas_list_sub_accounts": {
              const { account_id } = args as { account_id: number };
              if (!account_id) throw new Error("Missing required field: account_id");
              
              const subAccounts = await this.client.listSubAccounts(account_id);
              return {
                content: [{ type: "text", text: JSON.stringify(subAccounts, null, 2) }]
              };
            }
    
            case "canvas_get_account_reports": {
              const { account_id } = args as { account_id: number };
              if (!account_id) throw new Error("Missing required field: account_id");
              
              const reports = await this.client.getAccountReports(account_id);
              return {
                content: [{ type: "text", text: JSON.stringify(reports, null, 2) }]
              };
            }
    
            case "canvas_create_account_report": {
              const createReportArgs = args as unknown as CreateReportArgs;
              if (!createReportArgs.account_id || !createReportArgs.report) {
                throw new Error("Missing required fields: account_id and report");
              }
              
              const report = await this.client.createAccountReport(createReportArgs);
              return {
                content: [{ type: "text", text: JSON.stringify(report, null, 2) }]
              };
            }
            
            default:
              throw new Error(`Unknown tool: ${toolName}`);
          }
        } catch (error) {
          console.error(`Error executing tool ${request.params.name}:`, error);
          return {
            content: [{
              type: "text",
              text: `Error: ${error instanceof Error ? error.message : String(error)}`
            }],
            isError: true
          };
        }
      });
    }
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 a read operation ('Get'), implying it's non-destructive, but doesn't disclose behavioral traits like authentication needs, rate limits, error conditions, or what 'details' include. For a tool with zero annotation coverage, this leaves significant gaps in understanding how it behaves.

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

Conciseness5/5

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

The description is a single, efficient sentence that front-loads the core action ('Get details'). There is zero waste—every word contributes directly to stating the purpose without redundancy or unnecessary elaboration.

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 moderate complexity (3 required parameters) and no annotations or output schema, the description is minimally adequate. It states what the tool does but lacks context on behavior, output format, or usage scenarios. It meets the bare minimum for a read operation but doesn't compensate for missing structured data.

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 100%, with clear parameter descriptions (e.g., 'ID of the course'). The description adds no additional meaning beyond the schema, such as explaining relationships between parameters or format specifics. Baseline 3 is appropriate when the schema does the heavy lifting, but no extra value is added.

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 verb ('Get') and resource ('details of a specific module item'), making the purpose unambiguous. It distinguishes from siblings like 'canvas_get_module' (which gets the module itself) and 'canvas_list_module_items' (which lists multiple items). However, it doesn't specify what details are retrieved, keeping it from 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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites (e.g., needing course/module/item IDs) or contrast it with related tools like 'canvas_list_module_items' for browsing or 'canvas_get_module' for module-level details. Usage is implied but not explicitly stated.

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

Related 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/DMontgomery40/mcp-canvas-lms'

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