Skip to main content
Glama
moodle-mcp
by a2br

moodle-mcp

A read-only MCP server that gives AI agents (Claude Code, Claude Desktop, claude.ai…) access to your EPFL Moodle as a student: deadlines, course files, assignments, forums, grades.

It's built for moodle.epfl.ch and for macOS, where it keeps your Moodle key in the Keychain. It isn't affiliated with EPFL or Moodle.

Tools

Tool

What it answers

upcoming_deadlines(days, course?)

What's due soon, and whether Moodle still expects something from you

list_courses(include_past?)

Your courses (code, name, id)

course_overview(course, section?)

Sections and items of a course, with ids

open_item(item_id, pages?)

Any item: PDF text, assignment brief + submission status, page text, forum threads, folder files, links, quizzes

read_file(file_url, pages?)

Text of an attachment or folder file (also saved to ~/.cache/moodle-mcp/files)

search(query, course?)

Find items by name across courses (Moodle's global search is disabled at EPFL)

search_in_files(query, course?)

Full-text search inside course PDFs, code and pages; returns pages + snippets and the call to read just those pages

announcements(days, course?)

Recent posts in Announcements forums

read_discussion(discussion_id)

A full forum thread

grades(course)

Grade items, scores and feedback

whats_new(since?, course?)

New/edited items, files, grades and forum posts since your last check (or 3d, 2w, a date)

sync_course(course, folder?)

Download a course's files, attachments and pages to ~/Moodle/<code> with an INDEX.md; re-runs only fetch changes

Courses accept CS-214, cs214, a numeric id, or part of the name. Courses hidden on your Moodle dashboard are skipped unless named explicitly. The tools only read from Moodle; sync_course writes only to your own disk.

Token use

Long PDFs open as a page map (one line per page, repeated slide builds merged into ranges, plus the PDF outline if it has one); the agent then asks for pages="12-14". A 127-slide deck costs ~1.4k tokens to map instead of ~9k to dump. search_in_files indexes a course's files on first use (text cached in ~/.cache/moodle-mcp/files, refreshed when a file changes on Moodle), so later searches are instant and return only the matching pages.

Related MCP server: fiuba-mcp

Install

You need macOS and uv (it fetches Python 3.12+ itself). Clone this repository, then from its folder:

claude mcp add --scope user moodle -- "$(command -v uv)" --directory "$PWD" run moodle-mcp

For Claude Desktop (chat/Cowork), add the same command to mcpServers in ~/Library/Application Support/Claude/claude_desktop_config.json, with absolute paths:

{
  "mcpServers": {
    "moodle": {
      "command": "/opt/homebrew/bin/uv",
      "args": ["--directory", "/path/to/moodle-mcp", "run", "moodle-mcp"]
    }
  }
}

Then install the key helper (see below) and ask your agent anything about Moodle. Since no key is stored yet, it answers with a link to get one.

sh scripts/install_url_handler.sh

The Moodle key

The server uses a Moodle mobile web service token (the key the Moodle app uses), read from the macOS Keychain item moodle-epfl or from $MOODLE_TOKEN. EPFL's Security keys page doesn't hand one out, so it comes from the app sign-in flow: launch.php redirects a signed-in browser to moodlemobile://token=…. Keys expire from time to time.

Getting or renewing it

When the key has expired, or none is stored yet, tools answer with renewal steps that the agent walks you through. You never paste the key into the chat. With Moodle Key Helper installed (scripts/install_url_handler.sh puts it in ~/Applications), it takes one link:

  1. The local server makes up a random passport, saves it to ~/.cache/moodle-mcp/pending_renewal.json (valid 15 minutes) and gives you launch.php?…&passport=<it>.

  2. You open the link in a browser signed in to Moodle (if you aren't, Moodle carries on after sign-in) and let the browser open Moodle Key Helper. Moodle redirects to moodlemobile://token=…, which holds the key signed with md5(site URL + passport).

  3. The helper runs save_token.py --from-app. It accepts the link only if the signature matches the pending passport, checks the key with Moodle, stores it in the Keychain, sends it to your hosted server if you have one, and confirms with a notification. The running server picks it up on the next call.

Any web page can open a moodlemobile:// link, or send your browser to launch.php with a passport of its own, but it can't know the pending one. So a page can't plant a key (for example, one for another account), and links that arrive when no renewal is pending are ignored.

By hand

Without the helper, the renewal steps also give the manual route, with the same link:

  1. Signed in to moodle.epfl.ch in Chrome, open DevTools → Network (tick Preserve log).

  2. Open the link (any passport works here, e.g. https://moodle.epfl.ch/admin/tool/mobile/launch.php?service=moodle_mobile_app&passport=12345&urlscheme=moodlemobile).

  3. Copy the location: moodlemobile://token=… header of the launch.php 303 response.

  4. python3 scripts/save_token.py and paste it (input is hidden, and the key is never printed).

To revoke the key, reset the "Moodle mobile web service" key on moodle.epfl.ch → Preferences → Security keys, then get a fresh one.

On your phone, the web and cloud sessions (optional)

You can also host the server on fly.io and add it as a claude.ai custom connector. It then works in the Claude mobile apps, claude.ai, Claude Code on the web and routines. Connector calls come from Anthropic's servers, so cloud sandboxes don't need network access to it.

It's the same server with MOODLE_MCP_URL set, which switches it to HTTP behind a small OAuth sign-in (oauth.py). Approving a connection takes a passphrase only you have, and sign-ins are only handed back to Claude (claude.ai / claude.com) or to localhost. sync_course is left out there, since it would save to the server's disk. The file cache, the whats_new marker and sign-ins live on a volume.

Setup (once, with flyctl installed in ~/.fly/bin and logged in):

  1. cp fly.example.toml fly.toml and pick an app name. Set MOODLE_MCP_URL to where it will be served: https://<app>.fly.dev, or your own domain (flyctl certs add). fly.toml is ignored by git.

  2. flyctl apps create <app> and flyctl volumes create moodle_data --region cdg --size 1.

  3. sh scripts/setup_hosted.sh: creates the passphrase (Keychain item moodle-mcp-remote) and sends it and your Moodle key to fly as secrets, without printing either.

  4. flyctl deploy (also after code changes).

  5. On claude.ai: Settings → Connectors → Add custom connector, with your MOODLE_MCP_URL followed by /mcp. When the sign-in page asks, paste the passphrase: security find-generic-password -s moodle-mcp-remote -w | pbcopy

When the Moodle key expires, renew it on your Mac: save_token.py also sends the new key to the hosted server (the app in fly.toml), which restarts with it. The hosted server can't start a renewal on your Mac, so it only gives the manual steps. For the one-link renewal, ask the local server anything about Moodle instead: it uses the same key, so it gives you the link.

To disconnect every client: flyctl ssh console -C "rm /data/oauth.json", then flyctl apps restart <app>.

Configuration

Variable

Default

Purpose

MOODLE_TOKEN

–

Use this key instead of the Keychain (e.g. on the hosted server)

MOODLE_KEYCHAIN_SERVICE

moodle-epfl

Keychain item holding the key

MOODLE_MCP_STATE_DIR

~/.cache/moodle-mcp

File cache, whats_new marker, pending renewal, sign-ins

MOODLE_MCP_URL

–

Public URL; when set, serve over HTTP with OAuth sign-in

MCP_PASSPHRASE

–

Passphrase that approves connections to the hosted server

PORT

8080

HTTP port of the hosted server

License

MIT, see LICENSE. PDF text extraction uses PyMuPDF, which is licensed under the AGPL-3.0 (or a commercial license from Artifex).

Available Tools

12 tools
announcementsA
Read-only

Recent posts in the courses' Announcements (news) forums.

Args:
    days: How far back to look.
    course: Limit to one course (code like "CS-214", id, or name).

Inputs: days, course. Returns: result

course_overviewA
Read-only

Show a course's sections and every item in them (files, assignments, pages, links, forums...) with ids.

Args:
    course: Course code like "CS-214", numeric id, or part of the name.
    section: Only show sections whose number or name matches (e.g. "3" or "Semantics").

Inputs: course (required), section. Returns: result

gradesA
Read-only

Your grades in a course: every grade item with score, range, percentage and feedback.

Args:
    course: Course code like "CS-214", numeric id, or part of the name.

Inputs: course (required). Returns: result

list_coursesA
Read-only

List the courses you're enrolled in, most recently visited first.

Courses hidden on your Moodle dashboard are ones you don't follow; other tools skip them
unless you name them explicitly.

Args:
    include_past: Also list courses whose end date has passed.
    include_hidden: Also list courses hidden on your dashboard.

Inputs: include_past, include_hidden. Returns: result

open_itemA
Read-only

Open any course item by id and return its content.

- file (resource): the extracted text. Long PDFs return a page map (one line per page)
  first; then call again with pages="12-14" for just the pages you need
- assignment: instructions, dates, attachments, your submission status and grade
- page: its text
- forum: latest discussions (read one with read_discussion)
- folder: its files (read one with read_file)
- link (url): the target URL
- quiz: open/close dates, time limit, attempts, best grade

Args:
    item_id: The [id ...] from course_overview, search or upcoming_deadlines.
    pages: For PDFs, which pages to read, e.g. "1-5", "2,4,10-12" or "all".
    max_chars: Maximum characters of file text to return; longer PDFs get a page map.

Inputs: item_id (required), pages, max_chars. Returns: result

read_discussionA
Read-only

Read a whole forum thread (all posts, oldest first).

Args:
    discussion_id: The [discussion ...] id from open_item on a forum, or from announcements.

Inputs: discussion_id (required). Returns: result

read_fileA
Read-only

Download a Moodle file (e.g. an assignment attachment or a file in a folder) and return its text.

Long PDFs return a page map first; call again with pages="12-14" for the pages you need.
Code and text files come back as-is. On the user's Mac the file is also saved locally (path in the output).

Args:
    file_url: A moodle.epfl.ch .../pluginfile.php/... URL from open_item, search_in_files or read_discussion.
    pages: For PDFs, which pages to read, e.g. "1-5", "2,4,10-12" or "all".
    max_chars: Maximum characters of text to return; longer PDFs get a page map.

Inputs: file_url (required), pages, max_chars. Returns: result

search_in_filesA
Read-only

Full-text search inside course files (PDF slides, lecture notes, handouts, code) and pages.

Returns the best-matching pages with a snippet and the exact call to read them, so you can
read only the relevant pages instead of whole files. The first search in a course downloads
and indexes its files (can take a minute); later searches are instant.

Args:
    query: Words that must all appear on the same page, e.g. "big-step semantics".
    course: Limit to one course (recommended); by default searches all ongoing courses.
    max_results: How many matching pages to return.

Inputs: query (required), course, max_results. Returns: result

sync_courseA
Idempotent

Download a course's materials into a local folder, one subfolder per section.

Saves files, folder contents, assignment attachments and pages (as .md), plus an INDEX.md
listing everything with links, due dates and item ids. Only new or changed files are
downloaded, so it's cheap to run again. Nothing on Moodle is changed.

Args:
    course: Course code like "CS-214", numeric id, or part of the name.
    folder: Where to save. Defaults to ~/Moodle/<course code>.
    max_file_mb: Skip files larger than this (e.g. lecture videos).

Inputs: course (required), folder, max_file_mb. Returns: result

upcoming_deadlinesA
Read-only

What's due soon: assignment/quiz deadlines plus other calendar events, with whether you still need to act.

"TODO" means Moodle still expects something from you (e.g. nothing or only a draft submitted);
"done" means it doesn't (already submitted, or nothing to hand in).

Args:
    days: How many days ahead to look.
    course: Limit to one course (code like "CS-214", id, or name).
    include_past_days: Also show deadlines from the last N days (to catch overdue work).

Inputs: days, course, include_past_days. Returns: result

whats_newA
Read-only

What changed in your courses: new or edited items and files, new grades, new forum posts.

By default covers the time since you last called whats_new without `since` (or the last
7 days the first time), then remembers now as the new "last check".

Args:
    since: Look back this far instead: "3d", "12h", "2w", or a date like "2026-09-20".
        Doesn't move the "last check" marker.
    course: Limit to one course (code like "CS-214", id, or name).

Inputs: since, course. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 12 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes: listing courses, deadlines, course content, files, discussions, announcements, grades, search, and sync. However, open_item and read_file both handle file content, and search vs search_in_files could be confused (name search vs full-text search), though descriptions clarify the difference.

    Naming Consistency4/5

    Tool names mostly follow a verb_noun pattern (list_courses, open_item, read_file, read_discussion, sync_course). Minor deviations: 'search' and 'search_in_files' are less consistent than 'search_items'/'search_files', and 'whats_new' lacks an underscore, but overall the pattern is readable and predictable.

    Tool Count5/5

    12 tools is well-scoped for a Moodle assistant covering course browsing, deadlines, content retrieval, search, grades, announcements, and offline sync. Each tool serves a distinct workflow need without redundancy.

    Completeness4/5

    The surface covers the main student workflows: listing courses, viewing deadlines, reading content, searching, checking grades, and syncing. Minor gaps: no tool to submit assignments, create forum posts, or manage calendar events, but these are likely outside the server's read-oriented purpose.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Provides read-only access to a university's Moodle virtual campus, letting an AI assistant browse courses, sections and files, check upcoming deadlines, view assignment status and grades, and read forum announcements and threads. Authentication uses a Moodle token stored locally, with support for both undergraduate and postgraduate campus URLs.
      8
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables an AI agent to access a Moodle Campus Virtual account with the user's own credentials, reading course content, files, forums, notices, calendar, grades and quiz attempts for every enrolled course. Teachers, managers and course creators also get access to other participants' data and to planned, verified write operations such as forums, grading, attendance, quizzes, groups, content and H5P activities.
      4
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Gives AI agents read-only access to a learning platform's courses, assignment details and deadlines, and downloadable course files through the official Web Services API. It automatically works around VPN/DPI network blocking and incomplete TLS certificate chains, and deliberately offers no submission or upload tools.
      8
      MIT