Skip to main content
Glama

get_courses

Retrieve enrolled courses from the eClass platform to access academic information and manage coursework.

Instructions

Get list of enrolled courses from eClass

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
random_stringYesDummy parameter for no-parameter tools

Implementation Reference

  • Registration of the 'get_courses' tool in the MCP server's list_tools handler, including schema definition.
    types.Tool(
        name="get_courses",
        description="Get list of enrolled courses from eClass",
        inputSchema={
            "type": "object",
            "properties": {
                "random_string": {
                    "type": "string",
                    "description": "Dummy parameter for no-parameter tools"
                },
            },
            "required": ["random_string"],
        },
    ),
  • Primary MCP tool handler for 'get_courses', which invokes the course management logic and formats the response.
    async def handle_get_courses() -> List[types.TextContent]:
        """Handle getting the list of enrolled courses."""
        success, message, courses = course_management.get_courses(session_state)
        return [course_management.format_courses_response(success, message, courses)]
  • Core implementation of get_courses: authenticates session, fetches portfolio page, extracts courses using HTML parsing, handles errors.
    def get_courses(
        session_state: SessionState
    ) -> Tuple[bool, Optional[str], Optional[List[Dict[str, str]]]]:
        """
        Retrieve a list of enrolled courses from eClass.
        
        Returns:
            Tuple of (success, message, courses).
            On success: (True, None, courses_list)
            On empty result: (True, message, [])
            On failure: (False, error_message, None)
        """
        if not session_state.logged_in:
            return False, "Not logged in. Please log in first using the login tool.", None
        
        if not session_state.is_session_valid():
            return False, "Session expired. Please log in again.", None
        
        try:
            response = session_state.session.get(session_state.portfolio_url)
            response.raise_for_status()
            
            courses = html_parsing.extract_courses(response.text, session_state.base_url)
            session_state.courses = courses
            
            if not courses:
                return True, "No courses found. You may not be enrolled in any courses.", []
            
            logger.info(f"Successfully retrieved {len(courses)} courses")
            return True, None, courses
        
        except requests.RequestException as e:
            logger.error(f"Network error getting courses: {e}")
            return False, f"Network error retrieving courses: {e}", None
        except Exception as e:
            logger.error(f"Error getting courses: {e}")
            return False, f"Error retrieving courses: {e}", None
  • Helper function to format the response TextContent for the get_courses tool.
    def format_courses_response(
        success: bool, message: Optional[str], courses: Optional[List[Dict[str, str]]]
    ) -> types.TextContent:
        """Format course list response for MCP."""
        if not success:
            return types.TextContent(
                type="text",
                text=f"Error: {message}",
            )
        
        if message:  # No courses found message
            return types.TextContent(
                type="text",
                text=message,
            )
        
        course_list = html_parsing.format_course_list(courses)
        return types.TextContent(
            type="text",
            text=f"Found {len(courses)} courses:\n\n{course_list}",
        )
  • Helper function that parses the HTML of the portfolio page to extract course names and URLs using BeautifulSoup.
    def extract_courses(html_content: str, base_url: str) -> List[Dict[str, str]]:
        """
        Extract course information from the portfolio page.
        
        Returns:
            List of dicts with 'name' and 'url' keys.
        """
        courses = []
        soup = BeautifulSoup(html_content, 'html.parser')
        
        # Try specific course selectors
        course_elements = (
            soup.select('.course-title') or
            soup.select('.lesson-title') or
            soup.select('.course-box .title') or
            soup.select('.course-info h4')
        )
        
        if course_elements:
            for course_elem in course_elements:
                course_link = course_elem.find('a') or course_elem
                if course_link and course_link.get('href'):
                    course_name = course_link.text.strip()
                    course_url = course_link.get('href')
                    if course_name:
                        courses.append({
                            'name': course_name,
                            'url': _make_absolute_url(course_url, base_url)
                        })
        else:
            # Fallback: find course links by URL pattern
            for link in soup.find_all('a'):
                href = link.get('href', '')
                if 'courses' in href or 'course.php' in href:
                    course_name = link.text.strip()
                    if course_name:
                        courses.append({
                            'name': course_name,
                            'url': _make_absolute_url(href, base_url)
                        })
        
        logger.debug(f"Extracted {len(courses)} courses")
        return courses
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions retrieving a list but doesn't specify whether this requires authentication, what format the list is in, if there are rate limits, or any error conditions. For a read operation with zero annotation coverage, this leaves significant gaps in understanding the tool's behavior.

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 with no wasted words. It's front-loaded with the core purpose ('Get list of enrolled courses from eClass'), making it easy to understand immediately. Every word earns its place without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and a simple read operation, the description is incomplete. It lacks details on authentication requirements, return format, error handling, or any behavioral context. For a tool that likely interacts with an eClass system, this leaves too many unknowns for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has one parameter (random_string) with 100% description coverage, indicating it's a dummy parameter for no-parameter tools. The description doesn't add any parameter details beyond the schema, but since this is effectively a zero-parameter tool (with a dummy parameter), the baseline is 4 as it doesn't need to compensate for schema gaps.

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 action ('Get list') and target resource ('enrolled courses from eClass'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools (authstatus, login, logout) which are unrelated authentication tools, so this distinction isn't needed but the purpose remains clear.

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?

The description provides no guidance on when to use this tool versus alternatives. While the sibling tools are unrelated (authentication vs. data retrieval), there's no explicit mention of prerequisites like needing to be logged in or any context for usage. It simply states what it does without usage instructions.

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/sdi2200262/eclass-mcp-server'

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