Skip to main content
Glama

tool_cache_relevant_pages

Download exam page images and adjacent pages to local storage for review, enabling agents to inspect scanned content before grading assignments.

Instructions

Download the crop page and neighboring pages to /tmp for local review.

This is useful for scanned exams where the prompt is only available in page
images and where agents may need to inspect adjacent pages before grading.

Args:
    course_id: The Gradescope course ID.
    assignment_id: The assignment ID.
    question_id: The question ID.
    submission_id: The question submission ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
course_idYes
assignment_idYes
question_idYes
submission_idYes

Implementation Reference

  • The actual implementation of the tool logic.
    def cache_relevant_pages(
        course_id: str,
        assignment_id: str,
        question_id: str,
        submission_id: str,
    ) -> str:
        """Download the crop page and its neighbors to /tmp for local inspection."""
        if not course_id or not assignment_id or not question_id or not submission_id:
            return (
                "Error: course_id, assignment_id, question_id, and submission_id "
                "are required."
            )
    
        try:
            ctx = _get_grading_context(course_id, question_id, submission_id)
            conn = get_connection()
        except AuthError as e:
            return f"Authentication error: {e}"
        except ValueError as e:
            return f"Error: {e}"
        except Exception as e:
            return f"Error caching relevant pages: {e}"
    
        props = ctx["props"]
        question = props.get("question", {})
        parameters = question.get("parameters") or {}
        crop_rects = parameters.get("crop_rect_list", [])
        pages = [
            page for page in props.get("pages", [])
            if isinstance(page, dict) and page.get("url")
        ]
        relevant_pages = _select_relevant_pages(pages, crop_rects)
        if not relevant_pages:
            return "No relevant pages were found for this submission."
  • The MCP tool registration and handler wrapper for tool_cache_relevant_pages.
    @mcp.tool()
    def tool_cache_relevant_pages(
        course_id: str,
        assignment_id: str,
        question_id: str,
        submission_id: str,
    ) -> str:
        """Download the crop page and neighboring pages to /tmp for local review.
    
        This is useful for scanned exams where the prompt is only available in page
        images and where agents may need to inspect adjacent pages before grading.
    
        Args:
            course_id: The Gradescope course ID.
            assignment_id: The assignment ID.
            question_id: The question ID.
            submission_id: The question submission ID.
        """
        return cache_relevant_pages(
            course_id, assignment_id, question_id, submission_id
        )

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/Yuanpeng-Li/gradescope-mcp'

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