local_mcpserver¶
local_mcpserver is a Moodle local plugin that speaks the Model Context Protocol (MCP) over Streamable HTTP. An AI assistant such as Claude, ChatGPT, Cursor or Grok connects as a real Moodle user, with the same capabilities that user already has in the Moodle interface. It can read the site or build courses.
- Moodle: 4.5 to 5.2 (
requires2024100700,supported405–502). Tested on 4.5 LTS and 5.2 with PHP 8.3 and PostgreSQL; the same code runs on 5.0 and 5.1. - License: GNU GPL v3 or later.
- Version: 0.8.6, maturity beta. In development, tested locally with MCP Inspector.
- Author: Sergio Comerón.
Not published yet
Download, source code and Moodle directory listing: coming soon.
What it does¶
The endpoint is:
It accepts JSON-RPC 2.0 POST requests and answers with JSON or a one-shot SSE body. An MCP client
connects to that URL and calls 63 tools (by scope: 26 read, 26 write and 11 admin):
- 27 read tools
- General:
site_info,search_courses,list_categories,get_course_structure,list_participants,list_activities,get_activity_settings,get_grades_summary,get_task_status. - Student:
get_my_deadlines,get_my_grades,get_my_progress,get_assignment_details,get_forum_posts,get_calendar_events,search_course_content. - Teacher:
get_ungraded_work,get_inactive_students,get_submissions_status,get_submission,get_quiz_results,get_activity_completion_report,get_course_logs_summary,get_forum_unanswered. - Messaging:
list_conversations,get_conversation_messages. - Accounts (admin scope):
search_users.
- General:
- 36 write tools
- Courses and activities:
create_course,update_course,add_section,add_activity,update_activity,set_visibility,set_course_image,set_course_completion,set_availability,delete_activity,delete_section,build_course. - Quizzes and questions:
create_quiz,add_quiz_questions,import_questions. - Grading:
grade_submission. - Enrolment, roles and groups:
enrol_user,unenrol_user,set_user_role,create_group,add_group_members,remove_group_members. - Forums and messaging:
create_forum_discussion,reply_forum_post,send_private_message,reply_conversation. - User accounts (admin scope):
create_user,create_users,update_user,suspend_user,unsuspend_user. - Site policies (admin scope):
set_site_policy_handler,create_policy,update_policy,list_policies,get_policy_acceptances.
- Courses and activities:
It also offers three MCP prompts (design_course, create_quiz_from_content, grade_assignment) and ships the moodle-course-design skill. Each user can create personal tokens from My MCP tokens, and administrators have a token panel.
With write mode on, an assistant can add assignments with a rubric, forums, choices, URLs, pages and labels (with images), files and quizzes, with completion conditions and any other form setting; change course settings, the course image, completion tracking and access restrictions; author quiz questions (multiple choice, true/false, short answer, numerical, matching, essay); import GIFT or Moodle XML; build a whole course from a JSON plan in the background, with a dry run and rollback if it fails; grade assignments with a dry run first; start forum discussions and reply to posts; send private messages; manage site policies; and manage users, enrolment, roles and groups. An editing teacher can fill their own course; creating a new course needs Moodle's moodle/course:create.
Security at a glance¶
- OAuth 2.1 authorisation code flow with PKCE S256 and dynamic client registration (RFC 7591). Optional Moodle web service token fallback.
- Scopes
read,writeandadmin. Personal tokens with a fixed lifetime (30, 90 or 365 days). Short-lived access tokens; refresh tokens rotate on every use; tokens can be revoked. - Every tool call is written to the Moodle event log.
- Rate limit per user, per minute (60 by default).
- Write tools are off by default (
allowwrite= 0). grade_submissionis a dry run unless the call sendsdryRun: false. Deletions are dry runs unless the call sendsdryRun: falseandconfirm: true.