#agentmail MCP issue

1 messages · Page 1 of 1 (latest)

outer ember
#

I'm using agentmail MCP and if I want to send a large file that is in a file, it looks like it incorrectly reads the contents of the file into the prompt context which subequently leads to fetch timeouts. How can I get it to just send the file based on the file name

11:48:47
warn
agent/embedded
embedded run agent end
11:50:53
warn
fetch-timeout
fetch timeout reached; aborting operation
11:50:54
warn
agent/embedded
embedded run agent end
11:53:04
warn
fetch-timeout
fetch timeout reached; aborting operation
11:53:05
warn
agent/embedded
embedded run agent end
11:53:05
warn
agent/embedded
embedded run failover decision

green oreBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> âś… Mark Solution

main kiteBOT
# outer ember I'm using agentmail MCP and if I want to send a large file that is in a file, it...

Can you grab openclaw --version too? Version matters here.

I checked the current AgentMail MCP/toolkit shape: send_message / reply_to_message accept attachments as objects with filename, optional content_id, and either:

  • content: base64 encoded file content
  • url: a URL

I don’t see a local path / filePath / “send by filename” parameter in that MCP server. So if the model is reading the file into context and then passing base64, that is expected to blow up for large files.

Practical workaround: put the file somewhere AgentMail can fetch it, then pass it as an attachment URL, e.g. conceptually:

{
  "inboxId": "...",
  "to": ["..."],
  "subject": "...",
main kiteBOT
# outer ember I'm using agentmail MCP and if I want to send a large file that is in a file, it...
  "text": "Attached.",
  "attachments": [
    {
      "filename": "large.zip",
      "url": "https://..."
    }
  ]
}

If this is through OpenClaw’s own delivery system rather than the AgentMail MCP server, OpenClaw supports outbound attachments via MEDIA:<path-or-url> on its own line, and the CLI has openclaw message send --media /path/to/file: https://docs.openclaw.ai/start/openclaw and https://docs.openclaw.ai/help/faq#media-and-attachments

But for external MCP tool results, local MEDIA:/path is intentionally restricted/trusted differently, so I would not rely on an AgentMail MCP result to smuggle a host-local path through. For AgentMail specifically, URL is the clean route unless they add first-class filePath support to their MCP server. If you want that behavior, this is probably worth filing upstream with AgentMail MCP; if OpenClaw is the piece reading the file unexpectedly, file it with your OpenClaw version + the exact prompt/tool call shape here: https://github.com/openclaw/openclaw/issues

outer ember
#

So how would I pass it as an attachment

main kiteBOT
# outer ember So how would I pass it as an attachment

For AgentMail MCP, put it in the attachments array on the send_message or reply_to_message call.

For a large file, use a URL:

{
  "inboxId": "YOUR_INBOX_ID",
  "to": ["person@example.com"],
  "subject": "Large file",
  "text": "Attached.",
  "attachments": [
    {
      "filename": "large-file.zip",
      "url": "https://your-file-host.example.com/large-file.zip"
    }
  ]
main kiteBOT
# outer ember So how would I pass it as an attachment
}

For a small file, the MCP schema also accepts base64 content, but that means the file content goes through the tool call, so I’d avoid it for large files:

{
  "filename": "small.pdf",
  "content": "JVBERi0xLjQK..."
}

I don’t see a path/filePath option in the current AgentMail MCP server, so attachments: [{ "filename": "/local/path/file.zip" }] won’t make it read/send that local file by path. The attachment needs either url or base64 content.

outer ember
main kiteBOT
# outer ember I have a standing order, how can I adjust it to use this method https://cl1p.net...

I can read that standing order. The key change is: don’t tell the agent to read the large local file. Have the Lobster pipeline produce either a hosted/presigned URL, or a small text file containing that URL, then pass that URL into AgentMail’s attachments.

I’d adjust the standing order like this:

## Standing order: Email SQL leads

When I say "Email the leads file to me", "send me the leads email", or similar, execute this workflow without rediscovering the process.

### 1. Run the Lobster pipeline

Call the OpenClaw tool named `lobster` directly.
Use this exact payload:
{
  "action": "run",
  "pipeline": "/home/admin/.openclaw/workspace-dba-scout/sql-leads-draft.lobster",
main kiteBOT
# outer ember I have a standing order, how can I adjust it to use this method https://cl1p.net...
  "timeoutMs": 600000,
  "maxStdoutBytes": 512000
}

If the lobster tool fails:
- report the exact lobster tool error
- do not work around the failure with shell
- do not use the standalone Lobster CLI
- do not continue to email delivery

### 2. Read only the small generated email metadata files

If Lobster succeeds, read:
- subject from `/home/admin/.openclaw/workspace-dba-scout/sql-leads-draft-subject.txt`
- HTML body from `/home/admin/.openclaw/workspace-dba-scout/sql-leads-draft-output.html`
main kiteBOT
# outer ember I have a standing order, how can I adjust it to use this method https://cl1p.net...
- attachment URL from `/home/admin/.openclaw/workspace-dba-scout/sql-leads-attachment-url.txt`

The HTML file contents must be used as the email body.
Do not send the HTML file as an attachment.
Do not read the large leads attachment file into context.
Do not base64 encode the large leads attachment.
Use the attachment URL as the AgentMail attachment `url`.

### 3. Send the email

Send the email via the configured AgentMail MCP setup using `send_message`.

Use this attachment shape:
{
  "filename": "sql-leads.csv",
main kiteBOT
main kiteBOT
# outer ember I have a standing order, how can I adjust it to use this method https://cl1p.net...
}

### 4. Progress reporting

On success, reply exactly:

Pipeline succeeded and email sent.

On AgentMail failure, report the exact AgentMail error.

The missing piece is that your Lobster pipeline needs to create sql-leads-attachment-url.txt with a URL AgentMail can fetch. If it only creates /home/admin/.../big-file.csv, AgentMail MCP currently has no filePath field to attach that directly by local path, so the agent will keep being tempted to read/base64 it.

outer ember
#

That didn't work as it was trying to look for sql_leads.csv, which is incorrect. It should reference sql-leads-draft-subject.txt and sql-leads-draft-output.html files only

main kiteBOT
# outer ember That didn't work as it was trying to look for sql_leads.csv, which is incorrect....

Right, then remove the attachment step entirely. My previous example added a placeholder sql-leads.csv, which is wrong for your workflow.

Use this adjusted standing order section instead:

### 2. Read the generated email files

If Lobster succeeds, read only:
- subject from `/home/admin/.openclaw/workspace-dba-scout/sql-leads-draft-subject.txt`
- HTML body from `/home/admin/.openclaw/workspace-dba-scout/sql-leads-draft-output.html`

The HTML file contents must be used as the email body.
Do not send the HTML file as an attachment.
Do not look for, read, attach, or infer any CSV/leads attachment file.
Do not use `attachments` in the AgentMail MCP call.
main kiteBOT
main kiteBOT
outer ember
#

it's still trying to reads the contents, which is not workable. Is it possible to recode the MCP to take file names?

main kiteBOT
# outer ember it's still trying to reads the contents, which is not workable. Is it possible t...

Yes. That’s probably the right fix if the generated HTML is too large for prompt context.

The important distinction: don’t make the agent read sql-leads-draft-output.html. Add a custom MCP tool that accepts file paths, and let the MCP server read those files inside the tool implementation, then call AgentMail directly.

Something like this tool shape:

{
  "inboxId": "...",
  "to": ["you@example.com"],
  "subjectFile": "/home/admin/.openclaw/workspace-dba-scout/sql-leads-draft-subject.txt",
  "htmlFile": "/home/admin/.openclaw/workspace-dba-scout/sql-leads-draft-output.html"
}

Then inside the MCP server code:

main kiteBOT
main kiteBOT
# outer ember it's still trying to reads the contents, which is not workable. Is it possible t...
function safePath(file: string) {
  const resolved = path.resolve(file);
  if (!resolved.startsWith(ROOT + path.sep)) {
    throw new Error("file path outside allowed directory");
  }
  return resolved;
}

Then your standing order becomes much simpler: run Lobster, then call your custom MCP tool with subjectFile and htmlFile. No read tool, no copying HTML into context, no attachments.

Upstream AgentMail MCP currently exposes send_message with subject/html strings and attachment content/url; I don’t see native subjectFile or htmlFile parameters. So this would be either a fork of agentmail-mcp or a small local MCP wrapper just for your “send generated email from files” workflow.

outer ember
#

Can you give me a prompt to ask openclaw to recode it

main kiteBOT
# outer ember Can you give me a prompt to ask openclaw to recode it

Yep. Use a prompt like this with your local coding agent/OpenClaw session:

Please modify my local AgentMail MCP setup so it can send an email body from files without loading those file contents into the model prompt/context.

Goal:
Add a new MCP tool, preferably named send_message_from_files, that accepts:
- inboxId: string
- to: string[]
- cc?: string[]
- bcc?: string[]
- subjectFile: string
- htmlFile: string
- labels?: string[]

Behavior:
main kiteBOT
# outer ember Can you give me a prompt to ask openclaw to recode it
1. The tool implementation should read subjectFile and htmlFile inside the MCP server process using fs.readFile.
2. It should call AgentMail with:
   - subject = contents of subjectFile, trimmed only for trailing whitespace/newlines if appropriate
   - html = contents of htmlFile exactly as the email body
3. It must not expose the file contents in the MCP tool result.
4. It must not require the agent to call a read tool on either file.
5. It must not use attachments for this workflow.

Security:
- Only allow files under /home/admin/.openclaw/workspace-dba-scout
- Resolve paths with path.resolve before checking.
- Reject paths outside that directory.
- Reject symlinks if practical, or use realpath checks so symlinks cannot escape the allowed directory.
- Return a clear error if either file is missing or outside the allowed directory.
main kiteBOT
# outer ember Can you give me a prompt to ask openclaw to recode it
Standing-order target files:
- subjectFile: /home/admin/.openclaw/workspace-dba-scout/sql-leads-draft-subject.txt
- htmlFile: /home/admin/.openclaw/workspace-dba-scout/sql-leads-draft-output.html

Please update the MCP server code, show the files changed, and include the exact config/command I should use to run the modified MCP server instead of the stock agentmail-mcp package.

Then update your standing order to say: after Lobster succeeds, call send_message_from_files with those two file paths. It should explicitly say: “Do not read sql-leads-draft-subject.txt or sql-leads-draft-output.html with any read/file tool; pass their paths to send_message_from_files.”

outer ember
#

ok, that seems to have worked so what is the change to the standing order

main kiteBOT
# outer ember ok, that seems to have worked so what is the change to the standing order

Replace sections 2 and 3 with this:

### 2. Do not read the generated email files

If Lobster succeeds, do not read these files with any read/file tool:
- `/home/admin/.openclaw/workspace-dba-scout/sql-leads-draft-subject.txt`
- `/home/admin/.openclaw/workspace-dba-scout/sql-leads-draft-output.html`

Do not load their contents into prompt context.
Do not summarize, inspect, base64 encode, or attach either file.

### 3. Send the email from files

Send the email via the configured AgentMail MCP setup using the custom tool `send_message_from_files`.
main kiteBOT
# outer ember ok, that seems to have worked so what is the change to the standing order
Call `send_message_from_files` with:
{
  "inboxId": "...",
  "to": ["..."],
  "subjectFile": "/home/admin/.openclaw/workspace-dba-scout/sql-leads-draft-subject.txt",
  "htmlFile": "/home/admin/.openclaw/workspace-dba-scout/sql-leads-draft-output.html"
}

The MCP tool must read the files internally and send:
- subject from `subjectFile`
- HTML body from `htmlFile`

Do not use the stock AgentMail `send_message` tool for this workflow.
Do not include an `attachments` field.
main kiteBOT
outer ember
#

all working

main kiteBOT
# outer ember all working

Nice, glad that landed.

If this fixed it, please right-click the solution message → Apps → ✅ Mark Solution. That helps Answer Overflow index the path for the next person who hits large AgentMail MCP files.