Skip to main content
Glama
agrath

Atlassian Trello MCP Server

trello_create_card_attachment

Attach a URL or upload a local file to a Trello card by providing the card ID and attachment source.

Instructions

Attach a URL or local file to a Trello card. Provide either a url (for link attachments) or filePath (for file uploads from the local filesystem).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiKeyNoTrello API key (optional if TRELLO_API_KEY env var is set)
tokenNoTrello API token (optional if TRELLO_TOKEN env var is set)
cardIdYesID or URL of the card (e.g. "abc123" or "https://trello.com/c/abc123/1-title")
urlNoURL to attach as a link (e.g. "https://example.com/doc.pdf"). Cannot be used with filePath.
filePathNoAbsolute path to a local file to upload (e.g. "/home/user/report.pdf"). Cannot be used with url.
nameNoOptional display name for the attachment
mimeTypeNoOptional MIME type (e.g. "application/pdf", "image/png"). Auto-detected for file uploads if omitted.
setCoverNoIf true, set this attachment as the card cover image

Implementation Reference

  • Handler function that executes the tool logic. Extracts credentials, validates params via validateCreateCardAttachment, calls TrelloClient.createCardAttachment(), and returns the result.
    export async function handleTrelloCreateCardAttachment(args: unknown) {
      try {
        const { credentials, params } = extractCredentials(args);
        const { cardId, url, filePath, name, mimeType, setCover} = validateCreateCardAttachment(params);
        const client = new TrelloClient(credentials);
    
        const response = await client.createCardAttachment(cardId, {
          ...(url && { url }),
          ...(filePath && { filePath }),
          ...(name && { name }),
          ...(mimeType && { mimeType }),
          ...(setCover !== undefined && { setCover })
        });
        const attachment = response.data;
    
        const result = {
          summary: filePath
            ? `Uploaded file attachment to card ${cardId}`
            : `Attached URL to card ${cardId}`,
          cardId,
          attachment: {
            id: attachment.id,
            name: attachment.name,
            url: attachment.url,
            mimeType: attachment.mimeType,
            bytes: attachment.bytes,
            isUpload: attachment.isUpload,
            date: attachment.date
          },
          rateLimit: response.rateLimit
        };
    
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(result, null, 2)
            }
          ]
        };
      } catch (error) {
        const errorMessage = error instanceof z.ZodError
          ? formatValidationError(error)
          : error instanceof Error
            ? error.message
            : 'Unknown error occurred';
    
        return {
          content: [
            {
              type: 'text' as const,
              text: `Error creating attachment: ${errorMessage}`
            }
          ],
          isError: true
        };
      }
    }
  • Tool definition with inputSchema. Defines the name 'trello_create_card_attachment', description, and schema properties (apiKey, token, cardId, url, filePath, name, mimeType, setCover), with cardId as required.
    export const trelloCreateCardAttachmentTool: Tool = {
      name: 'trello_create_card_attachment',
      description: 'Attach a URL or local file to a Trello card. Provide either a url (for link attachments) or filePath (for file uploads from the local filesystem).',
      inputSchema: {
        type: 'object',
        properties: {
          apiKey: {
            type: 'string',
            description: 'Trello API key (optional if TRELLO_API_KEY env var is set)'
          },
          token: {
            type: 'string',
            description: 'Trello API token (optional if TRELLO_TOKEN env var is set)'
          },
          cardId: {
            type: 'string',
            description: 'ID or URL of the card (e.g. "abc123" or "https://trello.com/c/abc123/1-title")'
          },
          url: {
            type: 'string',
            description: 'URL to attach as a link (e.g. "https://example.com/doc.pdf"). Cannot be used with filePath.'
          },
          filePath: {
            type: 'string',
            description: 'Absolute path to a local file to upload (e.g. "/home/user/report.pdf"). Cannot be used with url.'
          },
          name: {
            type: 'string',
            description: 'Optional display name for the attachment'
          },
          mimeType: {
            type: 'string',
            description: 'Optional MIME type (e.g. "application/pdf", "image/png"). Auto-detected for file uploads if omitted.'
          },
          setCover: {
            type: 'boolean',
            description: 'If true, set this attachment as the card cover image'
          }
        },
        required: ['cardId']
      }
  • src/index.ts:98-99 (registration)
    Import of the tool definition and handler from src/tools/advanced.ts.
    trelloCreateCardAttachmentTool,
    handleTrelloCreateCardAttachment,
  • src/index.ts:199-199 (registration)
    Tool is registered in the tool list (server.setRequestHandler for ListTools) as part of the advanced features array.
    trelloCreateCardAttachmentTool,
  • src/index.ts:317-318 (registration)
    Case statement in the CallToolRequestHandler that routes the tool call to handleTrelloCreateCardAttachment.
    case 'trello_create_card_attachment':
      result = await handleTrelloCreateCardAttachment(args);
  • Validation helper using Zod schema; validates cardId (Trello ID), optional url/filePath, name, mimeType, setCover. Requires either url or filePath via refine.
    const validateCreateCardAttachment = (args: unknown) => {
      const schema = z.object({
    
        cardId: trelloIdSchema,
        url: z.string().url().optional(),
        filePath: z.string().optional(),
        name: z.string().optional(),
        mimeType: z.string().optional(),
        setCover: z.boolean().optional()
      }).refine(data => data.url || data.filePath, {
        message: 'Either url or filePath must be provided'
      });
    
      return schema.parse(args);
    };
  • TrelloClient.createCardAttachment method that handles both file upload (multipart/form-data) and URL attachment (JSON POST) to /cards/{cardId}/attachments.
    async createCardAttachment(cardId: string, data: {
      url?: string;
      filePath?: string;
      name?: string;
      mimeType?: string;
      setCover?: boolean;
    }): Promise<TrelloApiResponse<TrelloAttachment>> {
      if (data.filePath) {
        // File upload via multipart/form-data
        const fileBuffer = await readFile(data.filePath);
        const fileName = data.name || basename(data.filePath);
        const blob = new Blob([fileBuffer], { type: data.mimeType || 'application/octet-stream' });
    
        const formData = new FormData();
        formData.append('file', blob, fileName);
        if (data.name) formData.append('name', data.name);
        if (data.mimeType) formData.append('mimeType', data.mimeType);
        if (data.setCover !== undefined) formData.append('setCover', String(data.setCover));
    
        return this.makeRequest<TrelloAttachment>(
          `/cards/${cardId}/attachments`,
          {
            method: 'POST',
            body: formData as any
          },
          `Upload file attachment to card ${cardId}`
        );
      }
    
      // URL attachment via JSON body
      const body: Record<string, any> = {};
      if (data.url) body.url = data.url;
      if (data.name) body.name = data.name;
      if (data.mimeType) body.mimeType = data.mimeType;
      if (data.setCover !== undefined) body.setCover = data.setCover;
    
      return this.makeRequest<TrelloAttachment>(
        `/cards/${cardId}/attachments`,
        {
          method: 'POST',
          body: JSON.stringify(body)
        },
        `Create URL attachment on card ${cardId}`
      );
    }
  • src/server.ts:119-120 (registration)
    Tool name listed in WRITE_TOOL_NAMES set, which controls write-allowed tool filtering in server creation.
      'trello_create_card_attachment', 'trello_delete_card_attachment'
    ]);
Behavior3/5

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

With no annotations, the description bears full responsibility for behavioral disclosure. It mentions the two attachment modes and that filePath is for local files, but does not disclose authentication requirements (though apiKey and token are in schema), error handling for exclusive parameters, or side effects. It adds some context beyond the schema but not comprehensive.

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 consists of two concise sentences that front-load the purpose. Every word contributes meaning, and there is no redundant or vague language. The structure efficiently conveys the tool's core function and parameter guidance.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (8 parameters, no output schema), the description covers the main use case but lacks details on what happens on success, error conditions (e.g., providing both url and filePath), or the response format. For a tool with no output schema, some hint about the result would be helpful. Still, it provides adequate guidance for basic usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

All parameters are described in the schema (100% coverage). The description adds value by clarifying the exclusivity of url and filePath and explaining their purposes (link attachments vs file uploads). This goes beyond the schema's individual field descriptions.

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 it attaches a URL or local file to a Trello card, using specific verbs and resource. It distinguishes between two exclusive modes (url vs filePath), making the purpose unambiguous. Among siblings, it is distinct from deletion or other card operations.

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

Usage Guidelines4/5

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

The description tells the agent when to use this tool (for attaching to a card) and provides a clear choice between two parameter combinations. It does not explicitly mention when not to use it or alternatives, but the context of sibling tools implies that this is for addition, not removal or modification.

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/agrath/Trello-Desktop-MCP'

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