openclaw - 💡(How to fix) Fix [Feature]: Improve MCP server tool discoverability and search precision for email agents [1 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#70880Fetched 2026-04-24 10:38:22
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

MCP server tools have generic descriptions that make it hard for LLM agents to select the right tool and use it effectively. Key issues: duplicate search_emails vs search_all_emails, no way to filter by account/folder/date, and raw verbose JSON responses that overwhelm context windows.

Root Cause

MCP server tools have generic descriptions that make it hard for LLM agents to select the right tool and use it effectively. Key issues: duplicate search_emails vs search_all_emails, no way to filter by account/folder/date, and raw verbose JSON responses that overwhelm context windows.

Code Example

{
  "query": "invoice",
  "account": "[email protected]",
  "folder": "INBOX",
  "since": "2026-04-01",
  "unread_only": true,
  "limit": 10
}

---

{
  "from": "[email protected]",
  "subject": "Invoice #1234",
  "date": "2026-04-23",
  "body_text": "<first 500 chars>",
  "attachments": ["invoice.pdf"]
}
RAW_BUFFERClick to expand / collapse

Summary

MCP server tools have generic descriptions that make it hard for LLM agents to select the right tool and use it effectively. Key issues: duplicate search_emails vs search_all_emails, no way to filter by account/folder/date, and raw verbose JSON responses that overwhelm context windows.

Problem to solve

When an LLM agent connects to the OpenClaw MCP email server, it faces three problems:

  1. Tool confusion: search_emails and search_all_emails have nearly identical descriptions. The agent cannot determine which to use.

  2. No filtering: search_emails only takes a query string. The agent cannot filter by account, folder, date range, or unread status. This forces multiple round-trips and wastes tokens.

  3. Verbose responses: get_email_content returns full raw JSON (headers, body, attachments metadata). For a 50-line email, the response can be 2000+ tokens. The agent only needs the visible text.

Proposed solution

  1. Differentiate tool descriptions — Make search_emails description say "search in the currently selected account" and search_all_emails say "search across all connected accounts". Add parameter descriptions.

  2. Add search_emails_filtered — New tool with structured filters:

{
  "query": "invoice",
  "account": "[email protected]",
  "folder": "INBOX",
  "since": "2026-04-01",
  "unread_only": true,
  "limit": 10
}
  1. Add response summarization — For get_email_content, return a condensed version by default:
{
  "from": "[email protected]",
  "subject": "Invoice #1234",
  "date": "2026-04-23",
  "body_text": "<first 500 chars>",
  "attachments": ["invoice.pdf"]
}

Alternatives considered

  • Better prompts only — Works sometimes but is fragile. Different LLMs interpret vague descriptions differently.
  • Single search tool with optional params — Simpler API but breaks backward compatibility for existing users.

Impact

  • Affected: Anyone using MCP server with LLM agents (OpenClaw, Claude Code, Codex, etc.)
  • Severity: Medium — agent wastes tokens on wrong tool selection and verbose responses
  • Frequency: Every email search/get interaction
  • Consequence: Slower responses, higher token cost, occasional wrong results

Evidence

Tested with MiMo-V2-Pro and DeepSeek Reasoner. Both models consistently confused search_emails vs search_all_emails. Average email content response was 1800 tokens when 400 would suffice.

extent analysis

TL;DR

Implementing a new search_emails_filtered tool with structured filters and response summarization for get_email_content can improve LLM agent performance and reduce token waste.

Guidance

  • Differentiate tool descriptions for search_emails and search_all_emails to avoid confusion.
  • Introduce a search_emails_filtered tool with parameters like account, folder, since, and unread_only to enable efficient filtering.
  • Modify get_email_content to return a condensed response with essential information like from, subject, date, body_text, and attachments.

Example

{
  "query": "invoice",
  "account": "[email protected]",
  "folder": "INBOX",
  "since": "2026-04-01",
  "unread_only": true,
  "limit": 10
}

This example demonstrates the proposed structured filter for search_emails_filtered.

Notes

The proposed solution aims to address the specific issues mentioned, but its effectiveness may vary depending on the LLM agents and their interpretation of the new tool descriptions and parameters.

Recommendation

Apply the proposed workaround by introducing the search_emails_filtered tool and modifying get_email_content to return condensed responses, as this approach directly addresses the identified issues and provides a more efficient and effective solution for LLM agents.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING