Skip to content

Add the Agent Drive tools: upload_file, list_files, get_file, delete_file - #81

Merged
shalim786 merged 2 commits into
mainfrom
drive/tools
Oct 15, 2026
Merged

shalim786 merged 2 commits into
mainfrom
drive/tools

Conversation

@shalim786

@shalim786 shalim786 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR

Adds four Agent Drive tools (AgentMail Labs, US only): upload_file, list_files, get_file and delete_file. It bumps the toolkit to 0.15.0.

Requires agentmail 0.5.46, the SDK release with client.inboxes.files (from agentmail-docs#314). Against it, tsc --noEmit reports nothing for these tools.

Design: one upload tool

The API uploads in three steps: Create File returns a presigned PUT, the client sends the bytes there, then calls Complete File. A model can't make that PUT, so upload_file does all three in one call:

  • It takes content as plain text (encoding: utf8, the default) or base64 for any other bytes.
  • It computes the size and the base64 SHA-256 itself, with WebCrypto, so it works without Node's Buffer.
  • It PUTs the bytes with exactly the signed headers. It sets redirect: 'error' (a presigned S3 URL never redirects) and a 60-second timeout.
  • It then completes the file and returns it.

Text content defaults to text/plain; charset=utf-8. Base64 content without a contentType gets the API's application/octet-stream.

The identical call is safe to retry. The API returns the file it already made, and completes it itself if the bytes had landed. So only a file still waiting for its bytes gets another PUT.

Size: the hosted MCP server accepts request bodies up to 10 MB, which is roughly 7 MB of file as base64. The API caps a file at 100 MiB.

There's no url variant like the one attachments have. The toolkit would have to fetch arbitrary URLs from the MCP host itself, which is a request-forgery risk.

Outputs

FileItemSchema and FileSchema allowlist the fields an agent uses: fileId, inboxId, path, name, size, contentType, status, the timestamps, expiresAt, plus downloadUrl/downloadExpiresAt on get_file and upload_file. The API's sha256 and the inbox's duplicate email stay out.

Tests

  • tests/drive.test.ts covers:
    • size and SHA-256 computed from the content, and the PUT carrying exactly the signed headers and bytes before completing;
    • base64 decoding, the API-side content-type default, and expiresAt passed as a Date;
    • invalid base64 refused before any call;
    • a refused PUT that doesn't complete;
    • a ready file (an identical retry) returned with no PUT;
    • get_file leaving out sha256 and email.
  • Fixtures and arguments for all four tools are added to the catalog, so the contract and MCP tests cover them.
  • pnpm lint, pnpm build and pnpm test (673 tests) pass.

After merge

Publish to npm, then agentmail-mcp bumps agentmail-toolkit and its exact agentmail pin, adds the tools to coreTools, and regenerates the manifest.

🤖 Generated with Claude Code

shalim786 and others added 2 commits October 14, 2026 13:55
…file

upload_file runs the API's three-step upload in one call (create, PUT the
bytes to the presigned URL, complete), since a model can't make the PUT:
it takes text, or base64 for other bytes, and computes the size and SHA-256
itself. list_files, get_file and delete_file map one to one. Results leave
out the file's sha256 and the inbox's duplicate email. Bumps to 0.15.0.

Needs the agentmail SDK release that adds client.inboxes.files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0.5.46 is the SDK release with client.inboxes.files; tsc --noEmit no
longer reports it missing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@shalim786
shalim786 marked this pull request as ready for review October 14, 2026 23:58
@shalim786
shalim786 merged commit 09f541b into main Oct 15, 2026
2 checks 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.

2 participants