gmail_inbox_stats
Retrieve current Gmail inbox statistics including total messages, unread count, starred messages, and important messages for inbox management.
Instructions
Get current inbox statistics including total messages, unread count, starred count, and important message count.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp_gmail/server_old.py:136-144 (registration)Registers the gmail_inbox_stats tool in the MCP server with its schema (no input parameters).Tool( name="gmail_inbox_stats", description="Get current inbox statistics (unread count, starred, etc.)", inputSchema={ "type": "object", "properties": {}, }, ), Tool(
- src/mcp_gmail/server_old.py:359-366 (handler)Tool handler in call_tool() that executes get_inbox_stats() on GmailClient and returns formatted TextContent.elif name == "gmail_inbox_stats": stats = await client.get_inbox_stats() return [ TextContent( type="text", text=_format_inbox_stats(stats), ) ]
- src/mcp_gmail/gmail_client.py:337-379 (handler)Core implementation of inbox statistics retrieval using Gmail API queries for unread, starred, important, and total message counts in inbox.async def get_inbox_stats(self) -> InboxStats: """Get current inbox statistics.""" try: # Get counts unread = ( self.service.users() .messages() .list(userId="me", q="is:unread in:inbox", maxResults=1) .execute() ).get("resultSizeEstimate", 0) starred = ( self.service.users() .messages() .list(userId="me", q="is:starred", maxResults=1) .execute() ).get("resultSizeEstimate", 0) important = ( self.service.users() .messages() .list(userId="me", q="is:important is:unread", maxResults=1) .execute() ).get("resultSizeEstimate", 0) total = ( self.service.users() .messages() .list(userId="me", q="in:inbox", maxResults=1) .execute() ).get("resultSizeEstimate", 0) return InboxStats( total_messages=total, unread_count=unread, starred_count=starred, important_count=important, updated_at=datetime.now(timezone.utc), ) except HttpError as e: logger.error(f"Failed to get inbox stats: {e}") raise
- src/mcp_gmail/server_old.py:829-840 (helper)Helper function to format InboxStats model into a markdown-formatted string for tool response.def _format_inbox_stats(stats) -> str: """Format inbox stats for display.""" return f""" # 📊 Inbox Statistics - **Total Messages:** {stats.total_messages} - **Unread:** {stats.unread_count} - **Starred:** {stats.starred_count} - **Important (Unread):** {stats.important_count} _Updated: {stats.updated_at.strftime('%Y-%m-%d %H:%M:%S')}_ """