moodle-webservice_mcp
A Moodle web service plugin that implements the MCP for seamless integration with AI assistants
claude mcp add --transport stdio onbirdev-moodle-webservice_mcp docker run -i moodle:latest \ --env MOODLE_TOKEN="YOUR_MOODLE_TOKEN_IF_NEEDED" \ --env MOODLE_SITE_URL="https://your-moodle-site.com" \ --env MOODLE_MCP_ENDPOINT="/webservice/mcp/server.php" \ --env MOODLE_WEB_SERVICE_ENABLED="true"
How to use
This MCP server is implemented as a Moodle plugin that exposes Moodle's web service external functions through the Model Context Protocol (MCP) using JSON-RPC 2.0. Once installed and enabled in your Moodle instance, it dynamically discovers Moodle external functions that are available to the configured external service and presents them as MCP tools with JSON schemas for inputs and outputs. Clients can initialize a session, list the available tools, and call a specific tool by name with the proper arguments. Authentication is token-based, either via a wstoken query parameter or a Bearer token in the Authorization header, ensuring that only authorized services can access the exposed tools.
How to install
Prerequisites:
- A Moodle instance (4.2+) with web services enabled
- PHP 8.0+ and Moodle's web services configured
- Access to install Moodle plugins (Site administration)
Installation steps:
- Install the Moodle MCP Web Service plugin
- Via Moodle Admin UI: Site administration → Plugins → Install plugins
- Search for and install the MCP Web Service plugin
- Manual installation (if you prefer cloning)
- Clone the repository into Moodle's webservice directory: git clone https://github.com/onbirdev/moodle-webservice_mcp.git mcp
- Ensure Moodle recognizes the plugin under site administration → Notifications and complete any setup prompts
- Enable MCP protocol and web services
- Enable web services: Site administration → Advanced features → Enable web services
- Enable Model Context Protocol (MCP): Site administration → Plugins → Web services → Manage protocols → Enable MCP
- Create an External Service and Token (for authentication)
- External service: Site administration → Server → Web services → External services → Add
- Name: e.g., "MCP Service"
- Short name: e.g., "mcp_service"
- Enabled: Yes; Authorized users only: Yes
- Add external functions your service should expose
- Tokens: Site administration → Server → Web services → Manage tokens → Add
- User: select user for authentication
- Service: the MCP service you created
- Save and copy the token
- Access MCP endpoint
- The MCP endpoint is available at: https://your-moodle-site.com/webservice/mcp/server.php
- Use the token according to the client method (wstoken or Authorization header)
Additional notes
Tips and considerations:
- Ensure the user has the webservice/mcp:use capability to access MCP functions.
- Tokens should be kept secret; rotate tokens if compromised.
- The MCP server discovers Moodle external functions dynamically. If a function is not visible to the configured service, it will not appear in tools/list.
- Monitor usage through Moodle logs (Site administration → Reports → Logs) for auditing tool calls.
- The included client examples in the README demonstrate typical JSON-RPC 2.0 interaction: initialize, list tools, and call a specific tool.
- If you deploy behind a reverse proxy or load balancer, ensure proper routing to the Moodle instance and correct SSL termination.
Related MCP Servers
laravel-loop
Laravel Loop is a powerful Model Context Protocol (MCP) server designed specifically for Laravel applications. It connects your Laravel application with AI assistants using the MCP protocol.
ai-command
Control WordPress using WP-CLI, AI, and MCP.
php -sdk
PHP implementation of the Model Context Protocol (MCP), enabling seamless integration between LLM applications and external data sources and tools. ✨ Features 🚀 Complete MCP Protocol Support - Full implementation of the MCP specification 🔧 Type-Safe - Leverages PHP 8.1+ type system with enums, union types, and strict typing ⚡ Async First
mcp-time-php
A PHP sample implementation of an MCP (Model Context Protocol) server for retrieving time information.
maas-webapp
The code that powers the 'MCP as a Service' web application.
clockwork
MCP server for Laravel Clockwork - debug and analyze Laravel applications with AI assistance. Query performance, N+1 detection, cache analysis, and more.