Skip to main content
Glama
cristip73

MCP Server for Asana

by cristip73

asana_download_attachment

Download Asana attachments to your local directory for offline access or backup.

Instructions

Download an attachment locally

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
attachment_gidYesThe attachment GID to download
output_dirNoDirectory to save the file (defaults to ~/downloads)

Implementation Reference

  • Tool handler switch case that destructures input parameters and delegates to AsanaClientWrapper.downloadAttachment method, returning JSON response.
    case "asana_download_attachment": {
      const { attachment_gid, output_dir } = args;
      const response = await asanaClient.downloadAttachment(attachment_gid, output_dir);
      return {
        content: [{ type: "text", text: JSON.stringify(response) }],
      };
    }
  • Core implementation that fetches attachment metadata, downloads the file from Asana's download_url using fetch, determines filename and MIME type, and saves to local directory (default ~/downloads).
    async downloadAttachment(attachmentId: string, outputDir?: string) {
      const fs = await import('fs');
      const path = await import('path');
      const os = await import('os');
      const { pipeline } = await import('stream/promises');
    
      outputDir = outputDir || path.join(os.homedir(), 'downloads');
    
      const attachment = await this.getAttachment(attachmentId);
      const downloadUrl = attachment.download_url || attachment.downloadUrl;
      if (!downloadUrl) {
        throw new Error('Attachment does not have a download_url');
      }
    
      await fs.promises.mkdir(outputDir, { recursive: true });
    
      const res = await fetch(downloadUrl);
      if (!res.ok || !res.body) {
        throw new Error(`Failed to download attachment: ${res.status}`);
      }
    
      let filename: string = attachment.name || attachment.gid;
      const contentType = res.headers.get('content-type') || attachment.mime_type;
      if (!path.extname(filename) && contentType) {
        filename += this.extensionForMime(contentType);
      }
    
      const filePath = path.join(outputDir, filename);
      const fileStream = fs.createWriteStream(filePath);
      await pipeline(res.body, fileStream);
    
      return { attachment_id: attachmentId, file_path: filePath, mime_type: contentType };
    }
  • Defines the Tool object with name, description, and inputSchema for validation in MCP.
    export const downloadAttachmentTool: Tool = {
      name: "asana_download_attachment",
      description: "Download an attachment locally",
      inputSchema: {
        type: "object",
        properties: {
          attachment_gid: {
            type: "string",
            description: "The attachment GID to download"
          },
          output_dir: {
            type: "string",
            description: "Directory to save the file (defaults to ~/downloads)"
          }
        },
        required: ["attachment_gid"]
      }
    };
  • Includes downloadAttachmentTool in the exported tools array for MCP tool registration.
      getAttachmentsForObjectTool,
      uploadAttachmentForObjectTool,
      downloadAttachmentTool
    ];
  • Validation case that checks parameters against the tool's schema.
        case 'asana_download_attachment':
          result = validateGid(params.attachment_gid, 'attachment_gid');
          if (!result.valid) errors.push(...result.errors);
          break;
      }
    
      return {
        valid: errors.length === 0,
        errors
      };
    }
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 ('download locally') but doesn't mention critical traits like file format handling, error conditions (e.g., invalid GID), network usage, or whether it overwrites existing files. For a tool that interacts with external resources and local storage, this is a significant gap in transparency.

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 directly states the tool's action without unnecessary words. It's appropriately sized for a simple download operation and front-loaded with the core purpose.

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 tool's complexity (simple download with 2 parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't address behavioral aspects like error handling or file management, and while the schema covers parameters well, the overall context for safe and effective use is lacking.

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%, with clear parameter descriptions in the input schema. The description adds no additional meaning beyond implying local file saving, which is already covered by the schema's 'output_dir' description. This meets the baseline of 3 since the schema does the heavy lifting, but the description doesn't enhance parameter understanding.

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 ('download') and resource ('attachment'), making the purpose immediately understandable. It distinguishes from sibling tools like 'asana_upload_attachment_for_object' by focusing on retrieval rather than creation. However, it doesn't specify the source (Asana) beyond the tool name prefix, which keeps it from being fully specific.

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 like 'asana_get_attachments_for_object' (which lists attachments) or other download methods. It lacks context about prerequisites, such as needing an attachment GID from another operation, or exclusions for when not to use it.

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