Moodle MCP Server

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.

Category
Visit Server

README

<div align="center">

๐ŸŽ“ Moodle MCP Server

Model Context Protocol integration for Moodle LMS

License: MIT TypeScript Node.js MCP PRs Welcome

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

  1. Create environment file
cp .env.example .env
  1. 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:

  1. Navigate to Site administration โ†’ Server โ†’ Web services โ†’ Overview
  2. Follow the setup wizard to enable web services
  3. Create or use the built-in moodle_mobile_app service
  4. Ensure these functions are enabled:
    • core_webservice_get_site_info
    • core_enrol_get_users_courses
    • core_course_get_courses
    • core_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 information
  • core_enrol_get_users_courses - Enrolled courses list
  • core_course_get_courses - All available courses
  • core_course_get_contents - Course structure and resources

๐Ÿ“š Documentation

๐Ÿ› 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 .env file to version control

๐Ÿค Contributing

Contributions are welcome! Here's how you can help:

  1. ๐Ÿด Fork the repository
  2. ๐Ÿ”จ Create a feature branch (git checkout -b feature/amazing-feature)
  3. ๐Ÿ’พ Commit your changes (git commit -m 'Add amazing feature')
  4. ๐Ÿ“ค Push to the branch (git push origin feature/amazing-feature)
  5. ๐ŸŽ‰ 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

๐Ÿ“ž Support


<div align="center">

Made with โค๏ธ for the Moodle and AI community

โญ Star this repo if you find it helpful!

</div>

Recommended Servers

playwright-mcp

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured