krutikkkkkkkkk/gmail-mcp-server
If you are the rightful owner of gmail-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
This project demonstrates the creation of a Gmail MCP server integrated with an AI SDK for intelligent email management.
Gmail MCP Server with AI SDK
This project demonstrates how to create a Gmail MCP (Model Context Protocol) server and integrate it with the AI SDK for intelligent email management.
Features
- MCP Server: Provides Gmail tools via Model Context Protocol
- AI SDK Integration: Uses AI to interact with Gmail through MCP tools
- Gmail Operations: Search, read, send, and delete emails
- Multiple Transport Types: Supports stdio, HTTP, and SSE transports
Setup
-
Install dependencies:
npm install -
Set up environment variables:
cp .env.example .envEdit
.envand add your API keys:OPENAI_API_KEY: Your OpenAI API key- Gmail OAuth credentials (for production use)
-
Build the project:
npm run build
Usage
Running the MCP Server
Start the Gmail MCP server:
npm run server
Running the AI Client
Run the AI client that connects to the MCP server:
npm run client
Or run with a custom message:
npm run client "Search for emails about project updates"
Development Mode
Run in development mode with hot reloading:
npm run dev
Project Structure
src/
├── server/
│ └── mcp-server.ts # Gmail MCP server implementation
├── client/
│ └── mcp-client.ts # AI SDK client with MCP integration
└── index.ts # Main entry point
MCP Tools Available
The Gmail MCP server provides these tools:
- search_emails: Search for emails by query
- get_email: Get details of a specific email
- send_email: Send a new email
- delete_email: Delete an email
Example Interactions
- "Search for emails from john@example.com"
- "Find emails about project updates and summarize them"
- "Send an email to team@company.com about the meeting"
- "Delete the email with ID 12345"
Architecture
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ AI SDK │───▶│ MCP Client │───▶│ MCP Server │
│ (OpenAI) │ │ (stdio) │ │ (Gmail) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
The AI SDK connects to the Gmail MCP server through a stdio transport, allowing the AI to use Gmail tools naturally in conversation.
Extending
To add more MCP servers:
- Create additional MCP server implementations
- Add new transports in
mcp-client.ts - Combine tools from multiple servers
License
MIT