Moodle MCP Server
A powerful Model Context Protocol (MCP) server that seamlessly integrates AI assistants with Moodle Learning Management System. Enable your AI assistant to access courses, retrieve educational content, download resources, and search through your learning materials.
README
<div align="center">
๐ Moodle MCP Server
Model Context Protocol integration for Moodle LMS
Features โข Installation โข Usage โข Documentation โข Contributing
</div>
๐ Overview
A powerful Model Context Protocol (MCP) server that seamlessly integrates AI assistants with Moodle Learning Management System. Enable your AI assistant to access courses, retrieve educational content, download resources, and search through your learning materials.
๐ Compatible with: Claude Desktop, and any MCP-compatible AI assistant
โจ Features
- ๐ Secure Authentication - Token-based auth using Moodle Web Services
- ๐ Course Management - List and access all enrolled courses
- ๐ Content Retrieval - Get sections, modules, and resources from courses
- ๐พ Document Access - Download files and documents with proper authentication
- ๐ Smart Search - Find resources by name across all enrolled courses
- ๐ก๏ธ Error Handling - Comprehensive error handling with automatic token refresh
- ๐ TypeScript - Fully typed for better developer experience
๐ฏ Use Cases
- Study Assistant: Let AI help you navigate course materials
- Content Organization: Search and organize learning resources
- Course Overview: Get quick summaries of course structures
- Resource Discovery: Find specific documents across multiple courses
- Learning Analytics: Analyze course content and structure
๐ Prerequisites
- Node.js 18 or higher
- Moodle Instance with Web Services enabled
- Valid Credentials with API access to your Moodle instance
๐ Installation
Quick Start
# Clone the repository
git clone <repository-url>
cd moodle-mcp
# Install dependencies
npm install
# Build the project
npm run build
Configuration
- Create environment file
cp .env.example .env
- Configure your credentials
MOODLE_URL=https://your-moodle-instance.com
MOODLE_USERNAME=your_username
MOODLE_PASSWORD=your_password
MOODLE_SERVICE=moodle_mobile_app # Optional
Moodle Web Services Setup
Your Moodle instance must have Web Services enabled. If you're a Moodle administrator:
- Navigate to Site administration โ Server โ Web services โ Overview
- Follow the setup wizard to enable web services
- Create or use the built-in
moodle_mobile_appservice - Ensure these functions are enabled:
core_webservice_get_site_infocore_enrol_get_users_coursescore_course_get_coursescore_course_get_contents
๐ฎ Usage
Running the Server
# Production
node dist/index.js
# Development with auto-reload
npm run dev
Integration with Claude Desktop
Add to your Claude Desktop configuration:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"moodle": {
"command": "node",
"args": ["/absolute/path/to/moodle-mcp/dist/index.js"],
"env": {
"MOODLE_URL": "https://your-moodle-instance.com",
"MOODLE_USERNAME": "your_username",
"MOODLE_PASSWORD": "your_password"
}
}
}
}
Available Tools
| Tool | Description |
|---|---|
list_courses |
List all enrolled courses with details |
get_course_contents |
Retrieve complete course structure with sections and modules |
get_course_documents |
Get all downloadable files from a course with direct URLs |
search_resources |
Search for resources by name across all courses |
๐ Detailed documentation: See USAGE.md for comprehensive tool documentation
๐งช Testing
Quick Test
# Run the complete test suite
npm test
Testing Options
| Method | Description |
|---|---|
| Automated Tests | npm test - Full test suite |
| MCP Inspector | Interactive web-based tool testing |
| Standalone Script | Direct API testing without MCP |
| Manual cURL | Test Moodle API endpoints directly |
๐ Full testing guide: See TESTING.md
๐๏ธ Development
Project Structure
moodle-mcp/
โโโ src/
โ โโโ index.ts # MCP server implementation
โ โโโ moodle-client.ts # Moodle API client
โ โโโ types.ts # TypeScript type definitions
โ โโโ test.ts # Standalone test script
โโโ dist/ # Compiled JavaScript
โโโ .env.example # Environment template
โโโ README.md # This file
โโโ USAGE.md # Tool usage guide
โโโ TESTING.md # Testing guide
Commands
# Build the project
npm run build
# Watch mode (auto-rebuild)
npm run watch
# Run tests
npm test
# Development mode
npm run dev
๐ง API Architecture
Authentication Flow
1. Token Generation โ POST /login/token.php
2. API Calls โ GET/POST /webservice/rest/server.php?wstoken={token}
3. File Downloads โ GET /pluginfile.php/...?token={token}
Moodle Web Services
core_webservice_get_site_info- User and site informationcore_enrol_get_users_courses- Enrolled courses listcore_course_get_courses- All available coursescore_course_get_contents- Course structure and resources
๐ Documentation
- USAGE.md - Comprehensive guide to all available tools
- TESTING.md - Testing instructions and methods
- MCP Documentation - Learn more about MCP
๐ Troubleshooting
<details> <summary><strong>Authentication Errors</strong></summary>
- โ
Verify credentials are correct in
.env - โ Ensure Web Services are enabled in Moodle
- โ Check service name matches your Moodle configuration
- โ Verify user has appropriate API access permissions
</details>
<details> <summary><strong>Permission Errors</strong></summary>
- โ Verify user has appropriate role permissions in Moodle
- โ Some resources may be restricted based on enrollment
- โ Check course visibility settings
</details>
<details> <summary><strong>Connection Errors</strong></summary>
- โ Verify Moodle URL is correct and accessible
- โ Check network connection and firewall settings
- โ Ensure Moodle instance accepts API requests
- โ Try accessing Moodle URL directly in browser
</details>
๐ Security
- ๐ Store credentials securely using environment variables
- ๐ Use HTTPS for Moodle connections in production
- ๐ Regularly rotate passwords and tokens
- ๐ Follow your organization's security policies
- โ ๏ธ Never commit
.envfile to version control
๐ค Contributing
Contributions are welcome! Here's how you can help:
- ๐ด Fork the repository
- ๐จ Create a feature branch (
git checkout -b feature/amazing-feature) - ๐พ Commit your changes (
git commit -m 'Add amazing feature') - ๐ค Push to the branch (
git push origin feature/amazing-feature) - ๐ Open a Pull Request
Please ensure your PR:
- โ Includes tests for new features
- โ Updates documentation as needed
- โ Follows existing code style
- โ Passes all tests
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Built with Model Context Protocol SDK
- Powered by Moodle LMS
- TypeScript & Node.js ecosystem
๐ Support
- ๐ Documentation
- ๐ Issue Tracker
- ๐ฌ Discussions
<div align="center">
Made with โค๏ธ for the Moodle and AI community
โญ Star this repo if you find it helpful!
</div>
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.