Upload Files to ImageKit
CRITICAL: Only URL-based uploads are supported
The file parameter must be a publicly accessible URL string. Local files cannot be uploaded — local paths, Buffers, and streams are not supported and will fail. If the user has a local file, they must first host it at a public URL and pass that URL.
Both file and fileName are required.
NEVER convert a local file to a base64 (data URI) string and try to upload it. Reading a file into the model context to base64-encode it burns a huge number of LLM tokens and still won't work for large files. Always pass a URL — never inline file bytes.
Uploads are performed with the SDK's client.files.upload() method via mcp_imagekit_api_execute.
Usage
async function run(client) {
const file = await client.files.upload({
file: 'https://example.com/photo.jpg', // URL string ONLY — no local paths
fileName: 'photo.jpg',
folder: '/products',
tags: ['product', 'featured'],
});
return { fileId: file.fileId, url: file.url, size: file.size, fileType: file.fileType };
}
Parameters
Parameter names mirror the Upload API (FileUploadV1) field names in camelCase. When a field is omitted, ImageKit applies its own default.
| Parameter |
Description |
file (required) |
Publicly accessible URL of the file to upload. Local paths are NOT allowed. |
fileName (required) |
Name for the uploaded file, e.g. 'photo.jpg'. |
folder |
Destination folder in ImageKit (default: /) |
tags |
Array of tags (e.g. ['product', 'featured']) |
isPrivateFile |
Mark file as private |
isPublished |
Publish the file; false uploads as draft (enterprise plans) |
useUniqueFileName |
Add a unique suffix to the filename (default true) |
overwriteFile |
Overwrite an existing file at the same path |
overwriteAITags |
Overwrite existing AITags when replacing |
overwriteTags |
Overwrite existing tags when replacing |
overwriteCustomMetadata |
Overwrite existing customMetadata when replacing |
description |
Description for the file |
customCoordinates |
Important area: "x,y,width,height" |
customMetadata |
Object of custom metadata, e.g. { brand: 'Nike' } (fields must exist in DAM first) |
extensions |
Array of extensions, e.g. [{ name: 'google-auto-tagging', maxTags: 5 }] |
transformation |
Object of pre/post transformations, e.g. { pre: 'w-1200,q-80' } |
webhookUrl |
URL to receive extension completion status |
responseFields |
Fields to include in the response (e.g. ['tags', 'customMetadata', 'metadata']) |
checks |
Server-side upload check expression |
Examples
// Basic upload to a folder with tags
await client.files.upload({
file: 'https://example.com/photo.jpg',
fileName: 'photo.jpg',
folder: '/products',
tags: ['product', 'featured'],
});
// Overwrite an exact-named file
await client.files.upload({
file: 'https://example.com/banner.jpg',
fileName: 'banner.jpg',
useUniqueFileName: false,
overwriteFile: true,
});
// Upload with auto-tagging extension
await client.files.upload({
file: 'https://example.com/photo.jpg',
fileName: 'photo.jpg',
extensions: [{ name: 'google-auto-tagging', maxTags: 5 }],
});
// Upload with custom metadata and a pre-transformation
await client.files.upload({
file: 'https://example.com/photo.jpg',
fileName: 'photo.jpg',
customMetadata: { brand: 'Nike' },
transformation: { pre: 'w-1200,q-80' },
});
Notes
- Local files cannot be uploaded. Only a publicly accessible URL works. If the user provides a local path, tell them to host it publicly first and share the URL.
folder is the ImageKit media library path (not local). Starts with /, auto-creates nested folders. Don't include the filename in the folder path.
fileName allows: a-z, A-Z, 0-9, ., -. Other characters become _.
useUniqueFileName defaults to true (a unique suffix is appended). To overwrite an exact-named file, set useUniqueFileName: false and overwriteFile: true.
customMetadata fields must be created in the DAM first.
Procedure
- Get a public URL: Confirm the file is available at a publicly accessible URL. If the user has only a local file, stop and ask them to host it and provide the URL.
- Decide folder and tags: Where in the ImageKit media library the file should live.
- Run the upload via
mcp_imagekit_api_execute using client.files.upload().
- Verify the response: Confirm a
fileId and url are returned and the reported size/fileType match (fileType is image for images, non-image for video and other files).
Error Prevention
- Local paths fail: Passing a local file path, Buffer, or stream is not supported — always pass a URL string.
- Never base64-encode a file to upload it: Converting a local file to a base64/data-URI string wastes LLM tokens and fails for large files. Host the file and pass its URL instead.
- File size limits: Free plan: 25MB images, 100MB videos. Paid plans: higher.
- Version limit: Max 100 versions per file.
1---2name: upload-files3description: Upload files to ImageKit from a publicly accessible URL. Use when: uploading images, videos, or files to ImageKit media library; specifying folder paths; setting file names, tags, or metadata during upload. NOTE: only URL-based uploads are supported — local file paths cannot be passed.4---56# Upload Files to ImageKit78## CRITICAL: Only URL-based uploads are supported910The `file` parameter must be a **publicly accessible URL string**. **Local files cannot be uploaded** — local paths, Buffers, and streams are not supported and will fail. If the user has a local file, they must first host it at a public URL and pass that URL.1112Both `file` and `fileName` are **required**.1314**NEVER convert a local file to a base64 (data URI) string and try to upload it.** Reading a file into the model context to base64-encode it burns a huge number of LLM tokens and still won't work for large files. Always pass a URL — never inline file bytes.1516Uploads are performed with the SDK's `client.files.upload()` method via `mcp_imagekit_api_execute`.1718## Usage1920```typescript21async function run(client) {22 const file = await client.files.upload({23 file: 'https://example.com/photo.jpg', // URL string ONLY — no local paths24 fileName: 'photo.jpg',25 folder: '/products',26 tags: ['product', 'featured'],27 });28 return { fileId: file.fileId, url: file.url, size: file.size, fileType: file.fileType };29}30```3132## Parameters3334Parameter names mirror the Upload API (`FileUploadV1`) field names in camelCase. When a field is omitted, ImageKit applies its own default.3536| Parameter | Description |37|-----------|-------------|38| `file` (required) | **Publicly accessible URL** of the file to upload. Local paths are NOT allowed. |39| `fileName` (required) | Name for the uploaded file, e.g. `'photo.jpg'`. |40| `folder` | Destination folder in ImageKit (default: `/`) |41| `tags` | Array of tags (e.g. `['product', 'featured']`) |42| `isPrivateFile` | Mark file as private |43| `isPublished` | Publish the file; `false` uploads as draft (enterprise plans) |44| `useUniqueFileName` | Add a unique suffix to the filename (default `true`) |45| `overwriteFile` | Overwrite an existing file at the same path |46| `overwriteAITags` | Overwrite existing AITags when replacing |47| `overwriteTags` | Overwrite existing tags when replacing |48| `overwriteCustomMetadata` | Overwrite existing customMetadata when replacing |49| `description` | Description for the file |50| `customCoordinates` | Important area: `"x,y,width,height"` |51| `customMetadata` | Object of custom metadata, e.g. `{ brand: 'Nike' }` (fields must exist in DAM first) |52| `extensions` | Array of extensions, e.g. `[{ name: 'google-auto-tagging', maxTags: 5 }]` |53| `transformation` | Object of pre/post transformations, e.g. `{ pre: 'w-1200,q-80' }` |54| `webhookUrl` | URL to receive extension completion status |55| `responseFields` | Fields to include in the response (e.g. `['tags', 'customMetadata', 'metadata']`) |56| `checks` | Server-side upload check expression |5758## Examples5960```typescript61// Basic upload to a folder with tags62await client.files.upload({63 file: 'https://example.com/photo.jpg',64 fileName: 'photo.jpg',65 folder: '/products',66 tags: ['product', 'featured'],67});6869// Overwrite an exact-named file70await client.files.upload({71 file: 'https://example.com/banner.jpg',72 fileName: 'banner.jpg',73 useUniqueFileName: false,74 overwriteFile: true,75});7677// Upload with auto-tagging extension78await client.files.upload({79 file: 'https://example.com/photo.jpg',80 fileName: 'photo.jpg',81 extensions: [{ name: 'google-auto-tagging', maxTags: 5 }],82});8384// Upload with custom metadata and a pre-transformation85await client.files.upload({86 file: 'https://example.com/photo.jpg',87 fileName: 'photo.jpg',88 customMetadata: { brand: 'Nike' },89 transformation: { pre: 'w-1200,q-80' },90});91```9293## Notes9495- **Local files cannot be uploaded.** Only a publicly accessible URL works. If the user provides a local path, tell them to host it publicly first and share the URL.96- `folder` is the ImageKit media library path (not local). Starts with `/`, auto-creates nested folders. Don't include the filename in the folder path.97- `fileName` allows: `a-z`, `A-Z`, `0-9`, `.`, `-`. Other characters become `_`.98- `useUniqueFileName` defaults to `true` (a unique suffix is appended). To overwrite an exact-named file, set `useUniqueFileName: false` and `overwriteFile: true`.99- `customMetadata` fields must be created in the DAM first.100101## Procedure1021031. **Get a public URL**: Confirm the file is available at a publicly accessible URL. If the user has only a local file, stop and ask them to host it and provide the URL.1042. **Decide folder and tags**: Where in the ImageKit media library the file should live.1053. **Run the upload** via `mcp_imagekit_api_execute` using `client.files.upload()`.1064. **Verify the response**: Confirm a `fileId` and `url` are returned and the reported `size`/`fileType` match (`fileType` is `image` for images, `non-image` for video and other files).107108## Error Prevention109110- **Local paths fail**: Passing a local file path, Buffer, or stream is not supported — always pass a URL string.111- **Never base64-encode a file to upload it**: Converting a local file to a base64/data-URI string wastes LLM tokens and fails for large files. Host the file and pass its URL instead.112- **File size limits**: Free plan: 25MB images, 100MB videos. Paid plans: higher.113- **Version limit**: Max 100 versions per file.