Skip to main content
Glama

upload-file

Upload files or images to Zulip workspaces by providing filename and base64 content. Supports automatic MIME type detection for various file formats.

Instructions

Upload a file or image to Zulip.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYesName of the file including extension (e.g., 'document.pdf', 'image.png')
contentYesBase64 encoded file content
content_typeNoMIME type (e.g., 'image/png', 'application/pdf'). Auto-detected if not provided

Implementation Reference

  • MCP tool handler function for 'upload-file' that receives parameters, calls ZulipClient.uploadFile, and formats success/error responses.
    async ({ filename, content, content_type }) => {
      try {
        const result = await zulipClient.uploadFile(filename, content, content_type);
        return createSuccessResponse(JSON.stringify({
          success: true,
          uri: result.uri,
          message: `File uploaded successfully! Use this URI in messages: ${result.uri}`
        }, null, 2));
      } catch (error) {
        return createErrorResponse(`Error uploading file: ${error instanceof Error ? error.message : 'Unknown error'}`);
      }
    }
  • src/server.ts:603-619 (registration)
    Registration of the 'upload-file' MCP tool including name, description, schema, and handler function.
    server.tool(
      "upload-file",
      "Upload a file or image to Zulip.",
      UploadFileSchema.shape,
      async ({ filename, content, content_type }) => {
        try {
          const result = await zulipClient.uploadFile(filename, content, content_type);
          return createSuccessResponse(JSON.stringify({
            success: true,
            uri: result.uri,
            message: `File uploaded successfully! Use this URI in messages: ${result.uri}`
          }, null, 2));
        } catch (error) {
          return createErrorResponse(`Error uploading file: ${error instanceof Error ? error.message : 'Unknown error'}`);
        }
      }
    );
  • Zod input schema defining parameters for the upload-file tool: filename, base64 content, optional content_type.
    export const UploadFileSchema = z.object({
      filename: z.string().describe("Name of the file including extension (e.g., 'document.pdf', 'image.png')"),
      content: z.string().describe("Base64 encoded file content"),
      content_type: z.string().optional().describe("MIME type (e.g., 'image/png', 'application/pdf'). Auto-detected if not provided")
    });
  • Core implementation in ZulipClient that converts base64 to buffer, creates FormData, and uploads to Zulip /user_uploads API endpoint.
    async uploadFile(filename: string, content: string, contentType?: string): Promise<{ uri: string }> {
      // Convert base64 to buffer
      const buffer = Buffer.from(content, 'base64');
      
      const formData = new FormData();
      const blob = new Blob([buffer], { type: contentType });
      formData.append('file', blob, filename);
    
      const response = await this.client.post('/user_uploads', formData, {
        headers: {
          'Content-Type': 'multipart/form-data'
        }
      });
      return response.data;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Upload') which implies a write operation, but doesn't describe what happens after upload (e.g., returns a URL, stores in Zulip), potential side effects, rate limits, or authentication requirements. The description is minimal and lacks behavioral context.

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 that states the core purpose without unnecessary words. It's appropriately sized for a straightforward upload tool and is front-loaded with the essential information.

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 write operation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what the tool returns (e.g., file URL, success confirmation), error conditions, or important behavioral aspects. The context signals show this is a 3-parameter mutation tool that needs more complete documentation.

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 description adds no parameter information beyond what's already in the schema (which has 100% coverage). It doesn't explain relationships between parameters (e.g., that content_type should match filename extension) or provide usage examples. With complete 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.

Purpose4/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 ('a file or image to Zulip'), making the purpose immediately understandable. However, it doesn't differentiate this tool from potential sibling upload tools (none are listed in the sibling tools, but the description doesn't explicitly state this is the only file upload tool).

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. While there are no obvious sibling upload tools, it doesn't mention prerequisites (e.g., authentication needs), context (e.g., where uploaded files go), or exclusions (e.g., file size limits).

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

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