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: Moodle MCP Server
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.
| Name | Required | Description | Default |
|---|---|---|---|
| seccion_id | Yes | ||
| recursos_ids | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden. It discloses idempotency (a key behavioral trait) and the optional nature of 'recursos_ids'. However, it misses critical details like required permissions, whether changes are reversible, or potential side effects on student access, which are important for a visibility-changing tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise—one sentence plus a note on idempotency—with zero wasted words. It front-loads the core action ('Make visible') and efficiently covers key aspects. Every element earns its place, making it highly readable and focused.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no annotations, 0% schema coverage, and no output schema, the description is incomplete. It lacks details on permissions, error conditions, return values, or how visibility changes affect students. For a tool that modifies student access, this leaves significant gaps in understanding its full impact and usage context.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It mentions 'seccion_id' and 'recursos_ids' (modules subset) but provides no semantic context—e.g., what a 'seccion_id' represents or how 'recursos_ids' relate to modules. This adds minimal value beyond the bare schema, failing to adequately address the coverage gap.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb ('Make visible') and resource ('previewed section'), specifying the action of revealing content to students. It distinguishes from siblings like 'publicar_preview' by focusing on confirming visibility rather than initial publishing. However, it doesn't explicitly differentiate from all siblings, keeping it at 4 instead of 5.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage when a section is previewed and needs to be made visible, with optional module selection via 'recursos_ids'. It mentions idempotency, suggesting safe repeated use. However, it lacks explicit when-not-to-use guidance or clear alternatives among siblings like 'publicar_ficha_clase', leaving room for ambiguity.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| course_id | Yes | ||
| incluir_ultimas_clases | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It describes the tool as a read-only operation ('returns') and specifies the scope of data returned, which is helpful. However, it doesn't mention potential limitations like permissions needed, error conditions, or rate limits, leaving some behavioral aspects unclear for a tool with no annotation coverage.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is front-loaded with the core purpose in the first sentence and follows with a clear usage guideline. Every sentence adds value without redundancy, making it efficiently structured and appropriately sized for the tool's complexity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description provides good context on purpose and usage. It explains what the tool returns and when to use it, which is sufficient for a read-only tool. However, without an output schema or annotations, it could benefit from more details on return format or error handling, slightly limiting completeness.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 0% schema description coverage, the description must compensate for undocumented parameters. It explains the purpose of the tool's output but doesn't directly describe the parameters. However, the context ('compact radiograph of a Moodle course') and the parameter names ('course_id', 'incluir_ultimas_clases') are intuitive, and the description implies the tool fetches course-specific data, adding some semantic value. Since there are only 2 parameters, this partial compensation earns a 4.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose with specific verbs ('returns a compact radiograph') and resources ('Moodle course'), detailing exactly what information is provided (metadata, sections with module counts, recent MCP-published lessons, enrolment counts). It distinguishes this tool from siblings by explaining its preparatory role for publishing a Ficha, making it highly specific and differentiated.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly states when to use this tool ('Call this before publishing a Ficha so the agent knows where it fits'), providing clear context and purpose. It distinguishes it from sibling tools by positioning it as a preparatory step for publishing operations, offering specific guidance on its role in the workflow.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| ficha_path | Yes | ||
| course_id | Yes | ||
| section_id | No | ||
| modo | No | oculto |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden and adds valuable behavioral context: it discloses idempotency ('republishing the same Ficha updates in place, never duplicates'), default behavior ('Default modo is `oculto`'), and workflow relationships. It doesn't mention error conditions or permissions, leaving some gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Three sentences, each essential: first states purpose, second covers idempotency and default, third provides workflow guidance. No wasted words, front-loaded with core functionality.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a 4-parameter mutation tool with no annotations or output schema, the description is strong but not fully complete: it explains key behaviors (idempotency, defaults, workflow) but lacks details on error handling, response format, or side effects. Given the complexity, it's above minimum viable but could be more comprehensive.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It explains the 'modo' parameter's default value and meaning ('oculto' means hidden), and implies 'ficha_path' refers to a markdown file. It doesn't detail 'course_id' or 'section_id' semantics, but the tool name and context provide some inference.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb ('Publish') and resource ('a FichaClase markdown file as a Moodle section with component modules'), distinguishing it from siblings like 'publicar_preview' (preview workflow) and 'confirmar_preview' (confirmation step). It specifies the exact transformation from input to output.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It explicitly provides when-to-use guidance: 'Use `publicar_preview` + `confirmar_preview` for the preview workflow' distinguishes this as the final publishing tool versus preview alternatives. It also mentions the default mode ('oculto') as a usage hint.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| ficha_path | Yes | ||
| course_id | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: it's a mutation tool (implied by 'Publish'), returns a specific shape (similar to 'publicar_ficha_clase' plus a 'preview_url'), and has side effects (creating a hidden preview accessible only to teachers). However, it lacks details on permissions, error handling, or rate limits, which are important for a mutation tool without annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is highly concise and well-structured in two sentences. The first sentence states the core action and return value, while the second clarifies the preview state and next steps. Every word earns its place, with no redundancy or fluff, making it easy to parse and understand quickly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (a mutation with preview functionality), no annotations, no output schema, and low schema coverage, the description does a good job covering the core behavior and workflow. It explains the preview mode, return shape, and relationship to 'confirmar_preview'. However, it misses details like error cases or the exact return structure, which could be important for agent invocation without an output schema.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 2 parameters with 0% description coverage, so the schema provides no semantic information. The description does not explain what 'ficha_path' or 'course_id' represent, their formats, or constraints beyond the schema's basic types. It adds no parameter-specific meaning, but since there are only 2 parameters, the baseline is slightly higher than minimal, though it fails to compensate for the lack of schema descriptions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the specific action ('Publish a FichaClase in hidden preview mode') and resource ('FichaClase'), distinguishing it from sibling tools like 'publicar_ficha_clase' (which likely publishes publicly) and 'confirmar_preview' (which confirms the preview). It explicitly mentions the preview mode and the target audience (teacher vs. students), making the purpose distinct and well-defined.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides explicit guidance on when to use this tool: for publishing in 'hidden preview mode' that teachers can review, and it specifies an alternative ('confirmar_preview') for making it visible to students. It also implies when not to use it (e.g., for direct student access or final publication without preview), offering clear context for tool selection.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| function_name | Yes | ||
| params | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the transparency burden. It discloses the return shape: 'Returns `{ data }` on success, structured `meta.code` + `isError: true` on failure,' giving agents a concrete expectation of both success and error behavior. The 'escape hatch' metaphor additionally signals that this tool bypasses typical facades, though it does not detail potential side effects or validation behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is composed of two tightly crafted sentences. The first front-loads the core purpose, and the second packs in return format and usage guidance. There is no filler or repetition of schema details.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a generic escape-hatch tool, the description covers the essentials: what it does, when to prefer alternatives, and the shape of success/failure responses. It could also warn that function calls are not validated and may have destructive effects, but the 'escape hatch' label and the nudge toward high-level facades partially cover that.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate by explaining parameter meaning. It only says 'with arbitrary parameters,' which essentially repeats the free-form nature of the `params` object already visible in the schema. It does not explicitly state that `params` are passed directly to the Moodle function or how they map to function arguments, leaving a significant gap for a tool that is inherently parameter-driven.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with 'Escape hatch: call any Moodle Web Services function with arbitrary parameters,' which clearly and specifically identifies the tool's purpose and scope. This distinguishes it from high-level sibling tools that each target a single Moodle operation, positioning ws_raw as a generic passthrough.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The closing sentence, 'Prefer high-level facades when they cover your use case,' gives explicit guidance on when to use this tool versus the alternatives. It also labels the tool an 'escape hatch,' which implies it should be a fallback option, not the first choice.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
5 tool updates
v0.1.0- First observed
confirmar_preview - First observed
obtener_contexto_curso - First observed
publicar_ficha_clase - First observed
publicar_preview - First observed
ws_raw
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 your Moodle to AI assistants: courses, content, grading and reports from the chat.
Create, edit, translate, and export SCORM eLearning modules from a connected AI assistant.
AI-powered LMS course builder: 89 tools, 17 skills, SCORM/xAPI export, agentic UI
Connect any AI agent to 11+ social platforms: schedule, publish & track posts via hosted MCP.
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.15 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables interaction with Moodle learning management systems through the REST API. Supports course management, user enrollment, assignment handling, and forum operations through natural language.15 npmMIT
- AlicenseAqualityCmaintenanceEnables AI assistants to interact with Moodle via web services, allowing tasks like listing courses, assignments, events, and downloading files.104MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with Moodle LMS via the Moodle REST API, supporting management of courses, users, enrollments, grades, and content.GPL 3.0