Skip to main content
Glama

list_problems

Retrieve available coding challenges from the Orange Juice Online Judge to browse and select problems for solving.

Instructions

Fetch the list of problems from the Online Judge. Returns a JSON string containing total count and results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
offsetNo
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The list_problems tool handler function that fetches problem list from the Online Judge. It accepts offset and limit parameters, uses get_authenticated_client() to ensure authentication, calls client.get_problems(), and returns the JSON result as a string.
    @mcp.tool()
    def list_problems(offset: int = 0, limit: int = 50) -> str:
        """
        Fetch the list of problems from the Online Judge.
        Returns a JSON string containing total count and results.
        """
        c = get_authenticated_client()
        try:
            data = c.get_problems(offset=offset, limit=limit)
            return str(data)
        except Exception as e:
            return f"Error: {e}"
  • Helper function get_authenticated_client() used by list_problems to ensure the user is logged in before making API calls. Handles lazy initialization of authentication using environment variables.
    def get_authenticated_client():
        global is_logged_in
        if not is_logged_in:
            if not OJ_USERNAME or not OJ_PASSWORD:
                raise ValueError("OJ_USERNAME and OJ_PASSWORD environment variables are required.")
            client.login(OJ_USERNAME, OJ_PASSWORD)
            is_logged_in = True
        return client
  • The get_problems() method in OJClient that makes the actual HTTP GET request to /api/problem endpoint with pagination parameters (offset, limit) and returns the JSON response.
    def get_problems(self, offset=0, limit=50):
        params = {'paging': 'true', 'offset': offset, 'limit': limit}
        resp = self.session.get(self._get_url("/api/problem"), params=params, timeout=20)
        resp.raise_for_status()
        return resp.json()

Tool Definition Quality

Score is being calculated. Check back soon.

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/wangicheng/oj-mcp-server'

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