Skip to content

Assets ​

Type
Class
Namespace
craft\mcp\capabilities
Inherits
craft\mcp\capabilities\Assets
Since
5.12.0

Asset-specific MCP capabilities: creating assets from files, replacing files, uploads, and transform URLs. Assets are listed and managed through the elements.* tools.

View source

Public Methods ​

MethodDescription
__construct()
create()
replace()
resourceByIdAndSite()
transformUrl()

__construct() ​

View source

Arguments ​

  • $actor
  • $assetAdapter
  • $assets
  • $elementSerializer
  • $elements
  • $mcpAssetUploads

create() ​

View source

Arguments ​

  • $attributes
  • $fields
  • $file
  • $folderId
  • $volumeId
  • $filename

replace() ​

View source

Arguments ​

  • $assetId
  • $file
  • $filename

resourceByIdAndSite() ​

View source

Arguments ​

  • $id
  • $siteId

Returns ​

array{asset: array<string,mixed>}

transformUrl() ​

View source

Arguments ​

  • $transform (array<string,mixed>, string) – Named image transform handle or inline transform parameters.
  • $id
  • $uid
  • $siteId (integer, null) – Site ID to load the asset in.
  • $transformer (string, null) – Reserved for compatibility; custom transformer selection is unavailable in Craft 5.

Returns ​

array{url: string, mimeType: string, width: int|null, height: int|null}

Constants ​

ConstantDescription
CreateAttributesSchema
FieldsSchema
FileSchema