Skip to main content
Glama
seandkendall

productivity-mcp

by seandkendall

bulk_delete_emails

Remove many emails at once by specifying message IDs – expunges IMAP and moves Gmail to Trash.

Instructions

Delete many emails in one call. IMAP expunges; Gmail moves to Trash. Rate-limited.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
message_idsYes
accountNo
folderNoINBOX

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for bulk_delete_emails. Decorated with @mcp.tool() and @_logged (which applies rate-limiting). Iterates over message_ids calling provider.delete_message() on each, returning counts of successes and failures.
    @mcp.tool()
    @_logged
    def bulk_delete_emails(
        message_ids: list[str],
        account: str | None = None,
        folder: str = "INBOX",
    ) -> dict[str, Any]:
        """Delete many emails in one call. IMAP expunges; Gmail moves to Trash.
        Rate-limited."""
        provider = _email(account)
        ok, failed = 0, 0
        errors: list[str] = []
        for mid in message_ids:
            try:
                provider.delete_message(mid, folder=folder)
                ok += 1
            except Exception as exc:
                failed += 1
                if len(errors) < 5:
                    errors.append(f"{mid}: {exc}")
        return {"ok": ok, "failed": failed, "errors": errors}
  • Registration via @mcp.tool() decorator on FastMCP instance.
    @mcp.tool()
    @_logged
    def bulk_delete_emails(
  • Rate-limit configuration: 10 calls per 60-second window for bulk_delete_emails.
        "bulk_delete_emails": (10, 60.0),
        "bulk_move_emails": (10, 60.0),
        "create_event": (30, 60.0),
        "update_event": (30, 60.0),
    }
    
    
    class RateLimiter:
        def __init__(self, limits: dict[str, tuple[int, float]] | None = None) -> None:
            self._limits = dict(_DEFAULT_LIMITS)
            if limits:
                self._limits.update(limits)
            self._hits: dict[str, deque[float]] = {}
            self._lock = threading.Lock()
    
        def check(self, tool: str) -> None:
            limit = self._limits.get(tool)
            if limit is None:
                return
            max_calls, window = limit
            now = time.time()
            with self._lock:
                bucket = self._hits.setdefault(tool, deque())
                cutoff = now - window
                while bucket and bucket[0] < cutoff:
                    bucket.popleft()
                if len(bucket) >= max_calls:
                    wait = window - (now - bucket[0])
                    raise RuntimeError(
                        f"Rate limit exceeded for '{tool}': {max_calls} calls per "
                        f"{int(window)}s. Retry in {int(wait) + 1}s."
                    )
                bucket.append(now)
    
    
    limiter = RateLimiter()
  • Gmail implementation of delete_message — moves message to Trash (recoverable) via Gmail API.
    def delete_message(self, message_id: str, folder: str = "INBOX") -> None:
        # Move to Trash (recoverable). Use `delete` for permanent removal.
        self._svc().users().messages().trash(userId="me", id=message_id).execute()
  • IMAP implementation of delete_message — marks message as \Deleted and expunges immediately.
    def delete_message(self, message_id: str, folder: str = "INBOX") -> None:
        with self._lock:
            conn = self._select(folder, readonly=False)
            conn.uid("STORE", message_id, "+FLAGS", "(\\Deleted)")
            conn.expunge()
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, the description carries the burden. It discloses provider-specific actions (IMAP expunges, Gmail trash) and mentions rate-limiting. It could be clearer on permanence (IMAP expunge irreversible) but covers key behavioral traits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with two sentences, front-loading the primary purpose, and includes necessary behavioral details without extra words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given complexity (bulk delete with provider differences), the description covers the main behavior and rate limits. An output schema exists but isn't referenced; still, the description provides sufficient context for an agent to decide when to invoke.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, meaning no parameter descriptions exist in the schema, but the description also fails to explain any parameters (message_ids, account, folder). It adds no meaning beyond the schema field titles and defaults.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool deletes many emails in one call, distinguishing it from the sibling 'delete_email' (singular). The verb 'Delete' and resource 'emails' are explicit, and it specifies behavior per provider (IMAP expunges, Gmail moves to Trash).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description indicates usage for batch deletion and notes provider-specific behaviors, giving context for when to use. However, it does not explicitly mention when not to use (e.g., for single email deletion) or provide alternative tool names.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/seandkendall/productivity-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server