Skip to content

local_mcp

local_mcp 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 (requires 2024100700, supported 405–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.4.1 (2026110107), 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:

{wwwroot}/local/mcp/server.php

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 34 tools:

  • 21 read tools
    • General: site_info, search_courses, get_course_structure, list_participants, list_activities, 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_submissions_status, get_ungraded_work, get_quiz_results, get_inactive_students, get_activity_completion_report, get_course_logs_summary, get_forum_unanswered.
  • 13 write tools: create_course, build_course, add_section, add_activity, create_quiz, add_quiz_questions, import_questions, update_activity, enrol_user, create_group, set_visibility, delete_activity, delete_section.

With write mode on, an assistant can add assignments with a rubric, forums, URLs, pages, labels, files and quizzes; author quiz questions (multiple choice, true/false, short answer, numerical, matching, essay); import GIFT or Moodle XML; and build a whole course from a JSON plan in the background, with a dry run and rollback if it fails. 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, write and admin. 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).
  • Deletions are dry runs unless the call sends dryRun: false and confirm: true.

See Security and permissions.

Next steps

  1. Requirements
  2. Installation
  3. Quick start