upload_file_from_url
Upload files to Ed Discussion from public URLs, generating static links for course materials and attachments.
Instructions
Upload a file to Ed from a URL, returns the static file link
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | Public URL of the file to upload |
Implementation Reference
- src/api.ts:289-295 (handler)The implementation of the logic to upload a file from a URL. Note: I need to verify if the return is just the string or the property from res. I will read a bit more to be sure of the return.
async uploadFileFromUrl(url: string): Promise<string> { // Restrict to HTTPS to mitigate SSRF (block file://, ftp://, internal schemes) const parsed = new URL(url); if (parsed.protocol !== "https:") { throw new Error("Only https:// URLs are allowed for file uploads"); } const res = await this.request<EdFileResponse>("POST", "files/url", { url }); - src/index.ts:443-455 (registration)The registration of the upload_file_from_url tool.
server.tool( "upload_file_from_url", "Upload a file to Ed from a URL, returns the static file link", { url: z.string().url().describe("Public URL of the file to upload") }, async ({ url }) => { try { const link = await api.uploadFileFromUrl(url); return msg(`File uploaded: ${link}`); } catch (err) { return fail(err); } } );