Skip to main content
Glama

upload-file

Upload a file or image to a Zulip workspace by providing filename, base64 content, and optional MIME type.

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

  • Registers the 'upload-file' tool with MCP server. The handler decodes base64 content and calls zulipClient.uploadFile, returning the uploaded file URI.
    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'}`);
        }
      }
    );
  • Defines the UploadFileSchema using zod: filename (string), content (base64 string), and optional content_type (MIME 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")
    });
  • src/server.ts:603-619 (registration)
    Registers the 'upload-file' tool on the MCP server via server.tool() with its name, description, schema, and handler.
    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'}`);
        }
      }
    );
  • Uploads a file to Zulip by converting base64 to a buffer, creating a multipart form upload via Blob, and POSTing to /user_uploads.
    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;
    }
  • TypeScript type UploadFileParams inferred from UploadFileSchema.
    export type UploadFileParams = z.infer<typeof UploadFileSchema>;
Behavior2/5

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

No annotations are provided, so the description must disclose behavioral traits. It does not mention file size limits, overwrite behavior, authentication requirements, or response format. This is insufficient for a write operation.

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

Conciseness4/5

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

The description is a single sentence with no redundancy. However, it could be slightly expanded to include key usage context without becoming verbose.

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?

The tool has no output schema and lacks details on return values, error conditions, or side effects. For a file upload tool, this is insufficient for an agent to use correctly.

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 descriptions for all three parameters. The description adds no extra meaning beyond the schema, earning the baseline score.

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), resource (file or image), and platform (Zulip). It distinguishes this tool from siblings like send-message or add-emoji-reaction by focusing on file upload.

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

Usage Guidelines3/5

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

The description implies the tool is used for uploading files, but it provides no explicit guidance on when to use it versus alternatives, nor any exclusions or prerequisites.

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