Skip to main content
Glama

create_student_anonymization_map

Generate a secure CSV file that maps real student data to anonymous IDs for a Canvas course, creating a de-anonymization key for faculty to identify students while maintaining privacy.

Instructions

Create a local CSV file mapping real student data to anonymous IDs for a course.

    This tool generates a de-anonymization key that allows faculty to identify students
    from their anonymous IDs. The file is saved locally and should be kept secure.

    Args:
        course_identifier: The Canvas course code (e.g., badm_554_120251_246794) or ID
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
course_identifierYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler function for the 'create_student_anonymization_map' tool. Decorated with @mcp.tool() and @validate_params, it fetches students from the Canvas course, generates anonymous IDs, and writes a secure local CSV mapping file.
    @mcp.tool()
    @validate_params
    async def create_student_anonymization_map(course_identifier: str | int) -> str:
        """Create a local CSV file mapping real student data to anonymous IDs for a course.
    
        This tool generates a de-anonymization key that allows faculty to identify students
        from their anonymous IDs. The file is saved locally and should be kept secure.
    
        Args:
            course_identifier: The Canvas course code (e.g., badm_554_120251_246794) or ID
        """
        import csv
        from pathlib import Path
    
        from ..core.anonymization import generate_anonymous_id
    
        course_id = await get_course_id(course_identifier)
    
        # Get all students in the course
        params = {
            "enrollment_type[]": "student",
            "include[]": ["email"],
            "per_page": 100
        }
    
        students = await fetch_all_paginated_results(
            f"/courses/{course_id}/users", params
        )
    
        if isinstance(students, dict) and "error" in students:
            return f"Error fetching students: {students['error']}"
    
        if not students:
            return f"No students found for course {course_identifier}."
    
        # Create local_maps directory if it doesn't exist
        maps_dir = Path("local_maps")
        maps_dir.mkdir(exist_ok=True)
    
        # Generate filename with course identifier
        course_display = await get_course_code(course_id) or str(course_identifier)
        safe_course_name = "".join(c for c in course_display if c.isalnum() or c in ("-", "_"))
        filename = f"anonymization_map_{safe_course_name}.csv"
        filepath = maps_dir / filename
    
        # Create mapping data
        mapping_data = []
        for student in students:
            real_id = student.get("id")
            real_name = student.get("name", "Unknown")
            real_email = student.get("email", "No email")
    
            # Generate the same anonymous ID that would be used by the anonymization system
            anonymous_id = generate_anonymous_id(real_id, prefix="Student")
    
            mapping_data.append({
                "real_name": real_name,
                "real_id": real_id,
                "real_email": real_email,
                "anonymous_id": anonymous_id
            })
    
        # Write to CSV file
        try:
            with open(filepath, 'w', newline='', encoding='utf-8') as csvfile:
                fieldnames = ["real_name", "real_id", "real_email", "anonymous_id"]
                writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
    
                writer.writeheader()
                writer.writerows(mapping_data)
    
            result = "✅ Student anonymization map created successfully!\n\n"
            result += f"📁 File location: {filepath}\n"
            result += f"👥 Students mapped: {len(mapping_data)}\n"
            result += f"🏫 Course: {course_display}\n\n"
            result += "⚠️ **SECURITY WARNING:**\n"
            result += "This file contains sensitive student information and should be:\n"
            result += "• Kept secure and not shared\n"
            result += "• Deleted when no longer needed\n"
            result += "• Never committed to version control\n\n"
            result += "📋 File format: CSV with columns real_name, real_id, real_email, anonymous_id\n"
            result += "🔍 Use this file to identify students from their anonymous IDs in tool outputs."
    
            return result
    
        except Exception as e:
            return f"Error creating anonymization map: {str(e)}"
  • Top-level registration call within register_all_tools(mcp) that invokes register_other_tools to register this tool along with other tools in the 'other_tools' module.
    register_other_tools(mcp)
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes key traits: the tool creates a local file (implying a write operation), generates a de-anonymization key, and has security implications. However, it doesn't cover potential side effects (e.g., overwriting existing files), error conditions, or output format details, which are important for a tool with security risks.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and appropriately sized, with a clear opening sentence stating the purpose, followed by security notes and parameter details. Every sentence adds value, and it's front-loaded with the main action. Minor improvements could include bullet points for readability, but it's efficient overall.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (involving data mapping and security), no annotations, and an output schema present (which likely covers return values), the description is reasonably complete. It covers purpose, security implications, and parameter semantics, though it could benefit from more behavioral details like file naming or error handling to be fully comprehensive.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful context for the single parameter 'course_identifier' by explaining it as 'The Canvas course code (e.g., badm_554_120251_246794) or ID', which clarifies its purpose beyond the schema's generic title. With 0% schema description coverage and only one parameter, this compensation is effective, though it could specify format constraints more precisely.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Create a local CSV file mapping real student data to anonymous IDs for a course.' It specifies the verb ('create'), resource ('local CSV file'), and scope ('for a course'), making it easy to understand. However, it doesn't explicitly differentiate from sibling tools like 'get_anonymization_status', which might provide related information without creating a file.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by mentioning that the file 'should be kept secure' and is for faculty to identify students, suggesting it's for privacy-sensitive scenarios. However, it lacks explicit guidance on when to use this tool versus alternatives (e.g., 'get_anonymization_status' for checking status) or any prerequisites, leaving some ambiguity for the agent.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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/vishalsachdev/canvas-mcp'

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