get_students
Retrieve a list of students enrolled in a configured course using the Moodle MCP Server, enabling efficient course management and student data access.
Instructions
Obtiene la lista de estudiantes inscritos en el curso configurado
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"required": [],
"type": "object"
}
Implementation Reference
- src/index.ts:283-311 (handler)The main handler function for the 'get_students' tool. It queries the Moodle API using 'core_enrol_get_enrolled_users', filters for users with 'student' role, maps to a simplified Student object, and returns the list as formatted JSON text content.private async getStudents() { console.error('[API] Requesting enrolled users'); const response = await this.axiosInstance.get('', { params: { wsfunction: 'core_enrol_get_enrolled_users', courseid: MOODLE_COURSE_ID, }, }); const students = response.data .filter((user: any) => user.roles.some((role: any) => role.shortname === 'student')) .map((student: any) => ({ id: student.id, username: student.username, firstname: student.firstname, lastname: student.lastname, email: student.email, })); return { content: [ { type: 'text', text: JSON.stringify(students, null, 2), }, ], }; }
- src/index.ts:129-136 (registration)Tool registration in the ListTools response, defining the name, description, and input schema for 'get_students'.name: 'get_students', description: 'Obtiene la lista de estudiantes inscritos en el curso configurado', inputSchema: { type: 'object', properties: {}, required: [], }, },
- src/index.ts:131-135 (schema)Input schema definition for the 'get_students' tool, indicating it takes no parameters.inputSchema: { type: 'object', properties: {}, required: [], },
- src/index.ts:243-244 (registration)Dispatch case in the CallToolRequest handler that routes 'get_students' calls to the getStudents() method.case 'get_students': return await this.getStudents();
- src/index.ts:31-37 (helper)Type definition for Student objects returned by the get_students tool.interface Student { id: number; username: string; firstname: string; lastname: string; email: string; }