Skip to main content
Glama

get_submission_content

Retrieve detailed submission content including text and attached files for a specific student and assignment on Moodle.

Instructions

Obtiene el contenido detallado de una entrega específica, incluyendo texto y archivos adjuntos

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
studentIdYesID del estudiante
assignmentIdYesID de la tarea

Implementation Reference

  • The handler function that retrieves detailed submission content from Moodle API, processes online text and file plugins, and returns formatted JSON.
    private async getSubmissionContent(args: any) {
      if (!args.studentId || !args.assignmentId) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Student ID and Assignment ID are required'
        );
      }
    
      console.error(`[API] Requesting submission content for student ${args.studentId} on assignment ${args.assignmentId}`);
      
      try {
        // Utilizamos la función mod_assign_get_submission_status para obtener el contenido detallado
        const response = await this.axiosInstance.get('', {
          params: {
            wsfunction: 'mod_assign_get_submission_status',
            assignid: args.assignmentId,
            userid: args.studentId,
          },
        });
    
        // Procesamos la respuesta para extraer el contenido relevante
        const submissionData = response.data.submission || {};
        const plugins = response.data.lastattempt?.submission?.plugins || [];
        
        // Extraemos el texto de la entrega y los archivos adjuntos
        let submissionText = '';
        const files = [];
        
        for (const plugin of plugins) {
          // Procesamos el plugin de texto en línea
          if (plugin.type === 'onlinetext') {
            const textField = plugin.editorfields?.find((field: any) => field.name === 'onlinetext');
            if (textField) {
              submissionText = textField.text || '';
            }
          }
          
          // Procesamos el plugin de archivos
          if (plugin.type === 'file') {
            const filesList = plugin.fileareas?.find((area: any) => area.area === 'submission_files');
            if (filesList && filesList.files) {
              for (const file of filesList.files) {
                files.push({
                  filename: file.filename,
                  fileurl: file.fileurl,
                  filesize: file.filesize,
                  filetype: file.mimetype,
                });
              }
            }
          }
        }
        
        // Construimos el objeto de respuesta
        const submissionContent = {
          assignment: args.assignmentId,
          userid: args.studentId,
          status: submissionData.status || 'unknown',
          submissiontext: submissionText,
          plugins: [
            {
              type: 'onlinetext',
              content: submissionText,
            },
            {
              type: 'file',
              files: files,
            },
          ],
          timemodified: submissionData.timemodified || 0,
        };
        
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(submissionContent, null, 2),
            },
          ],
        };
      } catch (error) {
        console.error('[Error]', error);
        if (axios.isAxiosError(error)) {
          return {
            content: [
              {
                type: 'text',
                text: `Error al obtener el contenido de la entrega: ${
                  error.response?.data?.message || error.message
                }`,
              },
            ],
            isError: true,
          };
        }
        throw error;
      }
    }
  • TypeScript interface defining the structure of submission content returned by the handler.
    interface SubmissionContent {
      assignment: number;
      userid: number;
      status: string;
      submissiontext?: string;
      plugins?: Array<{
        type: string;
        content?: string;
        files?: Array<{
          filename: string;
          fileurl: string;
          filesize: number;
          filetype: string;
        }>;
      }>;
      timemodified: number;
    }
  • src/index.ts:199-216 (registration)
    Tool registration in the ListTools response, defining name, description, and input schema for validation.
    {
      name: 'get_submission_content',
      description: 'Obtiene el contenido detallado de una entrega específica, incluyendo texto y archivos adjuntos',
      inputSchema: {
        type: 'object',
        properties: {
          studentId: {
            type: 'number',
            description: 'ID del estudiante',
          },
          assignmentId: {
            type: 'number',
            description: 'ID de la tarea',
          },
        },
        required: ['studentId', 'assignmentId'],
      },
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves detailed content, implying a read-only operation, but doesn't specify whether it requires authentication, has rate limits, returns paginated results, or what happens if the submission doesn't exist. For a tool with no annotation coverage, this lack of behavioral details is a significant gap, though it doesn't contradict any annotations.

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

Conciseness5/5

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

The description is a single, efficient sentence in Spanish that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and includes key details (text and attachments). Every part of the sentence earns its place by clarifying the scope of retrieval.

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

Completeness3/5

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

Given the tool's complexity (a read operation with 2 parameters), no annotations, and no output schema, the description is minimally adequate. It covers the basic purpose and what content is retrieved, but lacks behavioral details (e.g., error handling, return format) and usage guidelines. For a tool with no structured output or annotations, it should do more to be fully complete, but it meets the minimum viable threshold.

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

Parameters3/5

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

The schema description coverage is 100%, with both parameters (studentId and assignmentId) clearly documented in the schema. The description doesn't add any parameter-specific information beyond what's in the schema, such as format examples or constraints. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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: 'Obtiene el contenido detallado de una entrega específica, incluyendo texto y archivos adjuntos' (Gets the detailed content of a specific submission, including text and attached files). It specifies the verb (obtiene/gets) and resource (contenido detallado de una entrega/detailed content of a submission), and distinguishes itself from siblings like 'get_submissions' (which likely lists submissions) by focusing on detailed content retrieval. However, it doesn't explicitly contrast with other siblings, so it's not a perfect 5.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose it over 'get_submissions' (which might list submissions without details) or other sibling tools like 'get_assignments' or 'get_students'. There's no context about prerequisites, such as needing to identify a specific submission first. The usage is implied from the purpose but not explicitly stated.

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/cfsandoval/Mcp'

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