Skip to main content
Glama

get-email-content

Retrieve complete email content using the email ID. This tool enables users to access and read full email messages from Gmail and other providers through ClaudePost's email management system.

Instructions

Get the full content of a specific email by its ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
email_idYesThe ID of the email to retrieve

Implementation Reference

  • Dispatches the 'get-email-content' tool call: validates email_id, fetches content asynchronously, handles timeout, and returns formatted text content.
    elif name == "get-email-content":
        email_id = arguments.get("email_id")
        if not email_id:
            return [types.TextContent(
                type="text",
                text="Email ID is required."
            )]
        
        try:
            async with asyncio.timeout(SEARCH_TIMEOUT):
                email_content = await get_email_content_async(mail, email_id)
                
            result_text = (
                f"From: {email_content['from']}\n"
                f"To: {email_content['to']}\n"
                f"Date: {email_content['date']}\n"
                f"Subject: {email_content['subject']}\n"
                f"\nContent:\n{email_content['content']}"
            )
            
            return [types.TextContent(
                type="text",
                text=result_text
            )]
            
        except asyncio.TimeoutError:
            return [types.TextContent(
                type="text",
                text="Operation timed out while fetching email content."
            )]
  • Registers the 'get-email-content' tool with the MCP server, defining its name, description, and JSON schema requiring 'email_id'.
    types.Tool(
        name="get-email-content",
        description="Get the full content of a specific email by its ID",
        inputSchema={
            "type": "object",
            "properties": {
                "email_id": {
                    "type": "string",
                    "description": "The ID of the email to retrieve",
                },
            },
            "required": ["email_id"],
        },
    ),
  • Asynchronous helper function that fetches the raw email message data using IMAP and delegates formatting to format_email_content.
    async def get_email_content_async(mail: imaplib.IMAP4_SSL, email_id: str) -> dict:
        """Asynchronously get full content of a specific email."""
        loop = asyncio.get_event_loop()
        try:
            _, msg_data = await loop.run_in_executor(None, lambda: mail.fetch(email_id, '(RFC822)'))
            return format_email_content(msg_data)
        except Exception as e:
            raise Exception(f"Error fetching email content: {str(e)}")
  • Helper function to parse raw email bytes into a structured dictionary, extracting headers and preferring plain text body or falling back to HTML.
    def format_email_content(msg_data: tuple) -> dict:
        """Format an email message into a dict with full content."""
        email_body = email.message_from_bytes(msg_data[0][1])
        
        # Extract body content
        body = ""
        if email_body.is_multipart():
            # Handle multipart messages
            for part in email_body.walk():
                if part.get_content_type() == "text/plain":
                    body = part.get_payload(decode=True).decode()
                    break
                elif part.get_content_type() == "text/html":
                    # If no plain text found, use HTML content
                    if not body:
                        body = part.get_payload(decode=True).decode()
        else:
            # Handle non-multipart messages
            body = email_body.get_payload(decode=True).decode()
        
        return {
            "from": email_body.get("From", "Unknown"),
            "to": email_body.get("To", "Unknown"),
            "date": email_body.get("Date", "Unknown"),
            "subject": email_body.get("Subject", "No Subject"),
            "content": body
        }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action 'Get', implying a read operation, but doesn't mention permissions, rate limits, error handling, or what 'full content' includes (e.g., attachments, headers). This leaves significant gaps for a tool with no structured safety hints.

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 a single, clear sentence with no wasted words. It's front-loaded with the core action and resource, making it highly efficient and easy to parse, which is ideal for conciseness.

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

Completeness2/5

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

Given the complexity of retrieving email content, no annotations, and no output schema, the description is insufficient. It doesn't explain return values, error cases, or behavioral traits like authentication needs, making it incomplete for effective tool use in this context.

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

Parameters3/5

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

The schema description coverage is 100%, with the parameter 'email_id' fully documented in the schema. The description adds no additional meaning beyond implying retrieval by ID, so it meets the baseline of 3 where the schema does the heavy lifting without extra value from the description.

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

Purpose4/5

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

The description clearly states the verb 'Get' and the resource 'full content of a specific email', making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'search-emails' or 'count-daily-emails', which might also retrieve email content in different contexts, so it misses the highest score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'search-emails' or 'send-email'. It mentions retrieving by 'specific email ID', but doesn't clarify scenarios where this is preferred over searching or other methods, leaving usage ambiguous.

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/meyannis/mcpemail'

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