Package Information
Available Nodes
Documentation generating…
Documentation
n8n-nodes-moocp
Community nodes for the student-facing Moodle features of moocp (MIT, reviewed at commit 603ab58789).
moocp is a local Rust MCP server. It signs in through a visible browser and speaks MCP over stdio. These nodes do not launch that binary. They support Moodle mobile web-service tokens and read-only website sessions imported from a browser login. SSO and MFA happen outside n8n.
This is an unverified community-node package for self-hosted n8n. It has not been reviewed or approved by n8n.
Install
Verified community nodes can be installed from the nodes panel. Until this package is verified, use a self-hosted n8n instance.
From the n8n GUI: Settings > Community nodes > Install and enter n8n-nodes-moocp. Installation requires an owner or admin account and support for unverified community packages.
From the command line, in the n8n user folder:
cd ~/.n8n/nodes
npm install n8n-nodes-moocp
Restart n8n. For a local checkout of this repository, build it and point n8n at the folder:
npm install
npm run build
export N8N_CUSTOM_EXTENSIONS="/absolute/path/to/n8n-nodes-moocp/dist"
Docker images need the built dist directory mounted into the container, and community packages enabled. Queue mode needs the package installed on every worker as well as the main process.
If the instance disables unverified packages, its administrator must enable N8N_COMMUNITY_PACKAGES_ENABLED and N8N_UNVERIFIED_PACKAGES_ENABLED. n8n Cloud does not install unverified packages.
npm run dev starts a local n8n with this package loaded. From n8n 3 that command expects Docker or Podman unless you pass --external-n8n.
Credential
Create a Moocp API credential:
| Field | Meaning |
|---|---|
| Authentication | Web Service Token (the default for existing credentials), or Browser Session (Read Only). |
| Site URL | Moodle base URL, for example https://moodle.example.edu. No trailing slash, query, or embedded password. |
| Web Service Token | A token for the moodle_mobile_app service, or for another external service that includes the same functions. |
| Session Cookies | A Cookie header or the JSON export copied by the local moocp helper. This is a masked credential field. |
| Allow Insecure HTTP | Off by default. Turn it on only for a local lab site. |
The token is sent as the wstoken form field on webservice/rest/server.php, as the token field on webservice/upload.php, and as the token query parameter on webservice/pluginfile.php. It is removed from values the node returns.
The credential test verifies an authenticated user: token mode checks core_webservice_get_site_info, including Moodle error bodies returned with HTTP 200; session mode checks the signed-in dashboard and logout link. Connection > Check repeats a live check. Status reports local configuration only and does not prove the connection works.
Using a browser session
This supports sites where browser SSO works but the Moodle mobile service is unavailable.
Complete
moocp loginin a Terminal on your Mac. University passwords and MFA stay in the browser.Run the bundled helper from a local checkout or installed package:
python3 scripts/copy-moocp-session.pyThe helper reads the active moocp account from macOS Keychain (or its explicitly configured file store) and copies a site-bound cookie export to the clipboard. It does not print the cookies, write an export file, or contact n8n. Use
--profile NAMEfor another saved account.In n8n, select Browser Session (Read Only) in the Moocp API credential, enter the same Site URL, and paste into Session Cookies. Replace the clipboard contents after pasting.
Save the credential and run Moocp > Connection > Check, then Course > Get Many.
The credential also accepts a Cookie header such as MoodleSession=YOUR_VALUE. Exported JSON preserves domain, path, secure, and expiry restrictions; a raw header is scoped to the configured site. Do not paste cookies into Web Service Token or send them in chat.
Session mode supports course discovery, course outlines and section summaries, activity-page text, attachment discovery on activity reads, and original file downloads. Deadlines, forums, messages, grades, quizzes, and personal coursework use allowlisted website AJAX reads only where Moodle exposes them. Unavailable functions fail explicitly; full personal-coursework HTML parsing is not implemented. Material listings include outline metadata; read an activity to discover attachments missing from the outline. HTML fallbacks report their limitations.
Session mode blocks all Moocp Action preparations, executions, and uploads, even when Approved is enabled. A website session itself is not a read-only credential; this restriction is enforced by the node.
The node fetches a current sesskey from the dashboard, retries a stale key once, and recognises rejected cookies, login pages, and SSO redirects as reauth_required. Cookies are never sent to another origin. Cookie replacements from Set-Cookie are used only during the current execution; the node does not update the saved n8n credential or persist cookies in workflow data. When the session expires, repeat login, copy, and paste. There is no automatic browser login, indefinite keepalive, or guaranteed session lifetime.
Live checks on the Mac do not establish that the same session will be accepted from your hosted n8n server. Check the imported credential on that instance before relying on scheduled runs.
Getting a token
moocp's own sign-in opens Chrome, Chromium, or Edge, completes university SSO, and then requests a mobile token from admin/tool/mobile/launch.php. This package cannot do that. n8n community nodes that are eligible for verification cannot start a browser, read the OS keychain, or spawn moocp.
Use a token created outside n8n:
- Moodle's Security keys page, when your account has
moodle/webservice:createmobiletoken. - A token an administrator creates for you against the mobile service.
- The token moocp already stored, if you can export it yourself. Do not paste a session cookie.
If mobile web services are unavailable, use Browser Session for the supported reads. Token-authenticated writes still require an enabled mobile or compatible external service.
Nodes
Moocp reads. Moocp Action prepares and executes writes. Both use resource and operation fields. Descriptions on the fields say which ID is a course-module ID and which limits apply.
Token-authenticated writes follow moocp's two-step rule:
- Prepare validates the action, reads the current Moodle state, and returns a proposal. It does not change Moodle. Proposals expire after 30 minutes. Assignment files are copied into the proposal as base64, with a SHA-256, so Execute does not trust a later copy of the file.
- Execute changes Moodle only when Approved is enabled, the proposal is unexpired, and the Moodle state still matches the snapshot. A succeeded proposal ID is remembered in the workflow's static data and is not sent again. A failed or uncertain attempt is not retried. Get shows the proposal without file bytes.
Leave Approved off until a person has read the preview. The example workflow ships with it off, so importing that file cannot send a message.
Search and Index Course store extracted text in workflow static data, not in moocp's SQLite database. The index is capped at 200 documents, is local to the workflow, and is not a durable full-text index. Queue-mode workers only share it when they share n8n's database.
Downloaded files are n8n binary data. The node never writes a path on the n8n host.
Validation
npm test runs against an in-process fixture shaped like moocp's synthetic campus: course list, the personal assignment extension and draft flag, the remaining quiz attempt, catalogue paging, secret stripping, form encoding, PDF literal extraction, and the prepare/approve/execute gate for a message. Those tests do not open a network connection.
Browser-session tests additionally cover expiry, redirects, same-site cookies, stale sesskeys, HTML/JSON course readers, downloads, credential checks, and write rejection. A read-only smoke check against ECS Moodle on 10 November 2026 verified the session, listed 15 courses, read a course outline and activity text, and completed a seven-day deadline request (zero events returned). It did not verify every course format, file download, personal coursework field, or operation, and it did not run on the hosted n8n server. Token-authenticated writes remain unverified against a live site. See COVERAGE.md.
Unsupported on purpose
These moocp features are not implemented:
- Browser tools (
moodle_browser_open, snapshot, tabs, screenshot, browser actions). They launch a visible Chromium with session cookies. - Full personal-coursework and plugin-specific HTML fallbacks, and browser-session writes.
- SSO sign-in,
moocp login, and token minting throughadmin/tool/mobile/launch.php. - CLI installation, updates, client registration, and the interactive
moocp reviewterminal. Approval is the Approved field. - SQLite full-text search and the on-disk document cache.
- ZIP, DOCX, and PPTX text extraction. Verified nodes cannot depend on an archive library. Compressed PDF streams are not inflated; literal PDF strings are. Download the original file for anything else.
- Fetching links that leave the Moodle site. moocp does that with its own public-address guard. This node refuses those links.
- Host filesystem paths from
moodle_download_file.
The admin-oriented package n8n-nodes-moodle creates users, courses, and enrolments. This package does not. It stays on the student operations moocp exposes.
Develop
npm install
npm test
npm run lint
npm run build
Node 24 or newer matches current n8n. The package has no runtime dependencies. Peer dependency is n8n-workflow.
npm publish --access public runs the tests, lint, and build before publishing. It requires an authenticated npm account with publishing permission. Publishing from a local machine does not include the GitHub Actions provenance required for n8n verification.
Do not run npm run release or npm publish unless you mean to publish the package.