Skip to main content
Glama

Create or resume an Assembly

transloadit_create_assembly

Create or resume media processing assemblies to encode videos, manipulate images, convert documents, transcribe audio, and handle other file transformations with optional file uploads and completion monitoring.

Instructions

Create or resume an Assembly, optionally uploading files and waiting for completion.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instructionsNo
filesNo
fieldsNo
wait_for_completionNo
wait_timeout_msNo
upload_concurrencyNo
upload_chunk_sizeNo
upload_behaviorNo
expected_uploadsNo
assembly_urlNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
errorsNo
statusYes
uploadNo
assemblyNo
warningsNo
next_stepsNo

Implementation Reference

  • The handler function for 'transloadit_create_assembly' which processes assembly creation, input files, template merging, and optionally waits for assembly completion.
    server.registerTool(
      'transloadit_create_assembly',
      {
        title: 'Create or resume an Assembly',
        description:
          'Create or resume an Assembly, optionally uploading files and waiting for completion.',
        inputSchema: createAssemblyInputSchema,
        outputSchema: createAssemblyOutputSchema,
      },
      async (
        {
          instructions,
          files,
          fields,
          wait_for_completion,
          wait_timeout_ms,
          upload_concurrency,
          upload_chunk_size,
          upload_behavior,
          expected_uploads,
          assembly_url,
        },
        extra,
      ) => {
        const liveClient = createLiveClient(options, extra)
        if ('error' in liveClient) return liveClient.error
        const { client } = liveClient
        const tempCleanups: Array<() => Promise<void>> = []
        const warnings: Array<{ code: string; message: string; hint?: string; path?: string }> = []
        let templatePathHint: string | undefined
    
        try {
          const fileInputs = files ?? []
          const urlInputs = fileInputs.filter((file) => file.kind === 'url')
          const hasUrlInputs = urlInputs.length > 0
          let inputFilesForPrep = fileInputs
          let params = parseInstructions(instructions) ?? ({} as CreateAssemblyParams)
          let allowStepsOverride = true
          let mergedInstructions: CreateAssemblyParams | undefined
          let mergedSteps: Record<string, unknown> | undefined
          let mergedFields: Record<string, unknown> | undefined
    
          let analysis = analyzeSteps(isRecord(params.steps) ? params.steps : {})
    
          if (params.template_id) {
            templatePathHint = templatePathHint ?? 'instructions.template_id'
            let template: Awaited<ReturnType<typeof client.getTemplate>>
            try {
              template = await client.getTemplate(params.template_id)
            } catch (error) {
              const isTemplateNotFound =
                (error instanceof ApiError && error.code === 'TEMPLATE_NOT_FOUND') ||
                getHttpStatusCode(error) === 404
    
              if (isTemplateNotFound) {
                const templateId = params.template_id
                const hint = isBuiltinTemplateId(templateId)
                  ? 'Builtin template not found. Call transloadit_list_templates with include_builtin: "exclusively-latest" to discover builtins.'
                  : 'Template not found. Call transloadit_list_templates to discover available templates.'
                return buildToolError('mcp_template_not_found', `Template not found: ${templateId}`, {
                  path: templatePathHint,
                  hint,
                })
              }
              throw error
            }
            allowStepsOverride = template.content.allow_steps_override !== false
            try {
              const merged = mergeTemplateContent(
                template.content,
                toAssemblyInstructionsInput(params),
              )
              mergedInstructions = merged as CreateAssemblyParams
              mergedSteps = isRecord(merged.steps) ? (merged.steps as Record<string, unknown>) : {}
              mergedFields = isRecord(merged.fields) ? (merged.fields as Record<string, unknown>) : {}
              analysis = analyzeSteps(mergedSteps)
            } catch (error) {
              if (error instanceof Error && error.message === 'TEMPLATE_DENIES_STEPS_OVERRIDE') {
                return buildToolError(
                  'mcp_template_override_denied',
                  'Template forbids step overrides; remove steps overrides or choose a different template.',
                  { path: templatePathHint },
                )
              }
              throw error
            }
          } else {
            mergedInstructions = params
            mergedSteps = isRecord(params.steps) ? (params.steps as Record<string, unknown>) : {}
            mergedFields = isRecord(params.fields) ? (params.fields as Record<string, unknown>) : {}
          }
    
          if (hasUrlInputs) {
            if (!analysis.hasHttpImport && !analysis.requiresUpload) {
              inputFilesForPrep = fileInputs.filter((file) => file.kind !== 'url')
              warnings.push({
                code: 'mcp_url_inputs_ignored',
                message: 'URL inputs were ignored because the template does not require input files.',
                hint: 'If you meant to process a URL, use a template that imports URLs (e.g. builtin/serve-preview@0.0.1), or call transloadit_list_templates with include_builtin: "exclusively-latest" to discover builtins.',
                path: templatePathHint ?? 'instructions',
              })
            } else if (analysis.hasHttpImport) {
              if (!allowStepsOverride) {
                if (analysis.requiresUpload) {
                  warnings.push({
                    code: 'mcp_template_import_override_denied',
                    message:
                      'Template forbids step overrides; URL inputs will be downloaded and uploaded via tus instead of /http/import.',
                    path: templatePathHint ?? 'instructions.template_id',
                  })
                } else {
                  return buildToolError(
                    'mcp_template_override_denied',
                    'Template forbids step overrides; URL inputs cannot be mapped to /http/import.',
                    { path: templatePathHint ?? 'instructions.template_id' },
                  )
                }
              } else if (mergedSteps) {
                params.steps = mergeImportOverrides(
                  mergedSteps,
                  isRecord(params.steps) ? params.steps : undefined,
                  analysis.importStepNames,
                ) as CreateAssemblyParams['steps']
              }
            }
          }
    
          if (mergedInstructions) {
            const fieldTemplateContent = JSON.stringify(mergedInstructions)
            const requiredFields = collectFieldNames(fieldTemplateContent)
            const providedFields = mergeFieldValues(
              mergedFields,
              isRecord(fields) ? (fields as Record<string, unknown>) : undefined,
            )
            const missingFields = requiredFields.filter((fieldName) => !(fieldName in providedFields))
            const effectiveMissing =
              hasUrlInputs && analysis.hasHttpImport
                ? missingFields.filter((fieldName) => fieldName !== 'input')
                : missingFields
    
            if (effectiveMissing.length > 0) {
              return buildToolError(
                'mcp_missing_fields',
                `Missing required fields: ${effectiveMissing.join(', ')}`,
                {
                  path: 'fields',
                  hint: 'Provide these field names under the fields argument.',
                },
              )
            }
          }
          const prep = await prepareInputFiles({
            inputFiles: inputFilesForPrep,
            params,
            fields,
            base64Strategy: 'tempfile',
            urlStrategy: 'import-if-present',
            maxBase64Bytes,
          }).catch((error) => {
            const message = error instanceof Error ? error.message : 'Invalid file input.'
            if (message.startsWith('Duplicate file field')) {
              return buildToolError('mcp_duplicate_field', message, { path: 'files' })
            }
            if (message.startsWith('Base64 payload exceeds')) {
              return buildToolError('mcp_base64_too_large', message, {
                hint: 'Use a URL import or path upload instead.',
              })
            }
            return buildToolError('mcp_invalid_args', message)
          })
          if ('content' in prep) {
            return prep
          }
          params = prep.params
          const filesMap = prep.files
          const uploadsMap = prep.uploads
          tempCleanups.push(...prep.cleanup)
    
          const totalFiles = Object.keys(filesMap).length + Object.keys(uploadsMap).length
          const uploadSummary: UploadSummary = {
            status: totalFiles > 0 ? 'complete' : 'none',
            total_files: totalFiles,
          }
    
          const timeout = wait_timeout_ms
          const waitForCompletion = wait_for_completion ?? false
          const uploadBehavior = upload_behavior ?? (waitForCompletion ? 'await' : 'background')
          const uploadConcurrency = upload_concurrency
          const chunkSize = upload_chunk_size
    
          let assembly: Awaited<ReturnType<typeof client.createAssembly>>
          try {
            assembly = assembly_url
              ? await client.resumeAssemblyUploads({
                  assemblyUrl: assembly_url,
                  files: filesMap,
                  uploads: uploadsMap,
                  waitForCompletion,
                  timeout,
                  uploadConcurrency,
                  chunkSize,
                  uploadBehavior,
                })
              : await client.createAssembly({
                  params,
                  files: filesMap,
                  uploads: uploadsMap,
                  waitForCompletion,
                  timeout,
                  uploadConcurrency,
                  chunkSize,
                  uploadBehavior,
                  expectedUploads: expected_uploads,
                })
          } catch (error) {
            if (isErrnoException(error) && error.code === 'ENOENT') {
              return buildToolError('mcp_file_not_found', error.message, {
                hint: 'Path inputs only work when the MCP server can read local files. For hosted MCP, use url/base64 or upload via `npx -y @transloadit/node upload`.',
              })
            }
            throw error
          }
    
          if (assembly_url) {
            uploadSummary.resumed = true
          }
    
          if (totalFiles === 0) {
            uploadSummary.status = 'none'
          } else if (uploadBehavior === 'none') {
            uploadSummary.status = 'none'
          } else if (uploadBehavior === 'background') {
            uploadSummary.status = 'uploading'
          }
    
          if (isRecord(assembly.upload_urls)) {
            uploadSummary.upload_urls = assembly.upload_urls as Record<string, string>
          }
    
          const nextSteps = waitForCompletion
            ? []
            : ['transloadit_wait_for_assembly', 'transloadit_get_assembly_status']
    
          return buildToolResponse({
            status: 'ok',
            assembly,
            upload: uploadSummary,
            next_steps: nextSteps,
            warnings: warnings.length > 0 ? warnings : undefined,
          })
        } finally {
          await Promise.all(tempCleanups.map((cleanup) => cleanup()))
        }
      },
  • Input validation schema for 'transloadit_create_assembly' using zod.
    const createAssemblyInputSchema = z.object({
      instructions: z.unknown().optional(),
      files: z.array(inputFileSchema).optional(),
      fields: z.record(z.string(), z.unknown()).optional(),
      wait_for_completion: z.boolean().optional(),
      wait_timeout_ms: z.number().int().positive().optional(),
      upload_concurrency: z.number().int().positive().optional(),
      upload_chunk_size: z.number().int().positive().optional(),
      upload_behavior: z.enum(['await', 'background', 'none']).optional(),
      expected_uploads: z.number().int().positive().optional(),
      assembly_url: z.string().optional(),
    })
  • Output validation schema for 'transloadit_create_assembly' using zod.
    const createAssemblyOutputSchema = z.object({
      status: z.enum(['ok', 'error']),
      assembly: z.unknown().optional(),
      upload: z
        .object({
          status: z.enum(['none', 'uploading', 'complete']),
          total_files: z.number().int().nonnegative(),
          resumed: z.boolean().optional(),
          upload_urls: z.record(z.string(), z.string()).optional(),
        })
        .optional(),
      next_steps: z.array(z.string()).optional(),
      errors: z.array(toolMessageSchema).optional(),
      warnings: z.array(toolMessageSchema).optional(),
    })
  • Registration/documentation of 'transloadit_create_assembly' in the server card definition.
    {
      name: 'transloadit_create_assembly',
      title: 'Create or resume an Assembly',
      description:
        'Create or resume an Assembly, optionally uploading files and waiting for completion.',
      inputSchema: {
        type: 'object',
        additionalProperties: false,
        properties: {
          instructions: { type: ['object', 'array', 'string', 'number', 'boolean', 'null'] },
          files: {
            type: 'array',
            items: { type: 'object' },
          },
          fields: { type: 'object' },
          wait_for_completion: { type: 'boolean' },
          wait_timeout_ms: { type: 'number' },
          upload_concurrency: { type: 'number' },
          upload_chunk_size: { type: 'number' },
          upload_behavior: { type: 'string', enum: ['await', 'background', 'none'] },
          expected_uploads: { type: 'number' },
          assembly_url: { type: 'string' },
        },
      },
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It hints at creation/resumption and optional waiting, but doesn't disclose critical traits like authentication needs, rate limits, error handling, side effects, or what 'resume' entails. For a complex tool with 10 parameters, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise—a single sentence with zero wasted words. It's front-loaded with the core action ('Create or resume an Assembly') and efficiently notes key optional features. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (10 parameters, nested objects, no annotations) and an output schema (which reduces need to describe returns), the description is incomplete. It omits essential context like parameter purposes, behavioral expectations, and differentiation from siblings. The output schema helps, but the description doesn't sufficiently guide usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate but fails to do so. It mentions 'optionally uploading files' (hinting at 'files' parameter) and 'waiting for completion' (hinting at 'wait_for_completion'), but ignores 8 other parameters like 'instructions', 'fields', timeouts, and concurrency settings. The description adds minimal value beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Create or resume') and resource ('an Assembly'), and mentions optional file uploads and waiting for completion. It doesn't explicitly differentiate from sibling tools like 'transloadit_wait_for_assembly' or 'transloadit_get_assembly_status', but the core purpose is well-defined.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions 'optionally uploading files and waiting for completion' but doesn't explain when to use it over 'transloadit_wait_for_assembly' for waiting, or 'transloadit_get_assembly_status' for checking status. No prerequisites or exclusions are stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/transloadit/node-sdk'

If you have feedback or need assistance with the MCP directory API, please join our Discord server