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
| Name | Required | Description | Default |
|---|---|---|---|
| problem_id | Yes | ||
| code | Yes | ||
| language | Yes |
Output Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/oj_mcp_server/server.py:69-82 (handler)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}" - src/oj_mcp_server/server.py:69-82 (registration)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}" - src/oj_mcp_server/oj_client.py:60-70 (handler)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()