Skip to main content
Glama

submit_code

Submit source code solutions to programming problems on the Orange Juice Online Judge. Specify the problem ID, programming language, and your code to evaluate your solution.

Instructions

Submit code to the Online Judge for a specific problem.
problem_id: the internal system ID of the problem.
language: string such as "C", "C++", "Python3".
code: the source code to submit.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
problem_idYes
codeYes
languageYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for submit_code - registered with @mcp.tool() decorator. This function receives problem_id, code, and language parameters, authenticates the client, calls the OJClient.submit_code method, and returns the result as a string.
    @mcp.tool()
    def submit_code(problem_id: int, code: str, language: str) -> str:
        """
        Submit code to the Online Judge for a specific problem.
        problem_id: the internal system ID of the problem.
        language: string such as "C", "C++", "Python3".
        code: the source code to submit.
        """
        c = get_authenticated_client()
        try:
            data = c.submit_code(code=code, language=language, problem_id=problem_id)
            return str(data)
        except Exception as e:
            return f"Error: {e}"
  • Tool registration point - the @mcp.tool() decorator on line 69 registers the submit_code function as an available MCP tool.
    @mcp.tool()
    def submit_code(problem_id: int, code: str, language: str) -> str:
        """
        Submit code to the Online Judge for a specific problem.
        problem_id: the internal system ID of the problem.
        language: string such as "C", "C++", "Python3".
        code: the source code to submit.
        """
        c = get_authenticated_client()
        try:
            data = c.submit_code(code=code, language=language, problem_id=problem_id)
            return str(data)
        except Exception as e:
            return f"Error: {e}"
  • Core implementation of submit_code logic in OJClient class. Updates CSRF token, creates payload with code/language/problem_id, and makes a POST request to /api/submission endpoint on the Online Judge.
    def submit_code(self, code, language, problem_id):
        self._update_csrf_token()
        payload = {
            "code": code,
            "language": language,
            "problem_id": int(problem_id)
        }
        # OJ API expect form data for submission
        resp = self.session.post(self._get_url("/api/submission"), data=payload, timeout=15)
        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