Skip to main content
Glama

Upload File

upload_file

Transfer files such as images and documents to the Emlog blog system via API, specifying the file path and resource category ID for efficient content management.

Instructions

Upload a file (image, document, etc.)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesLocal path to the file to upload
sidNoResource category ID

Implementation Reference

  • MCP tool handler for 'upload_file' that invokes emlogClient.uploadFile and formats the response or error.
    async ({ file_path, sid }) => {
      try {
        const result = await emlogClient.uploadFile(file_path, sid);
        return {
          content: [{
            type: "text",
            text: `Successfully uploaded file: ${result.url}`
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: `Error: ${error instanceof Error ? error.message : String(error)}`
          }],
          isError: true
        };
      }
    }
  • Input schema using Zod for validating tool parameters: file_path (required string) and sid (optional number).
    inputSchema: {
      file_path: z.string().describe("Local path to the file to upload"),
      sid: z.number().optional().describe("Resource category ID")
    }
  • src/index.ts:513-542 (registration)
    Registration of the 'upload_file' tool with server.registerTool, including title, description, schema, and handler.
    server.registerTool(
      "upload_file",
      {
        title: "Upload File",
        description: "Upload a file (image, document, etc.)",
        inputSchema: {
          file_path: z.string().describe("Local path to the file to upload"),
          sid: z.number().optional().describe("Resource category ID")
        }
      },
      async ({ file_path, sid }) => {
        try {
          const result = await emlogClient.uploadFile(file_path, sid);
          return {
            content: [{
              type: "text",
              text: `Successfully uploaded file: ${result.url}`
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: `Error: ${error instanceof Error ? error.message : String(error)}`
            }],
            isError: true
          };
        }
      }
    );
  • Core file upload logic in EmlogClient class: checks file existence, prepares FormData, posts to API, returns media object.
    async uploadFile(filePath: string, sid?: number): Promise<EmlogMedia> {
      if (!fs.existsSync(filePath)) {
        throw new Error(`File not found: ${filePath}`);
      }
      
      const formData = new FormData();
      formData.append('file', fs.createReadStream(filePath));
      
      if (sid) formData.append('sid', String(sid));
      formData.append('api_key', this.apiKey);
      
      const response = await this.api.post('/?rest-api=upload', formData, {
        headers: {
          ...formData.getHeaders()
        }
      });
      return response.data.data;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('upload') but doesn't describe traits like required permissions, file size limits, supported formats beyond vague examples, error handling, or what happens after upload (e.g., returns a URL or ID). This leaves significant gaps for a mutation tool.

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 a single, efficient sentence with zero waste. It's front-loaded with the core action and resource, making it easy to scan. Every word contributes to conveying the basic purpose without unnecessary elaboration.

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 complexity of a file upload tool (a mutation with no annotations and no output schema), the description is incomplete. It lacks details on behavioral traits, usage context, and output expectations, leaving the agent with insufficient information to invoke it correctly beyond the basic schema.

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?

The schema description coverage is 100%, with clear descriptions for both parameters ('file_path' and 'sid'). The description adds no meaning beyond this, as it doesn't explain parameter interactions, the purpose of 'sid', or file path constraints. With high schema coverage, the baseline score of 3 is appropriate.

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

Purpose3/5

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

The description states the verb ('upload') and resource ('a file'), but it's vague about what types of files are supported ('image, document, etc.') and doesn't distinguish this tool from potential siblings like 'create_article' or 'create_note', which might also involve file uploads. It provides a basic purpose but lacks specificity.

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 is provided on when to use this tool versus alternatives. For example, it doesn't clarify if this is for standalone file uploads versus attachments in other tools like 'create_article', or mention prerequisites like authentication. The description offers no context for usage decisions.

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

Related 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/eraincc/emlog-mcp'

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