https://linen.dev logo
p
Using Claude cowork. Need to upload file from sandbox to r2/s3 for attaching outlook. Is there an MCP tool call the agent can perform to received a pre signed url that it can post bytes to? I see this is possible with the API
b
Hi there, Looking deeper, this should be possible in a Tool Router/workbench-style session. The key is that Outlook needs a Composio storage key, not the sandbox path itself. If the file is already under
/mnt/files
, have the agent call
get_mount_file_s3_key("your-file.ext")
. If the file is elsewhere in the sandbox, have it call
upload_local_file("/path/to/your-file.ext")
and use the returned
s3key
. Then pass that into Outlook as the attachment:
Copy code
{
  "attachment": {
    "name": "your-file.ext",
    "mimetype": "application/octet-stream",
    "s3key": "<returned s3key>"
  }
}
The part that will not work is passing
/mnt/files/...
,
/workspace/...
, a URL, or a local file path directly as `s3key`; the Outlook tool resolves
s3key
from Composio storage, not from the sandbox filesystem. If those helper tools are not visible in your Claude Cowork session, use the API/SDK upload flow instead, then pass the returned
{name, mimetype, s3key}
object to Outlook. Sent by Composio Support Agent
a
hey @PM, this is possble. Lmk if you were unable to do it. A prompt and sample response from why it wasn't able to would help
p
to be clear, I am not running in the Composio sandbox. what tool call would i make to achieve this
a
Curious why you want to upload file to r2/s3. If usecase is something like sending email in outlook with attachment then you can use Outlook send email/message tool - uploading the file to s3 and passing the url in the tool input will be handled by Composio
p
i am working in claude cowork, which can only run arbitrary code within a linux sandox container
Composio MCP is enabled on it. So imagine the cowork agent does some work and generates a large PDF report that needs to be sent from outlook via Composio
if we were running some daytona sandbox, I know we can set up some mnt path into composio. but i do not believe this is possible with cowork. so our options are to either read content into context and generate Composiio outlook MCP tool call with attachment contents specified
OR provide the s3url param
so ideally there would be some Composio tool call like
REQUEST_URL_FOR_UPLOAD
that basically wraps this https://docs.composio.dev/reference/api-reference/files/postFilesUploadRequest#request-body.
my agent would be able to make that tool call annd just curl POST the file contents to the returned URL
I couldn't find any support for this kind of setup, so I just rolled out a custom MCP with essentially this REQUEST_URL_FOR_UPLOAD
@Abhishek please lmk
b
checking
p
thanks!
a
quick clarification and sorry for the earlier confusion. There are two different upload flows, depending on where the file exists: If the file is already inside Composio Remote Workbench, If your Composio MCP session exposes
COMPOSIO_REMOTE_WORKBENCH
(its exposed in the Composio consumer MCP you use), call that tool and run the preloaded
upload_local_file()
Python helper with the file's local Workbench path:
Copy code
result, error = upload_local_file("/tmp/report.pdf")
if error:
    raise Exception(error)

s3key = result["s3key"]
The helper uploads the file to Composio-hosted storage and returns the s3key required by the Outlook send-email tool. If the file exists only inside Claude Cowork, a Cowork-local path cannot be passed to
upload_local_file()
, because Cowork and Composio Remote Workbench are separate environments. In that case: Call POST
/api/v3/files/upload/request
([doc](https://docs.composio.dev/reference/api-reference/files)) to receive new_presigned_url and key. PUT the raw file bytes to new_presigned_url. Use the returned key as the attachment's s3key. In either flow, pass the attachment to Outlook as:
Copy code
{
  "attachment": {
    "name": "report.pdf",
    "mimetype": "application/pdf",
    "s3key": "<returned s3key or key>"
  }
}
For your current Cowork setup, the custom MCP wrapper you created around /api/v3/files/upload/request is the correct approach. You do not need to provide or manage your own storage bucket.
lmk if you have any questions around this
p
thanks @Abhishek, the MCP wrapper we rolled out has been working well. Definitely something to consider for future MCP releases. I'm sure there are many other users with similar Cowork/Code workflows that need this.