Skip to main content
Glama

get_class_schedule

Retrieve your weekly class schedule from the MUSTer campus system. Filter by specific date or view the full week's timetable with a single request.

Instructions

Get class schedule in this week; pass null for full week, or date (YYYY-MM-DD) to filter. If you need multiple days, pass null once instead of multiple calls.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateNoDate filter YYYY-MM-DD; null returns full week

Implementation Reference

  • main.py:190-196 (handler)
    MCP tool handler: thin wrapper that delegates to MUSTerClient.get_class_schedule() and handles errors.
    def tool_get_class_schedule(date: Optional[str] = None) -> Any:
        try:
            schedule_data = muster_client.get_class_schedule(date=date)
            return schedule_data
        except Exception as e:
            return {"error": f"Failed to fetch schedule data: {str(e)}"}
  • Tool schema definition including input schema for optional date parameter.
    Tool(
        name="get_class_schedule",
        description="Get class schedule in this week; pass null for full week, or date (YYYY-MM-DD) to filter. If you need multiple days, pass null once instead of multiple calls.",
        inputSchema={
            "type": "object",
            "properties": {
                "date": {
                    "type": ["string", "null"],
                    "description": "Date filter YYYY-MM-DD; null returns full week",
                }
            },
            "required": [],
        },
    ),
  • main.py:219-220 (registration)
    Tool dispatch registration in the call_tool handler.
    if name == "get_class_schedule":
        return _wrap_json(tool_get_class_schedule(args.get("date")))
  • Core helper method in MUSTerClient: authenticates, downloads Excel schedule via Selenium, parses with pandas, and filters by date if provided.
    def get_class_schedule(self, date: Optional[str] = None) -> Dict[str, Any]:
        """
        Get class schedule data from the MUST schedule website.
        Args:
            date: Optional date in YYYY-MM-DD format to filter results
        """      
        
        self._ensure_driver()
        
        self.heartBeat()
    
        if not self.logged_in:
            if not self.login():
                raise Exception("Login required to get courses.")
        
        # Create temporary download directory for Excel file
        with tempfile.TemporaryDirectory() as download_dir:
            try:
                # Update download preferences for this session
                self.driver.execute_cdp_cmd('Page.setDownloadBehavior', {
                    'behavior': 'allow',
                    'downloadPath': download_dir
                })
                
                # Navigate to schedule page
                self.driver.get(SCHEDULE_URL)
                
                # Login if we're redirected to login page
                current_url = self.driver.current_url.lower()
                if "login" in current_url or "signin" in current_url:
                    try:
                        self.login()
                    except Exception as e:
                        return {"error": f"Failed to login to schedule system: {str(e)}"}
                
                self.heartBeat()
                
                # Export process
                export_btn = WebDriverWait(self.driver, 10).until(
                    EC.element_to_be_clickable(
                        (By.XPATH, "//button[span[text()='導出']]")
                    )
                )
                export_btn.click()
                
                # Expand collapse panel and download
                collapse_header = WebDriverWait(self.driver, 10).until(
                    EC.element_to_be_clickable((By.XPATH, "//div[contains(@class,'ivu-collapse-header') and contains(.,'下載任務')]"))
                )
                collapse_header.click()
                
                download_buttons = WebDriverWait(self.driver, 10).until(
                    EC.presence_of_all_elements_located((By.XPATH, "//button[.//span[contains(text(),'下载') or contains(text(),'下載')]]"))
                )
                
                WebDriverWait(self.driver, 5).until(EC.element_to_be_clickable(download_buttons[-1]))
                download_buttons[-1].click()
                time.sleep(1)
                
                self.heartBeat()
                
                # Cancel any dialogs
                try:
                    cancel_buttons = WebDriverWait(self.driver, 5).until(
                        EC.presence_of_all_elements_located((By.XPATH, "//button[contains(., '取消')]"))
                    )
                    for button in cancel_buttons:
                        try:
                            button.click()
                        except:
                            pass
                except:
                    pass
                
                # Wait for file download
                timeout = 30
                start = time.time()
                
                while True:
                    xlsx_files = glob.glob(os.path.join(download_dir, "*.xlsx"))
                    if xlsx_files:
                        break
                    elif time.time() - start > timeout:
                        return {"error": "Failed to download schedule file within 30 seconds"}
                    else:
                        time.sleep(0.5)
                
                self.heartBeat()
                
                # Process the downloaded file
                xlsx_files = sorted(
                    glob.glob(os.path.join(download_dir, "*.xlsx")),
                    key=os.path.getmtime,
                    reverse=True
                )
                
                latest_xlsx = xlsx_files[0]
                df = pd.read_excel(latest_xlsx)
                schedule_data = df.to_dict('records')
    
                response = {
                    "success": True,
                    "total_classes": len(schedule_data),
                    "schedule": schedule_data
                }
                if date:
                    filtered = [cls for cls in schedule_data if isinstance(cls, dict) and cls.get("日期") == date]
                    response["schedule"] = filtered
                    response["total_classes"] = len(filtered)
                    if not filtered:
                        response["warning"] = "Only current week's schedule is available."
                return response
                
            except Exception as e:
                return {"error": f"Failed to fetch schedule data: {str(e)}"}
            finally:
                self.heartBeat()
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It explains the temporal scope ('this week'), filtering behavior, and optimization guidance about avoiding multiple calls. However, it doesn't mention potential rate limits, authentication requirements, error conditions, or what format the schedule data returns (though no output schema exists).

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 extremely concise (two sentences) and front-loaded with the core purpose. Every sentence earns its place: the first establishes what the tool does and parameter usage, the second provides important optimization guidance. Zero wasted words.

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?

For a single-parameter read tool with no annotations and no output schema, the description is adequate but has gaps. It explains the basic functionality and parameter usage well, but doesn't describe the return format, error handling, or what 'this week' means precisely. The optimization guidance is helpful, but more context about the schedule structure would improve completeness.

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?

The schema description coverage is 100%, so the parameter 'date' is already documented in the schema. The description adds some value by clarifying that null returns 'full week' and providing the YYYY-MM-DD format, but doesn't explain what 'full week' means (e.g., Monday-Sunday, current 7-day period) or edge cases. Baseline 3 is appropriate when schema does most of the work.

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 tool's purpose: 'Get class schedule in this week' specifies the verb (get) and resource (class schedule) with a temporal scope (this week). It distinguishes from siblings like 'get_all_courses' or 'get_pending_events' by focusing specifically on schedule data. However, it doesn't explicitly differentiate from potential schedule-related siblings that might not exist.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear usage guidance: 'pass null for full week, or date (YYYY-MM-DD) to filter' explains when to use each parameter option. 'If you need multiple days, pass null once instead of multiple calls' offers optimization advice, though it doesn't explicitly mention when to use this tool versus alternatives like 'get_pending_events' for event data.

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

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