Skip to main content
Glama

get_course_content

Retrieve assignments and resources for a specific course from the MUSTer MCP Server to access learning materials and track academic requirements.

Instructions

Get all assignments/resources for a course by exact name (call get_all_courses first).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
course_nameYesCourse name exactly as returned by get_all_courses

Implementation Reference

  • main.py:31-44 (registration)
    Registration of the MCP tool 'get_course_content' defining its name, description, and input schema.
    Tool(
        name="get_course_content",
        description="Get all assignments/resources for a course by exact name (call get_all_courses first).",
        inputSchema={
            "type": "object",
            "properties": {
                "course_name": {
                    "type": "string",
                    "description": "Course name exactly as returned by get_all_courses",
                }
            },
            "required": ["course_name"],
        },
    ),
  • main.py:35-43 (schema)
    Input schema definition for the tool, specifying 'course_name' as required string parameter.
        "type": "object",
        "properties": {
            "course_name": {
                "type": "string",
                "description": "Course name exactly as returned by get_all_courses",
            }
        },
        "required": ["course_name"],
    },
  • main.py:116-141 (handler)
    Primary MCP tool handler: resolves course by name, fetches content via MUSTerClient, formats as list of dicts with error handling.
    def tool_get_course_content(course_name: str) -> List[Dict[str, Any]]:
        try:
            all_courses = muster_client.get_courses()
    
            match = next((c for c in all_courses if c.name == course_name), None)
            if not match:
                return [{"error": f"No courses found matching '{course_name}'. Please call get_all_courses first."}]
    
            try:
                assignments = muster_client.get_course_content(match.url)
                return [
                    {
                        "name": assignment.name,
                        "type": assignment.type,
                        "url": assignment.url,
                        "course_name": match.name,
                        "course_url": match.url,
                    }
                    for assignment in assignments
                ]
            except Exception as e:
                return [{"error": f"Failed to get content from course '{match.name}': {str(e)}"}]
    
        except Exception as e:
            return [{"error": f"Failed to get course content: {str(e)}"}]
  • Core helper method implementing the scraping logic: loads course page, iterates sections and activities, determines types, builds Assignment list.
    def get_course_content(self, course_url: str) -> List[Assignment]:
        """Get all assignments and content from a specific course."""
        self._ensure_driver()
        self.heartBeat()
        if not self.logged_in:
            if not self.login():
                raise Exception("Login required to get courses.")
    
        try:
            self.driver.get(course_url)
            WebDriverWait(self.driver, 10).until(
                EC.presence_of_element_located((By.CSS_SELECTOR, ".course-content, .topics, li.section"))
            )
            assignments = []
            sections = self.driver.find_elements(By.CSS_SELECTOR, "li.section.main")
            for section in sections:
                try:
                    section_title_element = section.find_element(By.CSS_SELECTOR, ".sectionname span a, .sectionname a")
                    section_title = section_title_element.text.strip()
                    if section_title.lower() in ["general", ""]:
                        continue
    
                    activities = section.find_elements(By.CSS_SELECTOR, ".activity")
                    for activity in activities:
                        try:
                            activity_link = activity.find_element(By.CSS_SELECTOR, ".activityinstance a")
                            instance_name_element = activity_link.find_element(By.CSS_SELECTOR, ".instancename")
                            activity_name = " ".join(instance_name_element.text.strip().split())
                            activity_url = activity_link.get_attribute('href')
                            activity_type = "resource"
                            if "forum" in activity.get_attribute("class"):
                                activity_type = "forum"
                            elif "assign" in activity.get_attribute("class"):
                                activity_type = "assignment"
                            elif "quiz" in activity.get_attribute("class"):
                                activity_type = "quiz"
                            elif "resource" in activity.get_attribute("class"):
                                activity_type = "file"
    
                            if activity_name and activity_url:
                                hierarchical_name = f"{section_title} > {activity_name}"
                                assignments.append(Assignment(
                                    name=hierarchical_name,
                                    type=activity_type,
                                    url=activity_url,
                                    course=section_title
                                ))
                        except Exception:
                            continue
                except Exception:
                    continue
            self.heartBeat()
            return assignments
        except TimeoutException:
            print(f"Timeout while waiting for course content to load for url: {course_url}")
            return []
        except Exception as e:
            print(f"An error occurred while getting course content: {e}")
            return []
  • main.py:209-210 (handler)
    Dispatch logic in MCP server.call_tool() that routes calls to the tool_get_course_content handler.
    if name == "get_course_content":
        return _wrap_json(tool_get_course_content(args["course_name"]))

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/Cosmostima/MUSTer_MCP'

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