get_submission_status
Check the status and result of code submissions to the Orange Juice Online Judge by providing the submission ID.
Instructions
Get the status and result of a previously submitted code.
submission_id: The ID returned when submitting the code.Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| submission_id | Yes |
Output Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/oj_mcp_server/server.py:84-95 (handler)The get_submission_status tool handler - decorated with @mcp.tool() for registration. Takes a submission_id parameter, gets an authenticated client, and calls the OJ API to retrieve submission status and results.
@mcp.tool() def get_submission_status(submission_id: str) -> str: """ Get the status and result of a previously submitted code. submission_id: The ID returned when submitting the code. """ c = get_authenticated_client() try: data = c.get_submission(submission_id) return str(data) except Exception as e: return f"Error: {e}" - src/oj_mcp_server/server.py:21-28 (helper)Helper function get_authenticated_client() that ensures the OJClient is authenticated before use. Uses a global flag to track login state and authenticates with credentials from 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 - src/oj_mcp_server/oj_client.py:72-76 (helper)OJClient.get_submission() method that makes the actual HTTP GET request to the /api/submission endpoint with the submission_id parameter and returns the JSON response.
def get_submission(self, submission_id): params = {"id": submission_id} resp = self.session.get(self._get_url("/api/submission"), params=params, timeout=15) resp.raise_for_status() return resp.json()