plugin-mcp: auto-generated create tool for upload-enabled collections has no way to attach file content
Summary
For any collection with upload: true, plugin-mcp's auto-generated create<Collection> tool can never succeed — it has no parameter for file content, so every call fails with MissingFile: No files were uploaded.
Reproduction
- Enable the plugin on an upload collection (e.g. Payload's own
Mediaexample) withcreatecapability on. - Call the generated tool, e.g.
createMedia, with the collection's writable fields (alt, etc.). - Call fails:
Error creating resource in collection "media": MissingFile: ...
Root cause (traced in the installed @payloadcms/[email protected] / [email protected]):
- The MCP endpoint hands the raw request to a generic JSON-RPC handler (
createRequestFromPayloadRequest→mcp-handler) — no multipart parsing anywhere in that path. - The tool's input schema is generated purely from the collection's field schema (
convertCollectionSchemaToZod), with no special-casing for upload collections — no file parameter is ever generated. - The generated handler (
mcp/tools/resource/create.js) forwards only the JSON fields topayload.create({ data, ... }), never settingfile. - Payload's own
generateFileData()checkpoint then finds neitherreq.filenor an explicitfileargument and throws.
This is independent of storage backend — local disk or S3, the create operation requires an attached file before it decides where to store it. Confirmed same failure against S3-backed storage.
Suggested fix direction, and offer to contribute: for collections with upload: true, the generated tool could accept a base64-encoded file argument and pass it through as file: { data: Buffer.from(base64, 'base64'), mimetype, name, size } on the Local API create() call (supported since #708). I've verified this works end-to-end (base64 round-trip + real S3 upload) as a standalone patch — happy to open a PR if that direction is welcome, or if there's a reason upload collections were intentionally left out, that'd be useful to know too.
Versions: @payloadcms/[email protected], [email protected], Postgres adapter, @payloadcms/storage-s3.
Source: payloadcms/payload