Skip to main content
Glama

gmail_mark_as_unread_by_ids

Mark specific Gmail emails as unread using their message IDs. Requires confirmation to execute the action.

Instructions

Mark specific emails as unread using their message IDs. Requires confirmation to execute.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
message_idsYesComma-separated list of Gmail message IDs to mark as unread.
confirmYesMust be true to actually mark as unread. Set false to preview.

Implementation Reference

  • Handler function that processes the 'gmail_mark_as_unread_by_ids' tool call, parses arguments, handles confirmation preview, and delegates to GmailClient.mark_as_unread
    elif name == "gmail_mark_as_unread_by_ids":
        message_ids_str = arguments.get("message_ids", "")
        confirm = arguments.get("confirm", False)
        
        if not message_ids_str:
            return [TextContent(type="text", text="Error: message_ids is required.")]
        
        # Parse comma-separated IDs
        message_ids = [mid.strip() for mid in message_ids_str.split(",") if mid.strip()]
        
        if not message_ids:
            return [TextContent(type="text", text="Error: No valid message IDs provided.")]
        
        if not confirm:
            return [TextContent(
                type="text",
                text=f"Preview: {len(message_ids)} email(s) would be marked as unread. Set confirm=true to proceed."
            )]
        
        result = await client.mark_as_unread(message_ids)
        return [TextContent(
            type="text",
            text=f"Success: Marked {result['success']} email(s) as unread."
            + (f" Errors: {result['errors']}" if result['errors'] else "")
        )]
  • Tool schema and registration definition for 'gmail_mark_as_unread_by_ids', including input parameters and descriptions
    Tool(
        name="gmail_mark_as_unread_by_ids",
        description="Mark specific emails as unread using their message IDs. Requires confirmation to execute.",
        inputSchema={
            "type": "object",
            "properties": {
                "message_ids": {
                    "type": "string",
                    "description": "Comma-separated list of Gmail message IDs to mark as unread."
                },
                "confirm": {
                    "type": "boolean",
                    "description": "Must be true to actually mark as unread. Set false to preview."
                }
            },
            "required": ["message_ids", "confirm"]
        },
  • Core helper method in GmailClient that performs the batch modification to add UNREAD label to specified message IDs using Gmail API
    async def mark_as_unread(self, message_ids: list[str]) -> dict:
        """Mark one or more emails as unread by adding the UNREAD label.
        
        Args:
            message_ids: List of Gmail message IDs to mark as unread
            
        Returns:
            Dict with success count and any errors
        """
        if not message_ids:
            return {"success": 0, "errors": [], "message": "No message IDs provided"}
        
        results = {"success": 0, "errors": []}
        
        try:
            # Use batchModify for efficiency (up to 1000 at a time)
            if len(message_ids) <= 1000:
                self.service.users().messages().batchModify(
                    userId="me",
                    body={
                        "ids": message_ids,
                        "addLabelIds": ["UNREAD"]
                    }
                ).execute()
                results["success"] = len(message_ids)
            else:
                # Process in batches of 1000
                for i in range(0, len(message_ids), 1000):
                    batch = message_ids[i:i+1000]
                    self.service.users().messages().batchModify(
                        userId="me",
                        body={
                            "ids": batch,
                            "addLabelIds": ["UNREAD"]
                        }
                    ).execute()
                    results["success"] += len(batch)
                    
        except HttpError as e:
            logger.error(f"Failed to mark emails as unread: {e}")
            results["errors"].append(str(e))
            
        return results
Behavior3/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 adds value by stating the confirmation requirement, which hints at a safety mechanism, but lacks details on permissions, rate limits, or what happens if IDs are invalid. It doesn't contradict annotations, but more behavioral context would be helpful for a mutation tool.

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 front-loaded with the core purpose in the first sentence and adds a crucial behavioral note in the second. Both sentences earn their place by providing essential information without redundancy, making it efficient and well-structured.

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

Completeness3/5

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

Given the tool's complexity (a mutation operation with 2 required parameters) and no annotations or output schema, the description is adequate but has gaps. It covers the action and a key behavioral trait (confirmation), but lacks details on error handling, return values, or integration with sibling tools, which could improve completeness.

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?

Schema description coverage is 100%, so the input schema fully documents both parameters (message_ids and confirm). The description doesn't add any additional meaning beyond what the schema provides, such as format examples or edge cases. Baseline 3 is appropriate as the schema handles the heavy lifting.

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 specific action ('Mark specific emails as unread') and the resource ('using their message IDs'), distinguishing it from siblings like gmail_mark_as_unread_by_query which uses queries instead of IDs. The verb+resource combination is precise and unambiguous.

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 provides clear context by specifying 'Requires confirmation to execute,' which indicates a prerequisite for use. However, it doesn't explicitly differentiate when to use this tool versus alternatives like gmail_mark_as_unread_by_query or gmail_mark_as_read_by_ids, leaving some ambiguity in sibling tool selection.

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/murphy360/mcp_gmail'

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