tool_moodlemcp

antalmiklos/tool_moodlemcp

3.2

If you are the rightful owner of tool_moodlemcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

A Moodle admin tool plugin that implements a Model Context Protocol (MCP) Server for managing Moodle systems.

Moodle MCP Tool Plugin

A Moodle admin tool plugin that implements a Model Context Protocol (MCP) Server for managing Moodle systems. This plugin enables AI assistants and external applications to interact with Moodle through a standardized protocol, providing secure, programmatic access to Moodle's core functionality.

📚 Documentation

  • - Comprehensive study of requirements, architecture, and implementation plan
  • - Detailed technical implementation details
  • - Feature breakdown by development phase

🎯 Overview

This plugin transforms Moodle into an MCP server, allowing:

  • AI Assistants (like Claude) to manage Moodle systems
  • External Applications to integrate with Moodle via MCP protocol
  • Automated Workflows for course and user management
  • Secure API Access via token-based authentication

Installation

  1. Copy the tool_moodlemcp directory to your Moodle installation:

    /path/to/moodle/admin/tool/moodlemcp/
    
  2. Log in to your Moodle site as an administrator.

  3. Navigate to Site administration > Notifications (or visit /admin/index.php).

  4. Moodle will automatically detect the new plugin and prompt you to install it.

  5. Click Upgrade Moodle database now to complete the installation.

Access

After installation, you can access the tool via:

  • Site administration > Tools > Moodle MCP
  • Direct URL: /admin/tool/moodlemcp/index.php

Requirements

  • Moodle 4.0 or higher
  • Administrator access to install plugins

Permissions

The plugin requires the tool/moodlemcp:view capability, which is granted to managers by default.

🚀 Current Status

✅ Completed

  • Plugin structure and installation
  • Token management system (create, validate, expire tokens)
  • Database schema for token storage
  • Example quiz creation functionality

🚧 In Progress

  • MCP protocol handler implementation
  • Authentication middleware
  • API endpoint setup

📋 Planned

  • Course management tools
  • User management tools
  • Activity management tools
  • Resource access endpoints
  • Security hardening

See for detailed status.

🏗️ Architecture

The plugin follows a layered architecture:

MCP Client → MCP Protocol Handler → Authentication Layer → Moodle API Wrapper → Moodle Core

Key components:

  • MCP Server: Handles JSON-RPC 2.0 protocol
  • Token Authentication: Secure token-based access
  • Tool Implementations: Moodle operations as MCP tools
  • Resource Access: Readable data via MCP resources

🔐 Security

  • Token-based authentication with expiration
  • Capability-based authorization (respects Moodle permissions)
  • Rate limiting to prevent abuse
  • Input validation and sanitization
  • Comprehensive audit logging

📖 Development

Plugin Structure

tool_moodlemcp/
├── version.php                    # Plugin version and metadata
├── lang/
│   └── en/
│       └── tool_moodlemcp.php     # Language strings
├── db/
│   ├── install.xml                # Database schema
│   └── access.php                 # Capability definitions
├── classes/
│   ├── token_manager.php          # Token management ✅
│   ├── quiz_creator.php           # Quiz creation examples ✅
│   ├── mcp/                        # MCP protocol handlers (planned)
│   ├── auth/                       # Authentication (planned)
│   ├── tools/                      # MCP tools (planned)
│   └── resources/                  # MCP resources (planned)
├── api/
│   └── mcp.php                     # MCP API endpoint (planned)
├── lib.php                         # Library functions
├── settings.php                    # Admin settings and menu
├── index.php                       # Main plugin page
└── examples/
    └── create_quiz_example.php    # Usage examples ✅

🔌 API Usage (Planned)

Once implemented, the MCP server will be accessible at:

POST /admin/tool/moodlemcp/api/mcp.php
Authorization: Bearer {token}
Content-Type: application/json

Example request:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "create_course",
    "arguments": {
      "category_id": 1,
      "fullname": "Introduction to AI",
      "shortname": "AI101"
    }
  }
}

License

This plugin is licensed under the GNU GPL v3 or later.