moodle-cli 0.5.5 → 0.7.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ONBOARDING.md +54 -0
- package/README.md +144 -85
- package/SKILL.md +25 -154
- package/agents/openai.yaml +4 -0
- package/dist/moodle.js +5854 -1221
- package/dist/worker/worker.js +23629 -0
- package/package.json +17 -11
- package/references/command-reference.md +48 -0
- package/references/coursework-and-grades.md +45 -0
- package/references/deadlines-and-alerts.md +25 -0
- package/references/downloads.md +38 -0
- package/references/forums.md +57 -0
- package/references/maintenance.md +31 -0
- package/references/output-and-errors.md +31 -0
- package/references/profile-and-courses.md +27 -0
- package/references/setup-and-auth.md +91 -0
package/ONBOARDING.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: moodle-cli-onboarding
|
|
3
|
+
description: Help a student set up moodle-cli through a short conversation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# moodle-cli onboarding
|
|
7
|
+
|
|
8
|
+
You are helping a student connect their university Moodle account to `moodle-cli`. Take ownership of the setup. Keep commands and configuration details out of the conversation unless the student asks or you need their help with an error.
|
|
9
|
+
|
|
10
|
+
## Start the conversation
|
|
11
|
+
|
|
12
|
+
Use the student's language and begin with one question:
|
|
13
|
+
|
|
14
|
+
> What is your university's Moodle URL? You can paste any Moodle page you use, such as the dashboard, a course, or the login page.
|
|
15
|
+
|
|
16
|
+
Wait for the answer before doing setup work. Do not ask the student to find the site origin, remove part of the URL, choose a runtime, or edit a configuration file.
|
|
17
|
+
|
|
18
|
+
## Handle the setup
|
|
19
|
+
|
|
20
|
+
Once the student shares a URL, complete the setup on their computer:
|
|
21
|
+
|
|
22
|
+
- Check for Node.js 22+ and Bun. Install `moodle-cli` with the runtime available on the computer. Use `bunx --bun moodle-cli` as the command prefix when Bun is the only runtime.
|
|
23
|
+
- Follow redirects and resolve the URL to the final Moodle origin in the form `https://host`. Remove the path, query, and fragment. Confirm that the origin serves Moodle before saving it.
|
|
24
|
+
- Read `~/.config/moodle-cli/config.yaml` if it exists. Set `base_url` to the verified origin and preserve the other settings.
|
|
25
|
+
- Tell the student that Moodle may open in their browser and that you will wait while they complete their university sign-in. Run `moodle auth login`. If a browser opens, let the student finish SSO there, then continue when the command returns.
|
|
26
|
+
- Verify the account with `moodle user --json` and `moodle overview --json`. Diagnose configuration or authentication failures and retry before reporting success. If browser sign-in times out, run `moodle auth login` again after the student is ready.
|
|
27
|
+
- Set up session renewal after verification. On macOS, run `moodle auth keepalive install` and confirm it with `moodle auth keepalive status --json`. On Linux, schedule `moodle auth keepalive --json` every 30 minutes with cron. On other systems, use the operating system scheduler for the same command or explain how to renew with `moodle auth keepalive`.
|
|
28
|
+
- Install the bundled agent skill with `moodle skills add`. In a Bun-only environment, use `bunx --bun skills add https://github.com/bunizao/moodle-cli`.
|
|
29
|
+
|
|
30
|
+
Do not ask the student to copy a Moodle cookie, `sesskey`, browser database, or API token into the conversation. Do not print credentials. Keep the Moodle session on the student's computer.
|
|
31
|
+
|
|
32
|
+
## Offer remote access
|
|
33
|
+
|
|
34
|
+
After local verification succeeds, ask:
|
|
35
|
+
|
|
36
|
+
> Do you have a Cloudflare account? I can use it to deploy a private remote MCP server, which lets supported web AI clients connect to your Moodle.
|
|
37
|
+
|
|
38
|
+
If the student declines or has no account, finish the onboarding with local access. Mention that they can add remote access later.
|
|
39
|
+
|
|
40
|
+
If the student wants remote access, run `moodle mcp deploy`. Let them complete Cloudflare authorization in the browser when Wrangler requests it. The deployment command manages Worker creation, encrypted Moodle session upload, local renewal, and supported client configuration.
|
|
41
|
+
|
|
42
|
+
Verify the deployment with `moodle mcp status --json`. Continue troubleshooting until the command reports that the Worker and Moodle session are ready. Ask which web AI client the student wants to use, then guide them through that client's current custom MCP connection flow. Put access credentials into the client's connection settings, not the chat.
|
|
43
|
+
|
|
44
|
+
## Finish with something useful
|
|
45
|
+
|
|
46
|
+
After both verification commands succeed, run `moodle todo --days 14 --json`. Summarize the student's upcoming work in the language they used.
|
|
47
|
+
|
|
48
|
+
End with three requests they can try next, adapted to the Moodle data you found:
|
|
49
|
+
|
|
50
|
+
- “Plan my Moodle work for this week.”
|
|
51
|
+
- “Download the slides from this Moodle link.”
|
|
52
|
+
- “Find forum posts about the next assessment.”
|
|
53
|
+
|
|
54
|
+
If the student has no upcoming items, say so and use their enrolled units to suggest relevant requests. Report the verified Moodle site and account, but omit session values and internal credentials.
|
package/README.md
CHANGED
|
@@ -1,155 +1,214 @@
|
|
|
1
1
|
# moodle-cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Give your AI agent access to Moodle.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Let it keep up with deadlines and grades, fetch course files, and search forum discussions. `moodle-cli` finds your active browser session and keeps it alive in the background, so Moodle's login wall stays out of your way.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
7
|
+
[](https://www.npmjs.com/package/moodle-cli)
|
|
8
|
+
[](https://github.com/bunizao/moodle-cli/actions/workflows/ci.yml)
|
|
9
|
+
[](https://nodejs.org/)
|
|
10
|
+
[](https://bun.sh/)
|
|
11
|
+
[](LICENSE)
|
|
11
12
|
|
|
12
|
-
##
|
|
13
|
+
## Quick links
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
- [Set up with your agent](#start-with-your-agent)
|
|
16
|
+
- [Install and sign in manually](#install-and-sign-in-manually)
|
|
17
|
+
- [Study Boooooooooost](#study-boooooooooost)
|
|
18
|
+
- [Connect web AI through a private MCP server](#remote-mcp-for-web-ai)
|
|
19
|
+
- [Developer and agent reference](#for-developers-and-agents)
|
|
20
|
+
|
|
21
|
+
## For users
|
|
22
|
+
|
|
23
|
+
### Start with your agent
|
|
24
|
+
|
|
25
|
+
Paste this into Codex, Claude Code, OpenClaw, Hermes Agent, or another agent that can use your terminal:
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
Can you use https://github.com/bunizao/moodle-cli/raw/main/ONBOARDING.md to help me set up moodle-cli?
|
|
16
29
|
```
|
|
17
30
|
|
|
18
|
-
|
|
31
|
+
Your agent asks for your Moodle URL and opens your university's sign-in page when needed. Finish SSO in the browser while the agent waits; it verifies your account and sets up session renewal before reading Moodle. The same onboarding can deploy a private remote MCP server through your Cloudflare account.
|
|
32
|
+
|
|
33
|
+
### Install and sign in manually
|
|
34
|
+
|
|
35
|
+
Use Node.js 22+ or Bun:
|
|
19
36
|
|
|
20
37
|
```bash
|
|
21
|
-
|
|
38
|
+
# npm
|
|
39
|
+
npm install -g moodle-cli
|
|
40
|
+
|
|
41
|
+
# Bun
|
|
42
|
+
bun add --global moodle-cli
|
|
43
|
+
|
|
44
|
+
moodle --version
|
|
22
45
|
```
|
|
23
46
|
|
|
24
|
-
|
|
47
|
+
Run without a global install:
|
|
25
48
|
|
|
26
|
-
|
|
49
|
+
```bash
|
|
50
|
+
npx moodle-cli --help
|
|
51
|
+
bunx --bun moodle-cli --help
|
|
52
|
+
```
|
|
27
53
|
|
|
28
|
-
|
|
54
|
+
Sign in and open your dashboard:
|
|
29
55
|
|
|
30
56
|
```bash
|
|
31
|
-
|
|
32
|
-
|
|
57
|
+
moodle auth login
|
|
58
|
+
moodle overview
|
|
33
59
|
```
|
|
34
60
|
|
|
35
|
-
`~/.config/moodle-cli/config.yaml
|
|
61
|
+
On first use, enter your Moodle site origin, such as `https://moodle.example.edu`. `moodle-cli` validates it and saves it to `~/.config/moodle-cli/config.yaml`. If the CLI cannot find an active session, it opens your university's sign-in page and waits for you to finish.
|
|
36
62
|
|
|
37
|
-
|
|
63
|
+
Keep the session active on macOS with `moodle auth keepalive install`. On Linux, schedule `moodle auth keepalive --json` every 30 minutes with cron.
|
|
38
64
|
|
|
39
|
-
|
|
65
|
+
GitHub Releases also provide standalone binaries for macOS arm64 and Linux x64.
|
|
40
66
|
|
|
41
|
-
|
|
42
|
-
- an active Moodle browser session
|
|
43
|
-
- a `MOODLE_SESSION` environment variable
|
|
67
|
+
### Study Boooooooooost
|
|
44
68
|
|
|
45
|
-
|
|
69
|
+
Ask your agent in plain language or run the matching command:
|
|
70
|
+
|
|
71
|
+
| Student request | CLI command |
|
|
72
|
+
| --- | --- |
|
|
73
|
+
| “Give me a quick Moodle dashboard.” | `moodle overview` |
|
|
74
|
+
| “What is due in the next 14 days?” | `moodle todo --days 14` |
|
|
75
|
+
| “Show my grades and feedback for FIT1045.” | `moodle grades FIT1045` |
|
|
76
|
+
| “Find forum posts about the exam in FIT1045.” | `moodle forums search "exam" --course FIT1045` |
|
|
77
|
+
| “Download the slides from this Moodle link.” | `moodle download '<Moodle URL>' --dest './slides.pdf'` |
|
|
78
|
+
|
|
79
|
+
Unit arguments accept a Moodle course ID or a unique course name.
|
|
80
|
+
|
|
81
|
+
#### Paste Moodle links directly
|
|
82
|
+
|
|
83
|
+
The CLI recognizes course, forum, assignment, quiz, resource, page, folder, and grade-report URLs:
|
|
46
84
|
|
|
47
85
|
```bash
|
|
48
|
-
|
|
49
|
-
|
|
86
|
+
moodle 'https://moodle.example.edu/course/view.php?id=34637'
|
|
87
|
+
moodle 'https://moodle.example.edu/mod/forum/discuss.php?d=9001#p9101'
|
|
88
|
+
moodle download 'https://moodle.example.edu/mod/resource/view.php?id=91234' --dest './Week 03/slides.pdf'
|
|
50
89
|
```
|
|
51
90
|
|
|
52
|
-
|
|
91
|
+
You can paste the same links into your agent and ask it to inspect the page, find related material, or download the file.
|
|
92
|
+
|
|
93
|
+
#### Download course files
|
|
94
|
+
|
|
95
|
+
`moodle download` accepts an activity ID or an authenticated Moodle URL. `--dest` sets the exact local path, and `--force` replaces an existing file after the download completes. Folder activities expose `file_entries` so you can choose which files to save.
|
|
53
96
|
|
|
54
|
-
|
|
55
|
-
|
|
97
|
+
### Remote MCP for web AI
|
|
98
|
+
|
|
99
|
+
A private remote MCP server lets a supported web AI client use Moodle when it cannot run the local CLI. You need a Cloudflare account.
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
moodle mcp deploy
|
|
103
|
+
moodle mcp status
|
|
56
104
|
```
|
|
57
105
|
|
|
58
|
-
|
|
106
|
+
`moodle mcp deploy` validates Moodle access, deploys a Cloudflare Worker, uploads an encrypted Moodle session, verifies readiness, and installs session renewal. The guided [`ONBOARDING.md`](ONBOARDING.md) asks whether you want this after local setup and helps connect your web AI client.
|
|
59
107
|
|
|
60
|
-
|
|
108
|
+
### Update
|
|
61
109
|
|
|
62
110
|
```bash
|
|
63
|
-
moodle
|
|
64
|
-
moodle
|
|
65
|
-
moodle alerts
|
|
66
|
-
moodle todo
|
|
67
|
-
moodle overview
|
|
68
|
-
moodle courses
|
|
69
|
-
moodle grades 34637
|
|
70
|
-
moodle activities 34637
|
|
71
|
-
moodle https://school.example.edu/course/view.php?id=34637
|
|
72
|
-
moodle https://school.example.edu/mod/forum/discuss.php?d=9001#p9101 --json
|
|
73
|
-
moodle skills
|
|
74
|
-
moodle skills generate
|
|
75
|
-
moodle skills add
|
|
76
|
-
moodle update
|
|
77
|
-
moodle update --check-only
|
|
111
|
+
npm install -g moodle-cli@latest
|
|
112
|
+
bun add --global moodle-cli@latest
|
|
78
113
|
```
|
|
79
114
|
|
|
80
|
-
|
|
115
|
+
Standalone binaries print the latest GitHub Release URL instead of modifying themselves.
|
|
116
|
+
|
|
117
|
+
## For developers and agents
|
|
81
118
|
|
|
82
|
-
|
|
119
|
+
### Command and output contract
|
|
83
120
|
|
|
84
|
-
|
|
121
|
+
Inspect the full machine-readable command tree:
|
|
85
122
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
- `--fields a,b,c`: keep only listed top-level fields; arrays apply the filter per item
|
|
123
|
+
```bash
|
|
124
|
+
moodle commands --json
|
|
125
|
+
```
|
|
90
126
|
|
|
91
|
-
|
|
127
|
+
Commands support:
|
|
92
128
|
|
|
93
|
-
|
|
129
|
+
- `--json` or `--yaml` for structured output
|
|
130
|
+
- `--table` for human-readable output
|
|
131
|
+
- `--fields a,b,c` to select fields
|
|
132
|
+
- `-o, --output FILE` to write command output or a download receipt
|
|
94
133
|
|
|
95
|
-
|
|
134
|
+
The CLI prints tables in an interactive terminal and JSON when stdout goes to a pipe or file. Structured errors use one JSON object on stderr:
|
|
96
135
|
|
|
97
136
|
```json
|
|
98
|
-
{"
|
|
137
|
+
{"ok":false,"error":{"code":"auth","message":"...","hint":"..."},"exit_code":3}
|
|
99
138
|
```
|
|
100
139
|
|
|
101
|
-
Exit codes:
|
|
102
|
-
|
|
103
140
|
| Code | Meaning |
|
|
104
141
|
| --- | --- |
|
|
105
142
|
| 0 | Success |
|
|
106
|
-
| 1 |
|
|
107
|
-
| 2 |
|
|
108
|
-
| 3 |
|
|
109
|
-
| 4 |
|
|
143
|
+
| 1 | Network, configuration, or unexpected error |
|
|
144
|
+
| 2 | Usage error |
|
|
145
|
+
| 3 | Authentication error |
|
|
146
|
+
| 4 | Course, activity, forum, or discussion not found |
|
|
147
|
+
| 5 | Moodle rejected the request |
|
|
148
|
+
|
|
149
|
+
### Agent skill
|
|
110
150
|
|
|
111
|
-
|
|
151
|
+
Install the generated skill bundle:
|
|
112
152
|
|
|
113
153
|
```bash
|
|
114
|
-
moodle
|
|
115
|
-
|
|
154
|
+
moodle skills add
|
|
155
|
+
|
|
156
|
+
# Direct alternatives
|
|
157
|
+
npx skills add https://github.com/bunizao/moodle-cli
|
|
158
|
+
bunx --bun skills add https://github.com/bunizao/moodle-cli
|
|
116
159
|
```
|
|
117
160
|
|
|
118
|
-
`
|
|
161
|
+
[`SKILL.md`](SKILL.md) routes agents to focused setup, coursework, forum, download, and maintenance guidance under [`references/`](references/).
|
|
162
|
+
|
|
163
|
+
### MCP lifecycle and protocol
|
|
119
164
|
|
|
120
165
|
```bash
|
|
121
|
-
|
|
166
|
+
moodle mcp deploy
|
|
167
|
+
moodle mcp status
|
|
168
|
+
moodle mcp login
|
|
169
|
+
moodle mcp connect
|
|
170
|
+
moodle mcp remove
|
|
171
|
+
moodle mcp serve
|
|
172
|
+
moodle mcp bridge
|
|
122
173
|
```
|
|
123
174
|
|
|
124
|
-
|
|
175
|
+
The default client connection uses `moodle mcp bridge`, which keeps the Bearer token out of client configuration. Use `moodle mcp connect CLIENT --mode remote` for clients that support authenticated remote MCP headers.
|
|
125
176
|
|
|
126
|
-
|
|
177
|
+
Alpha version `0.7.0-alpha.0` supports MCP `2026-07-28` and a stateless compatibility lane for `2025-11-25` clients.
|
|
127
178
|
|
|
128
|
-
|
|
179
|
+
### Configuration
|
|
129
180
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
181
|
+
| Variable | Purpose |
|
|
182
|
+
| --- | --- |
|
|
183
|
+
| `MOODLE_BASE_URL` | Set the Moodle site origin without writing a config file. |
|
|
184
|
+
| `MOODLE_CONFIG` | Use another YAML config file. |
|
|
185
|
+
| `MOODLE_TOKEN` | Provide a `MoodleSession` cookie value in a non-browser environment. |
|
|
186
|
+
| `MOODLE_SESSION` | Compatibility alias for `MOODLE_TOKEN`. |
|
|
133
187
|
|
|
134
|
-
|
|
188
|
+
For local use, save `base_url` in `~/.config/moodle-cli/config.yaml`. `MOODLE_URL` remains a deprecated fallback for `MOODLE_BASE_URL`.
|
|
135
189
|
|
|
136
|
-
|
|
137
|
-
moodle skills add
|
|
138
|
-
```
|
|
190
|
+
### Build from source
|
|
139
191
|
|
|
140
|
-
|
|
192
|
+
Node.js workflow:
|
|
141
193
|
|
|
142
194
|
```bash
|
|
195
|
+
npm ci
|
|
196
|
+
npm run check
|
|
197
|
+
npm test
|
|
143
198
|
npm run build
|
|
144
|
-
npm run
|
|
145
|
-
git diff --exit-code SKILL.md
|
|
199
|
+
npm run pack:check
|
|
146
200
|
```
|
|
147
201
|
|
|
148
|
-
|
|
202
|
+
Bun workflow:
|
|
149
203
|
|
|
150
204
|
```bash
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
205
|
+
bun install
|
|
206
|
+
bunx tsc --noEmit
|
|
207
|
+
bunx vitest run
|
|
208
|
+
bun run build
|
|
209
|
+
bun run pack:check
|
|
155
210
|
```
|
|
211
|
+
|
|
212
|
+
## License
|
|
213
|
+
|
|
214
|
+
[MIT](LICENSE)
|
package/SKILL.md
CHANGED
|
@@ -1,167 +1,38 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: moodle-cli
|
|
3
|
-
description:
|
|
3
|
+
description: Read Moodle data, download local files, and manage a private Moodle MCP deployment with the `moodle` CLI. Use for authenticated profile, unit discovery, deadlines, alerts, sections, activities, grades, forum workflows, local file downloads, supported Moodle URLs, authentication diagnostics, or MCP deploy, status, login, connection, and removal.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# Moodle CLI
|
|
7
7
|
|
|
8
|
-
<!-- Generated by `moodle skills generate`. Edit `src/skill.template.md`
|
|
8
|
+
<!-- Generated by `moodle skills generate`. Edit `src/skill.template.md` and `src/skill-references/`. -->
|
|
9
9
|
|
|
10
|
-
Use `moodle` for read-only Moodle
|
|
10
|
+
Use `moodle` for read-only Moodle inspection, explicit local file downloads, and private managed MCP lifecycle operations.
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Core Steps
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
1. Classify the request with the branch map below and read that reference file before running a command.
|
|
15
|
+
2. Run the narrowest command that answers the request. Prefer `--json`; add `--fields` when only a few top-level fields matter.
|
|
16
|
+
3. Parse the result locally and answer with the requested facts, exact dates, and relevant Moodle links. The task is complete when the answer is supported by command output rather than inference.
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
Resolve an unfamiliar unit name with `moodle units --json` before using a unit-specific command. `courses` and `projects` are equivalent aliases. Use `moodle overview --json` only for an explicitly combined snapshot.
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
## Branch Map
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
- **Installation, configuration, authentication failure, session keepalive, or managed MCP lifecycle**: read [references/setup-and-auth.md](references/setup-and-auth.md).
|
|
23
|
+
- **Profile, course discovery, sections, or activity lists**: read [references/profile-and-courses.md](references/profile-and-courses.md).
|
|
24
|
+
- **Deadlines, todo items, alerts, or a combined snapshot**: read [references/deadlines-and-alerts.md](references/deadlines-and-alerts.md).
|
|
25
|
+
- **Grades or assignment, quiz, resource, link, page, and folder detail**: read [references/coursework-and-grades.md](references/coursework-and-grades.md).
|
|
26
|
+
- **Downloading a resource or selected folder files to local paths**: read [references/downloads.md](references/downloads.md).
|
|
27
|
+
- **Forum discovery, search, discussions, posts, groups, or rendering checks**: read [references/forums.md](references/forums.md).
|
|
28
|
+
- **Output selection, field filtering, error handling, or exit codes**: read [references/output-and-errors.md](references/output-and-errors.md).
|
|
29
|
+
- **Updates, skill installation, or skill regeneration**: read [references/maintenance.md](references/maintenance.md).
|
|
30
|
+
- **Exact syntax or all flags**: read [references/command-reference.md](references/command-reference.md).
|
|
21
31
|
|
|
22
|
-
|
|
32
|
+
## Shared Rules
|
|
23
33
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
npx moodle-cli --help
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Standalone binaries are published on GitHub Releases.
|
|
33
|
-
|
|
34
|
-
Existing PyPI users should migrate:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
uv tool uninstall moodle-cli
|
|
38
|
-
npm i -g moodle-cli
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Authenticate with an active Moodle browser session, `MOODLE_SESSION`, or `okta-auth-cli`.
|
|
42
|
-
|
|
43
|
-
Set `MOODLE_BASE_URL` or let the first run prompt for the Moodle root URL and save it to config.
|
|
44
|
-
|
|
45
|
-
## Forum Routing
|
|
46
|
-
|
|
47
|
-
For forum requests, prefer `moodle forum find` over manually chaining `forum forums`, `forum discussions`, and `forum discussion`.
|
|
48
|
-
|
|
49
|
-
If the user already gives a forum discussion URL, skip search and open it directly with `moodle forum discussion DISCUSSION_OR_URL --json`.
|
|
50
|
-
|
|
51
|
-
If the user gives a forum view URL or discussion URL and wants to browse nearby discussions, use `moodle forum discussions FORUM_OR_URL --json`.
|
|
52
|
-
|
|
53
|
-
Use scan budgets first when the site may be large:
|
|
54
|
-
|
|
55
|
-
- `--course` to narrow to one course
|
|
56
|
-
- `--limit-forums` to cap how many forums to scan
|
|
57
|
-
- `--limit-discussions` to cap how many discussions to scan per forum
|
|
58
|
-
|
|
59
|
-
Grouped forums are handled automatically. Do not assume an empty default forum page means the forum has no discussions.
|
|
60
|
-
|
|
61
|
-
Default forum agent flow:
|
|
62
|
-
|
|
63
|
-
1. Start with `moodle forum find QUERY --json`
|
|
64
|
-
2. Add `--unread-only` when the user wants new or unseen content
|
|
65
|
-
3. Add `--list --limit N` when one result is not enough and you need a shortlist
|
|
66
|
-
4. Add `--body` only when the snippet is insufficient and you need the full target post/discussion
|
|
67
|
-
|
|
68
|
-
Avoid `moodle forum search` unless you explicitly need a larger result set than `forum find --list`.
|
|
69
|
-
|
|
70
|
-
## Intent To Command
|
|
71
|
-
|
|
72
|
-
| User intent | Command |
|
|
73
|
-
| --- | --- |
|
|
74
|
-
| Show my profile or account info | moodle user --json |
|
|
75
|
-
| List my courses | moodle courses --json |
|
|
76
|
-
| Find nearest deadlines or upcoming actions | moodle todo --limit 5 --days 14 --json |
|
|
77
|
-
| List alerts or unread notifications | moodle alerts --limit 10 --json |
|
|
78
|
-
| Show a compact dashboard | moodle overview --todo-limit 5 --alerts-limit 5 --json |
|
|
79
|
-
| Show activities in a course | moodle activities COURSE_ID --json |
|
|
80
|
-
| Show course sections | moodle course COURSE_ID --json |
|
|
81
|
-
| Show grades for a course | moodle grades COURSE_ID --json |
|
|
82
|
-
| Find the best forum match | moodle forum find QUERY --json |
|
|
83
|
-
| Open a forum discussion URL or ID | moodle forum discussion DISCUSSION_OR_URL --json |
|
|
84
|
-
| Check whether the CLI has an update | moodle update --json |
|
|
85
|
-
| Install this agent skill | moodle skills add |
|
|
86
|
-
|
|
87
|
-
## Command Reference
|
|
88
|
-
|
|
89
|
-
| Command | Description | Arguments | Flags |
|
|
90
|
-
| --- | --- | --- | --- |
|
|
91
|
-
| moodle activities | List activities in a course. | <course> | --json<br>--yaml<br>--table<br>--fields (value required) |
|
|
92
|
-
| moodle alerts | List notifications and message counts. | | --json<br>--yaml<br>--table<br>--fields (value required)<br>--limit (default: 20; value required) |
|
|
93
|
-
| moodle assign | Show assignment details. | <assign> | --json<br>--yaml<br>--table<br>--fields (value required) |
|
|
94
|
-
| moodle course | Show course detail with sections. | <course> | --json<br>--yaml<br>--table<br>--fields (value required) |
|
|
95
|
-
| moodle courses | List enrolled courses. | | --json<br>--yaml<br>--table<br>--fields (value required) |
|
|
96
|
-
| moodle folder | Show folder details. | <folder> | --json<br>--yaml<br>--table<br>--fields (value required) |
|
|
97
|
-
| moodle forum | Forum utilities. | | |
|
|
98
|
-
| moodle forum check | Validate discussion rendering. | <forum> | --json<br>--yaml<br>--table<br>--fields (value required)<br>--limit (default: 20; value required) |
|
|
99
|
-
| moodle forum discussion | Show posts in a forum discussion. | <discussion> | --json<br>--yaml<br>--table<br>--fields (value required)<br>--post (value required)<br>--body |
|
|
100
|
-
| moodle forum discussions | List discussions from a forum. | <forum> | --json<br>--yaml<br>--table<br>--fields (value required)<br>--limit (default: 50; value required)<br>--query (value required) |
|
|
101
|
-
| moodle forum find | Find the best forum match. | <query> | --list<br>--body<br>--json<br>--yaml<br>--table<br>--fields (value required)<br>--course (value required)<br>--forum (value required)<br>--titles-only<br>--unread-only<br>--recent<br>--limit-forums (value required)<br>--limit-discussions (value required)<br>--limit (default: 5; value required) |
|
|
102
|
-
| moodle forum forums | List forum activities. | [query] | --json<br>--yaml<br>--table<br>--fields (value required)<br>--course (value required)<br>--limit (default: 50; value required) |
|
|
103
|
-
| moodle forum search | Search forum discussion titles and post text. | <query> | --json<br>--yaml<br>--table<br>--fields (value required)<br>--course (value required)<br>--forum (value required)<br>--titles-only<br>--unread-only<br>--recent<br>--limit-forums (value required)<br>--limit-discussions (value required)<br>--limit (default: 20; value required) |
|
|
104
|
-
| moodle grades | Show grade details for a course. | <course> | --json<br>--yaml<br>--table<br>--fields (value required) |
|
|
105
|
-
| moodle link | Show link details. | <link> | --json<br>--yaml<br>--table<br>--fields (value required) |
|
|
106
|
-
| moodle overview | Show a compact multi-source overview. | | --json<br>--yaml<br>--table<br>--fields (value required)<br>--todo-limit (default: 5; value required)<br>--todo-days (value required)<br>--alerts-limit (default: 5; value required) |
|
|
107
|
-
| moodle page | Show page details. | <page> | --json<br>--yaml<br>--table<br>--fields (value required) |
|
|
108
|
-
| moodle quiz | Show quiz details. | <quiz> | --json<br>--yaml<br>--table<br>--fields (value required) |
|
|
109
|
-
| moodle resource | Show resource details. | <resource> | --json<br>--yaml<br>--table<br>--fields (value required) |
|
|
110
|
-
| moodle skills | Show skill metadata or delegate to the shared skills CLI. | | |
|
|
111
|
-
| moodle skills add | Install the published skill through npx skills add. | | |
|
|
112
|
-
| moodle skills generate | Regenerate SKILL.md from the CLI command tree. | | |
|
|
113
|
-
| moodle todo | List upcoming actionable timeline items. | | --json<br>--yaml<br>--table<br>--fields (value required)<br>--limit (default: 20; value required)<br>--days (value required) |
|
|
114
|
-
| moodle update | Check for updates and upgrade the installed CLI. | | --json<br>--yaml<br>--table<br>--fields (value required)<br>--check-only |
|
|
115
|
-
| moodle user | Show authenticated user info. | | --json<br>--yaml<br>--table<br>--fields (value required) |
|
|
116
|
-
|
|
117
|
-
## Agent Output
|
|
118
|
-
|
|
119
|
-
### Output Contract
|
|
120
|
-
|
|
121
|
-
- `--json` writes JSON to stdout.
|
|
122
|
-
- `--yaml` writes YAML to stdout when supported.
|
|
123
|
-
- `--table` forces human-readable table/tree output.
|
|
124
|
-
- When stdout is not a TTY, commands default to JSON unless `--table` is set.
|
|
125
|
-
- `--fields a,b,c` keeps only listed top-level fields. Arrays apply the field filter to each item.
|
|
126
|
-
- Invalid `--fields` values are usage errors and list valid fields.
|
|
127
|
-
- With JSON output enabled, errors are one JSON line on stderr: `{"error":true,"code":"auth_failed","message":"...","hint":"..."}`.
|
|
128
|
-
|
|
129
|
-
Exit codes:
|
|
130
|
-
|
|
131
|
-
| Code | Meaning |
|
|
132
|
-
| --- | --- |
|
|
133
|
-
| 0 | Success |
|
|
134
|
-
| 1 | Unexpected error |
|
|
135
|
-
| 2 | Authentication or configuration error |
|
|
136
|
-
| 3 | Usage error |
|
|
137
|
-
| 4 | Requested course, activity, forum, or discussion was not found |
|
|
138
|
-
|
|
139
|
-
## Operating Rules
|
|
140
|
-
|
|
141
|
-
Parse JSON locally and return a concise answer.
|
|
142
|
-
|
|
143
|
-
Do not paste full command output unless the user explicitly asks for raw JSON.
|
|
144
|
-
|
|
145
|
-
If the user asks for "recent", "next", or "nearest", sort by relevance and mention exact timestamps from `due_at` or `created_at`.
|
|
146
|
-
|
|
147
|
-
If a request is ambiguous between activities, courses, and grades, inspect courses first and then run the smallest follow-up command.
|
|
148
|
-
|
|
149
|
-
For forum work, do not enumerate forums or discussions first unless the user explicitly asks to browse. Search first, then expand only if needed.
|
|
150
|
-
|
|
151
|
-
For forum discussion output, prefer structured fields over heuristic text parsing when available:
|
|
152
|
-
|
|
153
|
-
- `image_urls` for original image links
|
|
154
|
-
- `links` for extracted hyperlinks
|
|
155
|
-
- `tables` for structured table content
|
|
156
|
-
- `group_id` and `group_name` for grouped forum context
|
|
157
|
-
|
|
158
|
-
## Failure Modes
|
|
159
|
-
|
|
160
|
-
- Authentication failed: sign in to Moodle in the browser, export `MOODLE_SESSION`, or configure `okta-auth-cli`.
|
|
161
|
-
- Invalid base URL: use the Moodle site root such as `https://school.example.edu`, not `/login/index.php` or `/my/`.
|
|
162
|
-
- Could not check for updates: retry with network access to the npm registry, then run `npm install -g moodle-cli@latest` or download the latest GitHub Release binary.
|
|
163
|
-
|
|
164
|
-
## Safety
|
|
165
|
-
|
|
166
|
-
- Treat `MOODLE_SESSION` as a secret and never paste it into chat or logs.
|
|
167
|
-
- The CLI is read-only and does not create or modify Moodle content.
|
|
34
|
+
- Treat `moodle commands --json` as the source of truth for this tool's command tree.
|
|
35
|
+
- Use `--table` only when the user asks for the terminal presentation.
|
|
36
|
+
- Return a concise answer instead of pasting raw output unless raw JSON is requested.
|
|
37
|
+
- Treat `MOODLE_SESSION` as a secret and keep it out of chat, commands shown to the user, and logs.
|
|
38
|
+
- Keep remote Moodle data read-only. `moodle download` may write only the explicitly selected local file path; managed MCP commands may change only the selected Worker, local renewal job, client registration, and MCP deployment credentials.
|