Labsco
theposch logo

Gmail

β˜… 19

from theposch

An MCP server for Gmail, allowing AI assistants to manage emails through natural language.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeAdvanced setup

Enhanced Gmail MCP Server

A powerful and feature-rich Model Context Protocol (MCP) server for Gmail integration, written in Python. This server enables AI assistants like Claude to interact with Gmail through natural language, providing comprehensive email management capabilities.

🌟 Key Features

πŸ“§ Complete Email Management

  • Send emails with customizable subject, content, and recipients
  • Read and retrieve email content with full metadata
  • Move emails to trash with confirmation
  • Mark emails as read/unread
  • Open emails directly in browser

πŸ“ Draft Management

  • Create draft emails for later review
  • List all draft emails
  • Edit existing drafts

🏷️ Advanced Label Management

  • List all available labels
  • Create custom labels
  • Apply/remove labels from emails
  • Rename existing labels
  • Delete unused labels
  • Search emails by label

πŸ“ Folder Organization

  • Create new folders (implemented as Gmail labels)
  • Move emails between folders
  • List all available folders

πŸ” Powerful Search & Filtering

  • Search emails using Gmail's advanced query syntax
  • Create, manage, and delete email filters
  • Filter by sender, recipient, subject, content, and more
  • Customize search results with flexible parameters

πŸ—„οΈ Archive Management

  • Archive emails (remove from inbox without deleting)
  • Batch archive multiple emails matching search criteria
  • List all archived emails
  • Restore archived emails to inbox

πŸ” Security Considerations

  • Never commit credentials or token files to version control
  • Store credentials in a secure location with appropriate permissions
  • The server will request user confirmation before performing sensitive actions
  • Review Google Cloud Console regularly for unusual activity
  • Consider using environment variables for sensitive paths

πŸ› οΈ Architecture

This implementation features a comprehensive single-file architecture that handles all Gmail operations through the Google API client libraries. Key components include:

  • OAuth2 authentication with automatic token refresh
  • Comprehensive error handling and logging
  • Structured tool definitions with clear input schemas
  • Efficient email parsing and formatting

πŸ“š Example Prompts

Try these prompts with Claude after connecting the Gmail MCP server:

  • "Show me my unread emails"
  • "Search for emails from example@domain.com with attachments"
  • "Create a new label called 'Important Projects'"
  • "Draft an email to john@example.com about the upcoming meeting"
  • "Archive all emails from newsletter@example.com"
  • "Create a filter to automatically label emails from my team"

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the GPL-3.0 License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Inspired by various MCP server implementations in the community
  • Built with the Model Context Protocol framework
  • Uses Google's official API client libraries