LOLServ - Gmail AI MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@LOLServ - Gmail AI MCP ServerAnalyze my latest email from the boss about the deadline"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
LOLServ - Gmail AI MCP Server
A modern Model Context Protocol (MCP) server that provides AI-powered Gmail tools for email analysis, summarization, drafting replies, and rewriting content. Built with the latest MCP SDK patterns and full type safety.
Features
Email Analysis: Comprehensive email analysis with sentiment, tone, priority, and category detection
Email Summarization: Convert long emails into concise bullet points
Reply Drafting: Generate contextual email replies with customizable tone
Content Rewriting: Improve and modify email drafts based on instructions
Modern MCP: Built with
McpServerandregisterToolfor clean, maintainable codeMCP Tool Hints: Proper
readOnlyHintandidempotentHintannotations for better client integrationTool Debugging: Built-in debugging hints showing which MCP tools were used to generate responses
Modular Architecture: Each tool in its own file for better organization and maintainability
Type Safety: Full Zod validation and TypeScript integration
Runtime Validation: Comprehensive input/output validation with detailed error messages
Enterprise Ready: Production-grade error handling and fallback mechanisms
Related MCP server: Gmail MCP Server
Quick Start
Install dependencies:
npm installSet up environment variables: Create a
.envfile with your OpenAI API key:OPENAI_API_KEY=your_openai_api_key_here OPENAI_MODEL=gpt-3.5-turbo # Optional: gpt-4o-mini, gpt-4, etc.Start the MCP server:
# Stdio mode (default - for MCP clients like Claude Desktop) npm run mcp # HTTP mode (for web access and testing) npm run http # Streaming HTTP mode (for real-time streaming with MCP clients) npm run streaming-http # Production mode npm run build npm start
MCP Tools
The server exposes the following MCP tools with full type safety, validation, and MCP tool hints for better client integration:
intelligent_chat
AI-powered conversational assistant that can help with email tasks and suggest actions.
MCP Hints:
readOnlyHint: false- Can suggest actions and operationsidempotentHint: false- Different responses for same input based on context
Parameters:
message(string, required): The user's message or questionconversationHistory(array, optional): Previous messages in the conversationrole(string): "user", "assistant", or "system"content(string): Message contenttimestamp(string): When the message was sent
currentContext(object, optional): Current email contextselectedEmailId(string): Currently selected email IDthreadEmails(array): All emails in the current threadid(string): Email IDsubject(string): Email subjectsender(string): Sender email addresstime(string): Email timestampbody(string): Email body contentmessageIndex(number): Position in thread (0-based)
availableEmails(array): List of available emailsuserEmail(string): User's email address
Returns:
content(array): MCP content array with structured responsetype: "text"text: JSON string containing:response: The AI's conversational responsesuggestedActions: Array of actions the user might want to take (optional)shouldPerformAction: Boolean indicating if an action should be auto-performed (optional)actionToPerform: Specific action to perform if auto-execution is enabled (optional)
Example Response:
{
"response": "I can help you draft a reply to that email!",
"suggestedActions": [
{
"action": "draftReply",
"description": "Draft a professional reply to the email",
"parameters": {
"emailContent": "Hi, can we reschedule our meeting for next week?",
"tone": "professional"
}
}
]
}analyzeEmail
Comprehensive email analysis with structured insights.
MCP Hints:
readOnlyHint: true- Only reads and analyzes content without making changesidempotentHint: true- Multiple calls with same input produce same results
Parameters:
emailContent(string or object, required): Email contentSimple usage: Pass as string for basic analysis
Full usage: Pass as object with complete email structure:
subject(string, required): Email subject linesender(string, required): Sender email address (validated)recipients(object, optional): Recipient informationto(array of emails, default: []): To recipientscc(array of emails, default: []): CC recipientsbcc(array of emails, default: []): BCC recipients
body(string, required): Plain text email bodybodyHtml(string, optional): HTML email body
HTTP API Usage:
emailContent(string): The email text to analyzesubject(string, optional): Email subject (defaults to "No Subject")sender(string, optional): Sender email (defaults to "unknown@example.com")bodyHtml(string, optional): HTML version of email body
Returns:
content(array): MCP content array with structured analysistype: "text"text: JSON string containing:summary: Email summarymainPoints: Array of key pointssuggestedActions: Array of suggested actionspriority: "low" | "medium" | "high"category: "work" | "personal" | "marketing" | "notification" | "other"sentiment: "positive" | "neutral" | "negative"tone: "professional" | "casual" | "formal" | "urgent" | "friendly" | "polite" | "aggressive" | "apologetic" | "neutral"
summarizeEmail
Convert long emails into concise bullet points.
MCP Hints:
readOnlyHint: true- Only reads and analyzes content without making changesidempotentHint: true- Multiple calls with same input produce same results
Parameters:
text(string, required): Email content to summarize (min 1 character)
Returns:
content(array): MCP content array with summarytype: "text"text: Bullet point summary
draftReply
Generate contextual email replies with customizable tone.
MCP Hints:
readOnlyHint: true- Generates draft content but doesn't send or modify emailsidempotentHint: false- Multiple calls may produce different drafts due to AI generation
Parameters:
email(string, required): Original email content (min 1 character)tone(string, optional): Reply tone (default: "polite")
Returns:
content(array): MCP content array with generated replytype: "text"text: Generated reply content
rewriteReply
Rewrite email drafts according to specific instructions.
MCP Hints:
readOnlyHint: true- Modifies draft content but doesn't send or permanently change emailsidempotentHint: false- Multiple calls may produce different rewrites due to AI generation
Parameters:
draft(string, required): Original email draft (min 1 character)instruction(string, required): Rewrite instructions (min 1 character)
Returns:
content(array): MCP content array with rewritten emailtype: "text"text: Rewritten email content
Supported Email Formats
The server accepts various email address formats commonly used in email systems:
✅ Simple Format: paul@dserv.io
✅ RFC 5322 Format: Paul Wilkinson <paul@dserv.io>
✅ Quoted Format: "Paul Wilkinson" <paul@dserv.io>
✅ Multiple Recipients: Paul Wilkinson <paul@dserv.io>, Jane Doe <jane@example.com>
✅ Mixed Formats: paul@dserv.io, "Jane Smith" <jane.smith@company.com>
All email fields (sender, recipients.to, recipients.cc, recipients.bcc) support these formats.
Usage with MCP Clients
Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"gmail-ai": {
"command": "npx",
"args": ["tsx", "/path/to/lolserv/src/mcpServer.ts"],
"env": {
"OPENAI_API_KEY": "your-api-key-here"
}
}
}
}HTTP Mode
For web access and testing, start the server in HTTP mode:
npm run httpThen visit:
Server Status: http://localhost:4000/
MCP Endpoint: http://localhost:4000/mcp
Streaming HTTP Mode
For real-time streaming with MCP clients that support streaming HTTP transport:
npm run streaming-httpThis mode uses the StreamableHTTPServerTransport for efficient, real-time communication:
MCP Endpoint: http://localhost:4000/mcp
Transport: Streamable HTTP (supports streaming responses)
Benefits: Lower latency, real-time updates, better performance for long-running operations
Other MCP Clients
The server supports multiple transport modes:
# Stdio mode (default)
npx tsx src/mcpServer.ts
# HTTP mode
MCP_MODE=http npx tsx src/mcpServer.ts
# Streaming HTTP mode
MCP_MODE=streaming-http npx tsx src/mcpServer.tsEnvironment Variables
Configure the server behavior using environment variables:
# Server mode (stdio, http, streaming-http)
MCP_MODE=streaming-http
# Server port (for HTTP modes)
PORT=4000
# OpenAI configuration
OPENAI_API_KEY=your-api-key-here
OPENAI_MODEL=gpt-3.5-turboTesting
Run the test suite:
npm testThe test suite includes:
Server status endpoint validation
HTTP server connectivity checks
Tool availability verification
MCP protocol initialization testing
MCP tool discovery testing
Adding New Tools
The modular architecture makes it easy to add new tools:
Create a new tool file in
src/tools/:// src/tools/myNewTool.ts import { z } from "zod"; import { callLLM } from "../llm.js"; export const myNewTool = { name: "myNewTool", title: "My New Tool", description: "Description of what this tool does", inputSchema: { input: z.string().min(1, "Input is required"), }, annotations: { readOnlyHint: true, // Set to true if tool only reads data idempotentHint: true, // Set to true if same input produces same output }, handler: async ({ input }: { input: string }) => { // Tool implementation const result = await callLLM(`Process: ${input}`); return { content: [{ type: "text" as const, text: result }], }; }, };Export the tool in
src/tools/mcpServer.ts:export { myNewTool } from "./myNewTool.js";Register the tool in
src/mcpServer.ts:server.registerTool( myNewTool.name, { title: myNewTool.title, description: myNewTool.description, inputSchema: myNewTool.inputSchema, annotations: myNewTool.annotations, }, myNewTool.handler );
Development
TypeScript: Full TypeScript support with strict type checking
ES Modules: Modern ES module syntax
Zod Validation: Runtime type validation with detailed error messages
Modern MCP: Built with latest MCP SDK patterns (
McpServer,registerTool)Modular Design: Clean separation of concerns with individual tool files
Error Handling: Comprehensive error handling and logging
Environment Variables: Secure configuration management
Development Commands
# Start development server (stdio mode)
npm run mcp
# Start development server (HTTP mode)
npm run http
# Start development server (Streaming HTTP mode)
npm run streaming-http
# Build for production
npm run build
# Start production server
npm start
# Run tests
npm testProject Structure
src/
├── mcpServer.ts # Main MCP server entry point
├── mcpClient.ts # MCP client for testing and development
├── llm.ts # OpenAI client configuration
├── schemas.ts # Zod schemas for type validation
└── tools/ # Individual tool implementations
├── mcpClient.ts # Tool exports
├── summarizeEmail.ts
├── draftReply.ts
├── rewriteReply.ts
└── analyzeEmail.tsArchitecture
The server uses a modern, modular architecture:
Modular Design: Each tool is in its own file for better organization and maintainability
Modern MCP: Uses
McpServerandregisterToolpatterns for clean tool registrationZod Integration: Full runtime validation using Zod schemas defined in
schemas.tsType Safety: TypeScript types are inferred from Zod schemas for compile-time safety
MCP Compliance: Full Model Context Protocol compliance with proper content formatting
MCP Tool Hints
This server uses MCP tool hints to provide better client integration and tool behavior understanding:
Available Hints
readOnlyHint: Indicates whether the tool only reads data without making changesidempotentHint: Indicates whether multiple calls with the same input produce the same resultdestructiveHint: Indicates whether the tool can cause destructive operations (not used in this server)openWorldHint: Indicates whether the tool can access external data (not used in this server)
Tool Hint Usage
Analysis Tools (
analyzeEmail,summarizeEmail):readOnlyHint: true,idempotentHint: trueGeneration Tools (
draftReply,rewriteReply):readOnlyHint: true,idempotentHint: false
These hints help MCP clients make better decisions about tool usage, caching, and user experience.
Type Safety & Validation
This server implements enterprise-grade type safety:
Zod Schemas
Input Validation: All tool inputs are validated against Zod schemas
Output Validation: Tool outputs are validated to ensure consistency
Email Validation: Proper email address format validation
Enum Validation: Strict validation for priority, category, sentiment, and tone values
Error Handling
Detailed Error Messages: Zod provides specific validation error messages
Graceful Fallbacks: Fallback analysis when AI responses fail to parse
Runtime Safety: Prevents runtime errors from invalid data
Example Validation
// Input validation with detailed error messages
const validatedInput = SummarizeEmailInputSchema.parse({ text });
// Throws: "Email text is required" if text is empty
// Email validation
const emailSchema = z.string().email("Invalid sender email address");
// Throws: "Invalid sender email address" for malformed emailsOpenAI API Quota Management
Increasing Your Quota
Add Payment Method: Go to OpenAI Platform → Settings → Billing
Check Usage: Visit Usage Dashboard to see current limits
Upgrade Plan: Free tier has limited credits; paid plans offer higher quotas
Cost-Effective Models
gpt-3.5-turbo: Cheapest option, good for most tasksgpt-4o-mini: Balanced cost/performancegpt-4: Most capable but expensive
Requirements
Node.js 18+
OpenAI API key
TypeScript (for development)
License
ISC
Debugging Tool Usage
The server now includes built-in debugging information to help you understand which MCP tools were used to generate responses. This is particularly useful for:
Development: Understanding tool execution flow
Debugging: Identifying which tools were called and their success/failure status
Optimization: Monitoring tool usage patterns
Troubleshooting: Seeing detailed error information when tools fail
Debugging Information Structure
Each response includes:
toolsUsed: Array of tools executed with timestamps and success statusdebuggingInfo: Summary with tool count, names, and execution status
Example
{
"success": true,
"response": "I've analyzed and summarized your email.",
"toolsUsed": [
{
"name": "analyzeEmail",
"arguments": { "emailContent": {...} },
"timestamp": "2024-01-15T10:30:45.123Z",
"success": true
}
],
"debuggingInfo": {
"toolsExecuted": 1,
"toolsList": ["analyzeEmail"],
"executionSummary": "analyzeEmail ✅"
}
}See DEBUGGING-EXAMPLE.md for detailed examples and testing instructions.
Contributing
Fork the repository
Create a feature branch
Add your new tool following the modular pattern
Add tests for your tool
Submit a pull request
Support
For issues and questions:
Check the MCP Documentation
Review the tool examples in
src/tools/Ensure your OpenAI API key is properly configured
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/ohthepain/lolserv'
If you have feedback or need assistance with the MCP directory API, please join our Discord server