-
Notifications
You must be signed in to change notification settings - Fork 66
feat: Add download_attachment tool for fetching card attachments #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Problem: Currently there's no way to download/view attachments from Trello cards through the MCP server. The attachment URLs returned by get_card require authentication and cannot be accessed directly. Solution: Added a new download_attachment tool that: - Fetches attachment metadata - Downloads the file using OAuth authentication header - Returns base64-encoded data (images are returned as viewable content) Implementation Details: - Uses OAuth header: Authorization: OAuth oauth_consumer_key="...", oauth_token="..." - Query parameters don't work for attachment downloads (returns 401) - Reference: https://community.developer.atlassian.com/t/download-attachments-with-api/72386
Summary of ChangesHello @sap2me, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant enhancement by providing a dedicated tool to download attachments from Trello cards. Previously, direct access to these attachments was restricted due to authentication requirements. The new Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a new download_attachment tool, which is a great addition for fetching attachment content from Trello cards. The implementation correctly handles authentication for attachment downloads, which differs from other API calls. It also provides a good user experience by differentiating between image and non-image files in the output. My main feedback is to ensure that all API calls, including the one for downloading the attachment file, respect the client's rate limiting to prevent hitting Trello's API limits.
| const response = await axios.get(downloadUrl, { | ||
| headers: { | ||
| Authorization: `OAuth oauth_consumer_key="${this.config.apiKey}", oauth_token="${this.config.token}"`, | ||
| }, | ||
| responseType: 'arraybuffer', | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This direct call to axios.get bypasses the rate limiting implemented for this client. While a separate axios call is necessary because attachment downloads require an Authorization header instead of query parameters, it should still respect the rate limits. You should wait for an available token from the rate limiter before making the request to avoid hitting Trello's rate limits unexpectedly. This function makes two API calls, and both should be rate-limited.
| const response = await axios.get(downloadUrl, { | |
| headers: { | |
| Authorization: `OAuth oauth_consumer_key="${this.config.apiKey}", oauth_token="${this.config.token}"`, | |
| }, | |
| responseType: 'arraybuffer', | |
| }); | |
| await this.rateLimiter.waitForAvailableToken(); | |
| const response = await axios.get(downloadUrl, { | |
| headers: { | |
| Authorization: 'OAuth oauth_consumer_key="' + this.config.apiKey + '", oauth_token="' + this.config.token + '"', | |
| }, | |
| responseType: 'arraybuffer', | |
| }); |
|
@sap2me can you fix the CR comment, please? This feature is useful. |
Problem
Currently there's no way to download/view attachments from Trello cards through the MCP server. The attachment URLs returned by
get_cardrequire authentication and cannot be accessed directly.Solution
Added a new
download_attachmenttool that:Implementation Details
Authorization: OAuth oauth_consumer_key="...", oauth_token="..."Usage
{ "cardId": "card-id-or-shortlink", "attachmentId": "attachment-id" }Changes
src/trello-client.ts: AddeddownloadAttachment()methodsrc/index.ts: Registereddownload_attachmenttoolTesting
Tested manually with real Trello attachments - successfully downloads and returns images as base64 data.