{"record":{"id":"b19b34e7d00315d0","repo":"payloadcms/payload","slug":"collection-collectionslug-does-not-support-fi","errorCode":null,"errorMessage":"Collection \"${collectionSlug}\" does not support file uploads.","messagePattern":"Collection \"(.+?)\" does not support file uploads\\.","errorType":"validation","errorClass":"APIError","httpStatus":400,"severity":"error","filePath":"packages/plugin-mcp/src/mcp/builtin/collections/fileInput.ts","lineNumber":73,"sourceCode":"\n  if (input.source === 'uploadReference') {\n    try {\n      return await getFileFromUploadInstructions({ collectionSlug, file: input.file, req })\n    } catch (error) {\n      if (error instanceof Error && error.message === 'Staged upload was not found.') {\n        throw new APIError(\n          'Staged upload not found. Complete the upload action first, or use base64 for small local files.',\n          400,\n        )\n      }\n      throw error\n    }\n  }\n\n  const uploadConfig = req.payload.collections[collectionSlug]?.config.upload\n\n  if (!uploadConfig) {\n    throw new APIError(`Collection \"${collectionSlug}\" does not support file uploads.`, 400)\n  }\n\n  const maxFileSize = req.payload.config.upload.limits?.fileSize\n  let file: File\n\n  if (input.source === 'base64') {\n    const data = decodeBase64({ maxFileSize, value: input.data })\n\n    file = {\n      name: sanitizeFilename(input.name),\n      data,\n      mimetype: input.mimeType,\n      size: data.length,\n    }\n  } else {\n    if (uploadConfig.pasteURL === false) {\n      throw new APIError(\n        `Uploading files from URLs is disabled for collection \"${collectionSlug}\".`,","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/plugin-mcp/src/mcp/builtin/collections/fileInput.ts#L55-L91","documentation":"Thrown as a 400 when `resolveFile` is asked to handle a file for a collection whose config has no `upload` block — i.e. the target collection is not a Payload upload collection, so there is no `uploadConfig` to read `pasteURL`, file size limits, or storage adapters from.","triggerScenarios":"Calling an MCP file tool against a collection slug whose `CollectionConfig` lacks an `upload` property; passing a non-upload collection slug (e.g. a plain relationship collection) to a tool that ultimately calls `resolveFile`.","commonSituations":"Typo in the `collectionSlug` argument; pointing the tool at a collection that was originally an upload collection but had its `upload` block removed; misconfiguring which collections the MCP plugin exposes file tools for.","solutions":["Confirm the collection slug is correct and the collection is configured with an `upload` block in Payload","If the collection should accept files, add an `upload` config (with `staticURL`, `staticDir`, etc.) to it","Restrict the MCP tool's allowed collections so non-upload collections cannot be targeted"],"exampleFix":"// before — collection without upload\n{ slug: 'notes', fields: [...] }\n// after — enable uploads\n{ slug: 'notes', upload: { staticURL: '/media', staticDir: 'media' }, fields: [...] }","handlingStrategy":"validation","validationCode":"// Confirm the collection is an upload collection before calling a file tool\nconst col = payload.config.collections.find(c => c.slug === slug)\nif (!col?.upload) throw new Error(`${slug} is not an upload collection`)","typeGuard":"import type { CollectionConfig } from 'payload'\nfunction isUploadCollection(c: CollectionConfig | undefined): c is CollectionConfig & { upload: NonNullable<CollectionConfig['upload']> } {\n  return !!c && !!c.upload\n}","tryCatchPattern":"import { APIError } from 'payload'\ntry {\n  await fileTool.call({ collectionSlug: slug, ... })\n} catch (e) {\n  if (e instanceof APIError && e.statusCode === 400 && /does not support file uploads/.test(e.message)) {\n    // route to a non-file create flow instead\n  }\n  throw e\n}","preventionTips":["Restrict the MCP tool's accepted slugs to collections that have an `upload` block","Add an integration test that asserts every collection the tool advertises has `upload` defined","Validate the slug against payload.config.collections at the tool boundary"],"tags":["mcp","file-upload","configuration","collection-config"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}