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
访问服务器

README

<div align="center">

🎓 Moodle MCP Server

Model Context Protocol integration for Moodle LMS

License: MIT TypeScript Node.js MCP PRs Welcome

FeaturesInstallationUsageDocumentationContributing

</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>

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选