Add chat attachment support: surface metadata and download images/files

Previously, get_messages and search_messages completely ignored the
attachment field on Chat API messages. This adds:

- Attachment metadata (filename, type) displayed inline in get_messages
  and search_messages output
- New download_chat_attachment tool that downloads attachments via the
  Chat API media endpoint and saves to local disk

The download uses httpx with a Bearer token against the
chat.googleapis.com/v1/media endpoint (with alt=media), which works
correctly in both OAuth 2.0 and OAuth 2.1 modes. The attachment's
downloadUri field is intentionally ignored as it points to
chat.google.com which requires browser session cookies.

Key details:
- Uses attachmentDataRef.resourceName for the media endpoint URL
- No new OAuth scopes required (existing chat_read is sufficient)
- Tool registered in the extended tier
- 10 unit tests covering metadata display, download, and edge cases
This commit is contained in:
Drew Gillson
2026-02-18 17:02:18 -07:00
parent 860bc4c16f
commit 4f3eec459d
4 changed files with 571 additions and 1 deletions

View File

@@ -101,6 +101,7 @@ chat:
- search_messages
extended:
- list_spaces
- download_chat_attachment
complete: []
forms: