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);
    }
Behavior2/5

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

With no annotations provided, the description bears full responsibility to disclose side effects, permissions, or error handling. It only mentions 'Upload', implying mutation, but lacks details on file size limits, supported types, success/failure behavior, or required permissions.

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

Conciseness3/5

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

The description is very concise (two sentences), but it omits important behavioral context. While brevity is valued, it compromises completeness for a mutation tool.

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?

For a tool with no output schema and no annotations, the description should explain return values, error conditions, and execution behavior. It fails to do so, leaving significant gaps for an agent to safely invoke the tool.

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% with parameter description. The description adds 'Provide the absolute file path,' which largely echoes the schema. No additional semantic meaning is provided beyond what the schema already states.

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 that the tool uploads a local file as an asset, which is distinct from sibling tools like delete_asset or list_assets. However, it could be more explicit about the nature of assets in this context.

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, nor any prerequisites or conditions. The description simply states what it does, without helping the agent decide when to choose upload over other asset-related tools.

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/elmapicms/elmapicms-mcp-server'

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