Skip to main content
Glama

moodle-mcp

Moodle用のModel Context Protocol (MCP) サーバー。AIエージェントがWebサービスを介して、レッスン、リソース、アクティビティなどの教育コンテンツをMoodle上で公開・管理できるようにします。冪等性が保証されています。

CI npm license: MIT

ステータス: 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で公開されているツール

ツール

目的

obtener_contexto_curso

コースのスナップショット: メタデータ、セクション、最近MCPで公開されたレッスン、登録者数。

publicar_ficha_clase

FichaClase(絶対マークダウンパス)をMoodleセクションおよびモジュール更新として公開。

publicar_preview

上記と同様だが、強制的に非表示にし、プレビューURLを返す。

confirmar_preview

以前に非表示にしていたセクションとそのモジュールを学生に公開する。

ws_raw

エスケープハッチ: 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-mcp

Node.js 20以上が必要です。

設定 (環境変数)

変数

必須

デフォルト

説明

MOODLE_URL

はい

—

Moodleインスタンスの完全なHTTPS URL。

MOODLE_WS_TOKEN

はい

—

編集権限を持つWebサービス用トークン。

MOODLE_WS_TIMEOUT_MS

いいえ

30000

リクエストごとのタイムアウト。

MOODLE_WS_MAX_RETRIES

いいえ

3

一時的な障害時の再試行回数。

MOODLE_WS_RATE_LIMIT_PER_SEC

いいえ

10

トークンバケットレート制限。

MCP_LOG_LEVEL

いいえ

info

error / warn / info / debug。

MOODLE_ALLOW_INSECURE

いいえ

false

http:// URLを許可(開発用エスケープハッチ)。

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 tools
confirmar_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

    A3.9/5.0

    Scored across 5 tools

    Disambiguation5/5

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

    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.

    Tool Count5/5

    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.

    Completeness4/5

    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

    ActivityInactive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables 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