Skip to main content
Glama
elmapicms

elmapicms-mcp-server

Official
by elmapicms

Upload Asset

upload_asset

Upload a local file as an asset by providing its absolute file path.

Instructions

Upload a local file as an asset. Provide the absolute file path.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesAbsolute path to the file to upload

Implementation Reference

  • Handler function for the upload_asset tool. Reads the file from disk, derives filename and MIME type, then calls client.uploadFile() and returns the result.
    }, async ({ file_path }) => {
      const fileBuffer = await readFile(file_path);
      const filename = basename(file_path);
      const mimeType = getMimeType(file_path);
    
      const result = await client.uploadFile(
        "/files",
        fileBuffer,
        filename,
        mimeType
      );
      return {
        content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
      };
    });
  • Registration and input schema for the upload_asset tool. Defines a single required 'file_path' string parameter.
    server.registerTool("upload_asset", {
      title: "Upload Asset",
      description:
        "Upload a local file as an asset. Provide the absolute file path.",
      inputSchema: {
        file_path: z
          .string()
          .describe("Absolute path to the file to upload"),
      },
  • Registration of the upload_asset tool on the MCP server via registerTool().
    server.registerTool("upload_asset", {
      title: "Upload Asset",
      description:
        "Upload a local file as an asset. Provide the absolute file path.",
      inputSchema: {
        file_path: z
          .string()
          .describe("Absolute path to the file to upload"),
      },
  • Helper function that maps file extensions to MIME types, used by upload_asset to set the Content-Type.
    function getMimeType(filePath: string): string {
      const ext = extname(filePath).toLowerCase();
      return MIME_TYPES[ext] ?? "application/octet-stream";
    }
  • Helper method on ElmapiClient that performs the multipart/form-data file upload via fetch.
    async uploadFile(
      path: string,
      fileBuffer: Buffer,
      filename: string,
      mimeType: string
    ): Promise<unknown> {
      const blob = new Blob([new Uint8Array(fileBuffer)], { type: mimeType });
      const formData = new FormData();
      formData.append("file", blob, filename);
    
      const headers: Record<string, string> = {
        Accept: "application/json",
        Authorization: `Bearer ${this.token}`,
        "project-id": this.projectId,
        // Do NOT set Content-Type — fetch sets it with the boundary automatically
      };
    
      const response = await fetch(`${this.baseUrl}${path}`, {
        method: "POST",
        headers,
        body: formData,
      });
    
      return this.handleResponse(response);
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.1.0

TDQS

B3.3/5.0
Behavior2/5

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

No annotations provided, so description carries full burden. It only states the action; lacks details on success/error behavior, file size limits, or authorization needs.

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?

Two concise sentences, front-loaded with purpose. No unnecessary words.

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

Completeness3/5

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

For a simple tool with one parameter and no output schema or annotations, the description is minimal but functional. Could mention default behavior or return info.

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

Parameters3/5

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

Schema coverage is 100% and parameter description is adequate. Description adds no further meaning beyond the schema's parameter description.

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

Purpose5/5

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

The description clearly states the action (upload) and the resource (local file as asset). It distinguishes from bulk upload siblings by specifying a single file and requiring absolute path.

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?

No guidance on when to use this tool versus alternatives like bulk_upload_assets. No prerequisites or scenarios are mentioned.

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