Skip to content

fix: map chat attachments to MCP storage uploads - #1

Merged
eldadfux merged 3 commits into
mainfrom
fix/chat-attachment-storage-upload
Aug 5, 2026
Merged

fix: map chat attachments to MCP storage uploads#1
eldadfux merged 3 commits into
mainfrom
fix/chat-attachment-storage-upload

Conversation

@eldadfux

@eldadfux eldadfux commented Aug 5, 2026

Copy link
Copy Markdown
Member

Summary

  • Rewrite storage_create_file file args from turn attachment ids/names to MCP inline {filename, content, encoding: base64} before the tool call
  • Default file_id to unique() and stop clarifying auto vs custom ID (no way for the user to enter a custom ID)
  • Prefer same-turn upload when attachments are present; unit tests cover the write-guard rewrite

Depends on appwrite/mcp#93 (raise MAX_INLINE_BYTES to 10MB).
Cloud clarify attachment carry-forward: https://github.com/appwrite-labs/cloud/pull/3623

Test plan

  • Attach an image in Console chat and ask to upload it to a bucket without providing a URL
  • Confirm agent does not ask auto vs custom file ID
  • Confirm storage_create_file succeeds with inline base64 (not a local path / attachment id string)
  • python -m pytest tests/test_write_guard_attachments.py

Rewrite storage_create_file file args from turn attachment ids to inline
base64, default file_id to unique(), and skip auto/custom ID clarify so
uploads work in the same turn without asking the user for URLs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@greptile-apps

greptile-apps Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR maps chat attachments to MCP inline file payloads before Storage calls and streamlines automatic file ID selection.

  • Resolves current-turn attachment IDs or filenames into base64-encoded MCP file objects.
  • Applies file resolution within the write-guard argument normalization path.
  • Updates agent guidance to use same-turn attachments and default Storage file IDs to unique().

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
app/attachment_upload.py Adds exact attachment ID/name resolution and converts attachment bytes into the MCP inline base64 file shape.
app/mcp/write_guard.py Integrates attachment conversion into argument normalization while preserving query normalization.
app/graph/builder.py Updates workflow guidance for attachment uploads and automatic file ID generation.
app/graph/tools.py Clarifies the intended roles of attachment inspection and structured ID prompts.

Reviews (3): Last reviewed commit: "Remove unused test files for attachment ..." | Re-trigger Greptile

Comment thread app/attachment_upload.py
eldadfux and others added 2 commits August 5, 2026 13:03
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@eldadfux
eldadfux merged commit 73aed64 into main Aug 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant