Skip to main content
Glama
cristip73

MCP Server for Asana

by cristip73

asana_upload_attachment_for_object

Upload local files as attachments to Asana objects like tasks or projects using file paths and optional custom names.

Instructions

Upload a local file as attachment to an object

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
object_gidYesThe object GID to attach the file to
file_pathYesPath to the local file
file_nameNoOptional custom file name
file_typeNoOptional MIME type for the uploaded file

Implementation Reference

  • Core handler function that reads the local file using fs, creates FormData, and uploads it to Asana's attachments endpoint using fetch with Bearer token authentication.
    async uploadAttachmentForObject(objectId: string, filePath: string, fileName?: string, fileType?: string) {
      const fs = await import('fs');
      const path = await import('path');
    
      if (!fs.existsSync(filePath)) {
        throw new Error(`File not found: ${filePath}`);
      }
    
      const form = new FormData();
      const name = fileName || path.basename(filePath);
      const buffer = await fs.promises.readFile(filePath);
      const file = new File([buffer], name, { type: fileType || 'application/octet-stream' });
      form.append('parent', objectId);
      form.append('file', file);
    
      const token = Asana.ApiClient.instance.authentications['token'].accessToken;
      const response = await fetch('https://app.asana.com/api/1.0/attachments', {
        method: 'POST',
        headers: { Authorization: `Bearer ${token}` },
        body: form as any
      });
    
      if (!response.ok) {
        throw new Error(`Upload failed: ${response.status} ${await response.text()}`);
      }
    
      const result = await response.json();
      // Am adăugat tipare explicită pentru a rezolva avertismentul TypeScript
      const typedResult = result as { data: any };
      return typedResult.data;
    }
  • MCP tool dispatch handler case that extracts parameters and delegates execution to AsanaClientWrapper's uploadAttachmentForObject method.
    case "asana_upload_attachment_for_object": {
      const { object_gid, file_path, file_name, file_type } = args;
      const response = await asanaClient.uploadAttachmentForObject(object_gid, file_path, file_name, file_type);
      return {
        content: [{ type: "text", text: JSON.stringify(response) }],
      };
    }
  • Tool definition including name, description, and input schema for parameter validation.
    export const uploadAttachmentForObjectTool: Tool = {
      name: "asana_upload_attachment_for_object",
      description: "Upload a local file as attachment to an object",
      inputSchema: {
        type: "object",
        properties: {
          object_gid: {
            type: "string",
            description: "The object GID to attach the file to"
          },
          file_path: {
            type: "string",
            description: "Path to the local file"
          },
          file_name: {
            type: "string",
            description: "Optional custom file name"
          },
          file_type: {
            type: "string",
            description: "Optional MIME type for the uploaded file"
          }
        },
        required: ["object_gid", "file_path"]
      }
    };
  • Registration of the tool in the main tools array exported for MCP server.
    getAttachmentsForObjectTool,
    uploadAttachmentForObjectTool,
    downloadAttachmentTool
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 mentions uploading a file but lacks details on permissions required, rate limits, error handling, or what happens on success (e.g., returns an attachment ID). This leaves significant gaps in understanding the tool's behavior.

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 directly states the tool's purpose without unnecessary words. It is appropriately sized and front-loaded, making it easy to grasp quickly with zero waste.

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 operation with no annotations and no output schema, the description is incomplete. It fails to address key aspects like authentication needs, response format, or error conditions, making it inadequate for a tool that modifies data without structured support.

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 description coverage is 100%, so the schema already documents all parameters clearly. The description adds no additional meaning beyond what's in the schema, such as examples or constraints, resulting in a baseline score of 3 as the schema does the heavy lifting.

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 target ('a local file as attachment to an object'), making the purpose understandable. It distinguishes from sibling tools like 'asana_download_attachment' and 'asana_get_attachments_for_object' by focusing on upload rather than retrieval, though it doesn't explicitly contrast with other attachment-related tools.

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. While the description implies it's for uploading attachments, it doesn't specify scenarios, prerequisites, or exclusions, such as file size limits or supported object types, leaving usage context unclear.

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

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