moodle-mcp
moodle-mcp
Moodle用のModel Context Protocol (MCP) サーバー。AIエージェントがWebサービスを介して、レッスン、リソース、アクティビティなどの教育コンテンツをMoodle上で公開・管理できるようにします。冪等性が保証されています。
ステータス: v0.1 MVP。
概要
moodle-mcp は、stdioベースのMCPサーバーです。一連の高レベルなファサードと、低レベルな ws_raw プリミティブを公開し、標準的な教育用「Ficha」(YAMLフロントマター付きのマークダウンファイル)を、Moodleコースのセクション、ページ、リソース、アクティビティとして公開します。すべての書き込みは idnumber によるアップサート(更新または挿入)で行われるため、同じFichaを再公開しても重複が作成されることはありません。
主な利用者: Italicia の言語学習ワークフローを駆動するClaude Desktop。ただし、これは汎用的なオープンソースアダプターであり、MCP対応エージェントとWebサービスが有効なMoodle 4.x/5.xインスタンスであれば誰でも使用できます。
Related MCP server: mcp-moodle
v0.1で公開されているツール
ツール | 目的 |
| コースのスナップショット: メタデータ、セクション、最近MCPで公開されたレッスン、登録者数。 |
| FichaClase(絶対マークダウンパス)をMoodleセクションおよびモジュール更新として公開。 |
| 上記と同様だが、強制的に非表示にし、プレビューURLを返す。 |
| 以前に非表示にしていたセクションとそのモジュールを学生に公開する。 |
| エスケープハッチ: MoodleのWS関数を直接呼び出す。 |
v0.1には含まれていません(v0.2以降で計画中): publicar_ficha_examen, sync_alumnos_csv, HTTP/SSEトランスポート, GIFTビルダー, マルチパートアセットアップロード, 自動モジュール作成。
インストール
# Via npx (recommended for Claude Desktop)
npx -y @marcosnahuel/moodle-mcp
# Or install globally
npm install -g @marcosnahuel/moodle-mcpNode.js 20以上が必要です。
設定 (環境変数)
変数 | 必須 | デフォルト | 説明 |
| はい | — | Moodleインスタンスの完全なHTTPS URL。 |
| はい | — | 編集権限を持つWebサービス用トークン。 |
| いいえ |
| リクエストごとのタイムアウト。 |
| いいえ |
| 一時的な障害時の再試行回数。 |
| いいえ |
| トークンバケットレート制限。 |
| いいえ |
|
|
| いいえ |
|
|
Claude Desktopの設定
claude_desktop_config.json に追加します(OSごとの正確なパスについては examples/setup-claude-desktop.md を参照してください):
{
"mcpServers": {
"moodle": {
"command": "npx",
"args": ["-y", "moodle-mcp"],
"env": {
"MOODLE_URL": "https://your-moodle.example.com",
"MOODLE_WS_TOKEN": "your-ws-token"
}
}
}
}Claude Desktopを再起動します。上記の5つのツールがエージェントから利用可能になるはずです。
例
1. アクションを実行する前にコースのスナップショットを取得する
// tool call
{
"name": "obtener_contexto_curso",
"arguments": { "course_id": 42, "incluir_ultimas_clases": 5 }
}レスポンス(省略):
{
"course": { "id": 42, "fullname": "Italiano A1", "shortname": "ITA-A1", "format": "topics", "startdate": 1700000000 },
"secciones": [{ "id": 100, "name": "Unidad 3", "section": 3, "visible": true, "modules_count": 6 }],
"ultimas_clases": [{ "seccion_id": 100, "seccion_name": "Unidad 3", "ficha_idnumber": "mcp:a9993e364706816aba3e2571" }],
"matriculados": { "total": 18, "docentes": 1, "alumnos": 17 }
}2. FichaClaseを公開する(まずプレビュー)
{
"name": "publicar_preview",
"arguments": {
"ficha_path": "/home/alicia/fichas/italiano/a1-2026/u3/c5.md",
"course_id": 42
}
}レスポンスには、Aliciaが確認のために開くことができる preview_url が含まれています。承認されたら:
{
"name": "confirmar_preview",
"arguments": { "seccion_id": 100, "recursos_ids": [501, 502, 503] }
}3. エスケープハッチ — 生のWS関数を呼び出す
{
"name": "ws_raw",
"arguments": {
"function_name": "core_webservice_get_site_info",
"params": {}
}
}レスポンス:
{ "data": { "sitename": "Aula Italicia", "release": "5.0.2+", ... } }冪等性
このMCPによって作成されるすべてのリソースは、以下の形式の安定した idnumber を持ちます:
mcp:<first 24 chars of sha1(ficha.id + "|" + component_id)>同じFichaを再公開すると、idnumber によって既存のリソースが検索され、その場で更新されます。重複は作成されません。いつでもどこでも安全に再試行できます。
v0.1の注意点
v0.1は、その機能の境界について誠実です。以下のことは確実に行えます:
コース、そのセクション、モジュールの検索。
mcp:idnumberプレフィックスによる「所有」リソースの検索。既存モジュールの可視性の更新(プレビュー → 確認ワークフロー)。
安定した
codeフィールドを持つ構造化されたMoodleエラーの表示。トークンのログ記録やスタックトレースの伝播は行いません。
v0.1ではまだ以下のことはできません:
マルチパートを使用したMoodleドラフトファイル領域へのアセットファイルのアップロード。アセットアップロード用に計画された呼び出しは
advertenciasで報告されます。初回は手動でシードしてください。Webサービスを通じた新しいセクションやモジュールの作成。モジュールがまだ存在しない場合、ツールはステータス
"missing"とadvertenciaを返します。local_wsmanagesections(または同等のもの)をインストールし、それらのエンドポイントを接続するのはv0.2の作業です。
どちらのギャップも、実際のMoodle Dockerに対して実行される tests/integration/ の統合スイートによって推進されます。
開発
git clone https://github.com/marcosnahuel/moodle-mcp
cd moodle-mcp
npm install
npm run typecheck # tsc --noEmit
npm test # vitest unit suite
npm run test:coverage # with v8 coverage (≥80% enforced)
npm run build # tsup → dist/
# Integration — requires docker
docker compose -f tests/integration/docker-compose.test.yml up -d
export MOODLE_TEST_URL=http://localhost:8081
export MOODLE_TEST_TOKEN=<generate in Moodle admin>
export MOODLE_TEST_COURSE=<course id>
npm run test:integration
docker compose -f tests/integration/docker-compose.test.yml down -vセキュリティ
トークンは決してログに記録されません。ログレコードのどのフィールドにトークンが表示されても、
***に置き換えられます。エラーメッセージ内のURLも同様に編集されます。
MOODLE_ALLOW_INSECURE=true(開発用のみ)でない限り、HTTPSが必須です。MCPはWebサービスRESTを介してのみMoodleと通信します。Cookie認証、Webスクレイピング、直接的なDBアクセスは行いません。
貢献
課題、PR、コミットの規約については CONTRIBUTING.md を参照してください。
このプロジェクトに参加することで、CODE_OF_CONDUCT.md を遵守することに同意したものとみなされます。
ライセンス
MIT © 2026 Italicia — LICENSE を参照してください。
Available Tools
5 toolsconfirmar_previewB
Make a previewed section (and optionally a subset of its modules) visible to students. Idempotent.
Inputs: seccion_id (required), recursos_ids.
obtener_contexto_cursoA
Returns a compact radiograph of a Moodle course: metadata, sections with module counts, recent MCP-published lessons, and enrolment counts (teachers vs students). Call this before publishing a Ficha so the agent knows where it fits.
Inputs: course_id (required), incluir_ultimas_clases.
publicar_ficha_claseA
Publish a FichaClase markdown file as a Moodle section with component modules. Idempotent: republishing the same Ficha updates in place, never duplicates. Default modo is oculto (hidden). Use publicar_preview + confirmar_preview for the preview workflow.
Inputs: ficha_path (required), course_id (required), section_id, modo.
publicar_previewA
Publish a FichaClase in hidden preview mode. Returns the same shape as publicar_ficha_clase plus preview_url the teacher can open to review. Students will not see anything until confirmar_preview is called.
Inputs: ficha_path (required), course_id (required).
ws_rawA
Escape hatch: call any Moodle Web Services function with arbitrary parameters. Returns { data } on success, structured meta.code + isError: true on failure. Prefer high-level facades when they cover your use case.
Inputs: function_name (required), params.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a distinct and non-overlapping purpose: obtener_contexto_curso provides course metadata, publicar_ficha_clase publishes a class file, publicar_preview publishes in hidden mode, confirmar_preview makes previews visible, and ws_raw serves as a low-level escape hatch. The descriptions clearly differentiate their roles, with no ambiguity in selection.
Naming is inconsistent with mixed conventions: obtener_contexto_curso and publicar_ficha_clase use Spanish verbs with snake_case, while confirmar_preview and publicar_preview mix Spanish verbs with English terms, and ws_raw is an English abbreviation. There is no uniform pattern across the tool set, making it chaotic and harder to predict.
With 5 tools, the count is well-scoped for the server's purpose of managing Moodle courses. Each tool serves a specific function in the publishing workflow (e.g., preview, confirmation, raw access), and none feel redundant or missing for the apparent scope, making the set appropriately sized.
The tool set covers core workflows for publishing and managing Moodle course content, including metadata retrieval, publishing with preview options, and confirmation. A minor gap exists in lacking direct update or deletion tools for existing content, but agents can work around this using the idempotent publishing tools and the ws_raw escape hatch for other operations.
Maintenance
Related MCP Connectors
Connect any AI agent to 11+ social platforms: schedule, publish & track posts via hosted MCP.
WordPress for AI agents: researched posts, page edits and SEO fields as drafts you approve.
Publish to self-hosted WordPress from AI agents: markdown, images, SEO, and Notion sync.
Manage WordPress blogs and WooCommerce shops from Claude, ChatGPT, Cursor and other MCP apps.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables interaction with Moodle learning management systems through the Moodle REST API. Supports course management, user enrollment, assignments, forums, quizzes, and file operations through natural language.MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to interact with Moodle via web services, allowing tasks like listing courses, assignments, events, and downloading files.1066 PyPI5MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with Moodle LMS via the Moodle REST API, supporting management of courses, users, enrollments, grades, and content.1GPL 3.0
- AlicenseAqualityDmaintenanceMCP server for Moodle that lets AI agents publish and manage pedagogical content — courses, lessons, quizzes, forums — via Moodle Web Services with idempotency.45MIT