Skip to main content
Documentation

Uploading files

Files travel by URL, not through the chat

Assistants cannot push file contents through a conversation. MCP tool arguments are JSON written by the model itself, so a binary would have to travel base64-encoded as generated text — impossible beyond a few tens of kilobytes, and clients like Claude Desktop never attach conversation files to tool calls anyway.

So files reach Moodle by URL: you give the assistant a public HTTPS link and your own Moodle server downloads the file directly (up to 512 MiB, with Moodle's SSRF protections). The file never passes through the chat.

Adding a file to a course

  • local_mcpconnector_create_resource — adds any file (PDF, DOCX, image, video…) to a course as a File resource. Requires plugin 2.5 or later.
  • local_mcpconnector_create_scorm — creates a SCORM activity from a package zip. Requires plugin 2.3 or later.

Ask in plain language — "add this PDF to the Biology course as a resource: https://…" — and the assistant picks the right tool.

The link must return the file itself, not a web page wrapping it:

SourceUse
Google Drivehttps://drive.google.com/uc?export=download&id=FILE_ID — the normal share link returns a page, and very large files hit a confirmation page the server can't click through
DropboxAppend ?dl=1 to the share link
GitHubUse the raw.githubusercontent.com URL

Any HTTPS URL your Moodle can reach works, including your own web server.

Files on the assistant's machine

When the file lives where the assistant runs — a SCORM package it just built, a PDF it generated — there's no public URL to give. Use moodle_request_file_upload:

  1. The tool returns a temporary upload URL.
  2. The assistant uploads the file with the curl command it gets back.
  3. It passes the returned fileUrl to create_resource or create_scorm.

Both URLs expire and the file is purged after 30 minutes. It's a transfer channel, not storage — don't treat it as a place to keep anything.

Troubleshooting uploads

  • "Could not download the file" — the URL returns HTML instead of the file, or isn't publicly reachable. Test it with curl -IL <url> from outside your network.
  • The tool isn't available — your plugin is older than the version listed above. Update it in Moodle.
  • The assistant says it can't upload files — it hasn't found the tool. Asking it to search its Moodle tools for "upload" usually unblocks it.