open-moodle
Connects to a Moodle instance via its REST API, allowing users to check their profile, list enrolled courses, inspect course sections and resources, read course materials such as PDFs, DOCX, PPTX, and text files as extracted text, view upcoming deadlines, fetch announcements and notifications, and access assignment details and submission status.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@open-moodlewhat assignments do I have due this week?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
open-moodle
A client and Model Context Protocol (MCP) server for Moodle. It enables AI coding assistants and terminal users to inspect courses, read materials, track deadlines, search lecture slides, analyze attendance thresholds, and view announcements directly through Moodle's REST API.
The Problem
Connecting AI models to university Moodle portals usually fails due to practical design hurdles:
Restricted Token Pages: Universities routinely disable
/user/managetoken.php, preventing students from generating API tokens through the web interface.Missing Document Parsing: Most existing tools only return raw file URLs. External AI models cannot open links behind authenticated intranets, preventing them from reading syllabi, lecture slides, or assignment briefs.
Context Window Blowups: Downloading multi-megabyte PDFs and slide decks into conversational contexts stalls requests and burns tokens.
Silent Error Swallowing: Generic wrappers often catch API exceptions and return empty lists, misleading the assistant into claiming you have no courses, deadlines, or assignments when an API function is merely disabled.
Token Leakage: Moodle attaches secret tokens to download links in API responses. Without explicit sanitization, those tokens leak into chat transcripts, system logs, and model context windows.
open-moodle addresses these issues directly:
Obtains active tokens via the Moodle mobile authentication endpoint or browser-assisted SSO launch flow.
Indexes course documents locally into an embedded SQLite FTS5 full-text search engine for sub-second keyword lookups without re-downloading files into model context.
Streams and extracts text from PDFs (via PyMuPDF), Word documents (
.docx), and PowerPoint presentations (.pptx) with strict size limits and page windowing.Strips
tokenandwstokenfrom course, calendar, notification, and search URLs, and from error text, before returning data to the model. File downloads are limited to this site'spluginfile.php.Checks whitelisted capabilities and reports informative messages if a university disables a specific endpoint.
Related MCP server: Canvas LMS MCP Server
Features
Model Context Protocol Server: Compatible with Antigravity (
agy), Claude Desktop, Cursor, Grok, and Zed over standard input/output (stdio).Attendance from the gradebook: Reads grade items named attendance and compares them with your cutoff. Safe-bunk and recovery math runs only when real session counts are present. Student tokens cannot read the attendance plugin's session register.
Local full-text search: Embedded SQLite FTS5 index gives sub-second BM25 keyword search across course PDFs, slides, and docs. No separate search server. Indexing stores every page, not a 20-page window.
Bulk Course Downloader: Downloads course files organized into topic directories, skipping unmodified files automatically.
In-Memory Document Extraction: Converts PDFs, Word
.docx, and PowerPoint.pptxslide decks directly into text without external system dependencies like LibreOffice.Bounded Downloads: Caps file transfers at 25MB and supports windowed reading (
start_pageandmax_pages) to protect context windows.Assignment Submission Status: Checks whether you turned in each assignment (
submitted,draft,new) alongside due dates and grading states.Course Announcements & Briefing: Pulls genuine instructor posts from course news forums, and offers a single-call
moodle_brieftool summarizing deadlines, attendance alerts, notifications, and active courses.Interactive Browser SSO: Opens Moodle's mobile launch page and captures
openmoodle://token=...after checking the passport. A temporary URL handler is registered on macOS, Linux, and Windows; you can also paste the link.Terminal CLI: Run commands like
open-moodle attendance,open-moodle search,open-moodle download, oropen-moodle briefdirectly in your shell.Zero-Install Execution: Works instantly with
uvx open-moodleor via standardpip/pipx.
Installation
From GitHub (Recommended)
Run or install directly from the repository using uv or pip:
# Run directly without installing (via uvx)
uvx --from git+https://github.com/sonstellar969/open-moodle.git open-moodle --help
# Or install globally into your PATH
uv tool install git+https://github.com/sonstellar969/open-moodle.git
# Or via pip
pip install git+https://github.com/sonstellar969/open-moodle.gitLocal Development / From Source
git clone https://github.com/sonstellar969/open-moodle.git
cd open-moodle
uv tool install --editable .Authentication
open-moodle resolves credentials using the following precedence:
Command-line flags (
--url,--token)Environment variables (
MOODLE_URL,MOODLE_TOKEN)Local configuration file (
~/.config/open-moodle/config.json)
Interactive Password Login
open-moodle loginPrompts for your Moodle site URL, student username, and password. The tool queries /login/token.php for a mobile web service token and stores it locally with user-only permissions (0600).
Campus SSO Login (Microsoft / Google)
If your institution uses Single Sign-On (SSO):
open-moodle login --ssoThis launches your default browser to Moodle's mobile launch endpoint, starts a temporary local listener, captures the token redirect, and saves it automatically.
Direct Token Configuration
If you already have a token:
open-moodle login --url "https://lms.university.edu" --token "YOUR_TOKEN"For detailed guidance, read the Authentication Guide.
MCP Server Setup
Configure open-moodle in your preferred AI assistant.
Antigravity CLI (agy)
If installed globally via uv tool install:
agy mcp add moodle open-moodle mcpOr directly from GitHub without installing:
agy mcp add moodle uvx --from git+https://github.com/sonstellar969/open-moodle.git open-moodle mcp(If credentials are saved via open-moodle login, they are loaded automatically. Otherwise, pass --env MOODLE_URL=... --env MOODLE_TOKEN=....)
Claude Desktop
Add this block to claude_desktop_config.json:
{
"mcpServers": {
"moodle": {
"command": "open-moodle",
"args": ["mcp"],
"env": {
"MOODLE_URL": "https://lms.university.edu/webservice/rest/server.php",
"MOODLE_TOKEN": "YOUR_MOODLE_TOKEN"
}
}
}
}(Or use "command": "uvx" with "args": ["--from", "git+https://github.com/sonstellar969/open-moodle.git", "open-moodle", "mcp"])
Grok
Grok Build reads ~/.grok/config.toml, not Claude's config file. If you already ran open-moodle login, the server picks up the saved token and you can omit the environment variables.
grok mcp add moodle -- open-moodle mcpOr, in ~/.grok/config.toml:
[mcp_servers.moodle]
command = "open-moodle"
args = ["mcp"]Cursor
Add to your project's .cursor/mcp.json or configure under Cursor Settings -> Features -> MCP:
{
"mcpServers": {
"moodle": {
"command": "open-moodle",
"args": ["mcp"],
"env": {
"MOODLE_URL": "https://lms.university.edu/webservice/rest/server.php",
"MOODLE_TOKEN": "YOUR_MOODLE_TOKEN"
}
}
}
}Local & Open-Source Models (LM Studio, Continue.dev, Ollama, LibreChat)
You can run open-moodle with 100% local, open-source models (such as Qwen 2.5, Llama 3.1/3.3, and Mistral) to ensure your campus lecture notes, assignments, attendance, and grades remain strictly on your machine without cloud subscriptions.
Recommended Local Models for Tool Calling
Qwen 2.5 (
qwen2.5:7b/14b): Best-in-class precision for function calling on consumer hardware.Llama 3.1 / 3.3 (
llama3.1:8b/70b): Strong general-purpose reasoning with native tool output.Mistral Nemo (
mistral-nemo:12b): Robust function calling with large context support.
LM Studio Setup
Open LM Studio -> navigate to the Developer / MCP tab.
Add the server definition:
{ "mcpServers": { "open-moodle": { "command": "open-moodle", "args": ["mcp"] } } }Load a tool-compatible model (e.g.,
qwen2.5-7b-instruct) and ask: "Check my attendance" or "Search my course notes for virtual memory".
Continue.dev (VS Code / JetBrains) Setup
Add open-moodle under experimental.modelContextProtocolServers in ~/.continue/config.json:
{
"models": [
{
"title": "Ollama - Qwen 2.5 7B",
"provider": "ollama",
"model": "qwen2.5:7b"
}
],
"experimental": {
"modelContextProtocolServers": [
{
"transport": {
"type": "stdio",
"command": "open-moodle",
"args": ["mcp"]
}
}
]
}
}LibreChat Setup
In your librechat.yaml:
mcpServers:
open-moodle:
type: stdio
command: open-moodle
args:
- mcpFor advanced usage, Goose CLI agent setup, and custom Python scripts with Ollama, see the Local Models Guide.
See the Client Setup Guide for instructions covering Claude Code, Windsurf, and Zed.
MCP Tools Provided
The server exposes 14 tools:
Tool | Parameters | Purpose |
|
| Consolidated student briefing: enrolled courses, attendance alerts, deadlines, and notifications. |
|
| Fetches course attendance with percentage and safe bunks / recovery targets. |
|
| Sub-second full-text BM25 search across indexed course slides, PDFs, and notes. |
|
| Indexes all text materials for a course into local SQLite FTS5 database. |
| None | Checks connection and returns student profile metadata and allowed API count. |
| None | Returns enrolled courses with numeric IDs, full titles, and short codes. |
|
| Outlines syllabus sections, modules, and resources (with sanitized URLs). |
|
| Downloads and parses a PDF, DOCX, PPTX, or text file with page range support. |
|
| Returns scheduled quizzes, assignments, and calendar events. |
|
| Lists assignments, due dates, submission states ( |
|
| Fetches instructor announcements and posts from the course Announcements forum. |
|
| Pulls grade items, marks, percentages, and teacher feedback. |
|
| Fetches recent system bell alerts and personal notices. |
| None | Lists which web service functions this token can call, and which features those functions unlock. |
CLI Commands Reference
All commands accept global flags --url <URL> and --token <TOKEN> to override saved credentials or environment variables on the fly.
Command Overview
Command | Arguments & Flags | Description |
|
| Authenticates with Moodle and stores credentials in |
| None | Displays authenticated student name, user ID, university site, Moodle version, and whitelisted APIs. |
| None | Lists all enrolled courses with numeric course IDs, short codes, and full course names. |
|
| Displays per-course attendance records with safe bunks allowed or classes needed to hit target percentage. |
|
| Consolidated student dashboard: active courses, attendance alerts, upcoming deadlines, and unread alerts. |
|
| Lists upcoming actionable calendar deadlines, pending assignment submissions, and quizzes. |
|
| Fetches genuine instructor posts and discussion topics from the course Announcements forum. |
|
| Displays recent personal system bell notifications with read/unread statuses. |
|
| Pulls student grade items, marks, display percentages, grade ranges, and instructor feedback. |
|
| Downloads and indexes course slides, PDFs, Word docs, and notes into local SQLite FTS5 database. |
|
| Sub-millisecond BM25 keyword search across locally indexed course slides and notes with excerpts. |
|
| Bulk downloads all course files into topic folders, automatically skipping unmodified files. |
|
| Downloads and extracts readable text directly from a remote file URL with page windowing. |
| None | Shows which Moodle web services this token can call. |
| None | Runs the Model Context Protocol (MCP) server over standard input/output (stdio) for AI assistants. |
Detailed Command Guide
1. open-moodle login
Authenticates with your university's Moodle portal.
Password login: prompts for URL, student ID, and password, acquiring a token from
/login/token.php:open-moodle loginCampus SSO login: opens Moodle's mobile launch page (
urlscheme=openmoodle). Moodle redirects toopenmoodle://token=<base64>. The payload ismd5(wwwroot + passport):::token, and a mismatch is rejected. Paste the link if the temporary URL handler does not catch it:open-moodle login --ssoManual token: save an existing token directly:
open-moodle login --url "https://lms.university.edu" --token "YOUR_TOKEN"
2. open-moodle whoami
Verifies connection and prints student profile metadata:
open-moodle whoamiopen-moodle doctor prints the same connection plus a line for each feature (courses, calendar, grades, forums, attendance) and whether the required web service is enabled.
3. open-moodle courses
Lists all courses you are enrolled in with their numeric Course IDs (needed for other commands):
open-moodle courses4. open-moodle attendance
Shows course attendance with target threshold analytics (default 75%):
# Check against standard 75% cutoff
open-moodle attendance
# Check against custom threshold (e.g., 80% or 85%)
open-moodle attendance --threshold 80.0Most student tokens only receive a gradebook percentage. In that case the table shows the percentage and does not invent session counts or safe bunks.
When a record includes real attended and total session counts:
For courses at or above the threshold: safe bunks remaining are $\lfloor \frac{\text{attended} - T \times \text{total}}{T} \rfloor$.
For courses below the threshold: consecutive classes needed are $\lceil \frac{T \times \text{total} - \text{attended}}{1 - T} \rceil$.
A 100% target cannot be recovered after a session has already been missed.
5. open-moodle brief
Single-screen student briefing summarizing everything you need to know for the coming week:
open-moodle brief --days 7Includes: active course count, attendance danger alerts (<75%), upcoming deadlines, and unread notifications.
6. open-moodle deadlines
Lists actionable calendar events and deadlines:
open-moodle deadlines --days 147. open-moodle announcements
Pulls actual instructor posts from the course Announcements forum (unlike bell notifications, which are generic):
open-moodle announcements 201 --limit 58. open-moodle notifications
Lists system bell alerts and personal notices:
open-moodle notifications --limit 109. open-moodle grades
Displays gradebook items, marks, ranges, and teacher feedback:
# View grades across all enrolled courses
open-moodle grades
# View grades for a specific course ID
open-moodle grades --course 20110. open-moodle sync
Downloads and indexes course materials into a local SQLite FTS5 database (~/.cache/open-moodle/search_index.db). Once indexed, you can search topics without re-downloading files:
open-moodle sync 20111. open-moodle search
Fast local keyword search across indexed PDFs, slides, and docs. Results include the page or slide and a token-free file URL:
# Search across all indexed courses
open-moodle search "virtual memory"
# Search within a specific course
open-moodle search "CPU scheduling" --course 201 --limit 512. open-moodle download
Bulk downloads all materials for a course into topic folders (e.g., 01_Syllabus/, 02_Process_Scheduling/):
# Downloads into ./course_201_materials by default
open-moodle download 201
# Downloads into custom directory
open-moodle download 201 --dest ./OS-Notes13. open-moodle read
Downloads a remote Moodle file URL and extracts clean readable text in terminal:
open-moodle read "https://lms.university.edu/webservice/pluginfile.php/123/mod_resource/content/1/notes.pdf" --start 1 --pages 1014. open-moodle doctor
Prints which web services this token can call:
open-moodle doctor15. open-moodle mcp
Launches the Model Context Protocol (MCP) stdio server for AI assistants (Antigravity, Claude, Cursor, Grok, Zed):
open-moodle mcpArchitecture & Storage
Configuration: Credentials are saved to
~/.config/open-moodle/config.json. The file is created with mode0600.Search Index: SQLite FTS5 database at
~/.cache/open-moodle/search_index.db(orOPEN_MOODLE_CACHE_DIR), created with mode0600. Sync indexes every page of a PDF or slide deck..docand.pptfiles are skipped. Re-sync drops files that disappeared from the course. Search hits include the page label and a URL with the token removed.Downloads: File fetches are limited to
pluginfile.phpon the configured Moodle host. A URL on any other host is refused, so a tool call cannot send your token elsewhere.Read-only client: The commands do not submit assignments, change grades, or post to forums. The saved value is still a
moodle_mobile_apptoken, and that service can allow writes on some sites. Treat the config file like a password.
Documentation
Local & Open-Source Models Guide: Setup for Ollama, LM Studio, Continue.dev, Open WebUI, and LibreChat.
Authentication & Token Guide: Mobile token acquisition, SSO launch flow, and troubleshooting.
Client Setup Guide: Config examples for Antigravity, Claude, Cursor, Grok, and others.
Moodle API Reference: Standard REST web service functions used under the hood.
License
MIT License. See LICENSE for details.
Text extraction from PDFs uses PyMuPDF, which is licensed under AGPL-3.0. That license applies to PyMuPDF itself when you install the dependency.
This server cannot be deployed
Maintenance
Related MCP Connectors
Read-only access to Epivo's live course catalogue for AI agents.
Search university course materials, your flashcards, quizzes, streak and quota. All tools read-only.
Create, edit, translate, and export SCORM eLearning modules from a connected AI assistant.
Manage your Canvas coursework with quick access to courses, assignments, and grades. Track upcomin…
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables AI systems to interact with Canvas Learning Management System data, allowing users to access courses, assignments, quizzes, planner items, files, and syllabi through natural language queries.227MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to access Canvas LMS course content, including assignments, modules, announcements, and files, to help students manage their coursework.5 npmISC
- FlicenseBqualityBmaintenanceEnables AI assistants to act as teaching assistants for Canvas LMS, allowing them to browse courses, read student submissions (including PDF/DOCX), grade with rubrics, post announcements, manage modules and pages, and more.64-
- FlicenseNot gradedqualityBmaintenanceEnables AI assistants to interact with a student's Canvas LMS account, supporting course viewing, grade checks, assignment submissions, announcements, discussions, calendar events, inbox messages, and more via specialized tools.1-