Get the FREE Ultimate OpenClaw Setup Guide →

email-analyzer

Gmail inbox analytics via MCP: fetch, search, and summarize email metrics in Node.js.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio winitramesh2-email-analyzer node index.js \
  --env GMAIL_CLIENT_ID="OAuth client ID from Google Cloud Console" \
  --env GMAIL_REDIRECT_URI="OAuth redirect URI (if applicable)" \
  --env GMAIL_CLIENT_SECRET="OAuth client secret from Google Cloud Console" \
  --env GMAIL_REFRESH_TOKEN="OAuth refresh token for the Gmail account"

How to use

This MCP server is a Node.js application that connects to your Gmail account via the Model Context Protocol (MCP) to fetch and analyze your emails. It exposes a set of Gmail MCP tools that let you list messages, retrieve specific messages, search with Gmail query syntax, send messages, and create drafts. The analyzer computes metrics such as total emails, unread count, important emails, attachments, top senders, and label distribution. To use it, ensure the server is running (the app reads credentials from a .env file). Once started, you can invoke the available MCP tools through your MCP client to perform tasks like listing recent messages, performing searches, or analyzing your mailbox according to the configured parameters. You can customize how many emails to fetch and which search queries to apply by editing the main index.js and the configuration in gmail-mcp-config.json.

How to install

Prerequisites:

  • Node.js (recommended LTS) and npm installed
  • Git (optional, for cloning the repository)

Steps:

  1. Install dependencies

    • npm install
  2. Configure credentials

    • Create or populate the .env file with your Gmail OAuth credentials (client ID, client secret, refresh token, etc.).
    • Example environment values to include: GMAIL_CLIENT_ID=your-client-id GMAIL_CLIENT_SECRET=your-client-secret GMAIL_REFRESH_TOKEN=your-refresh-token GMAIL_REDIRECT_URI=your-redirect-uri
  3. Start the server

    • npm start
  4. Verify it's running

    • Access the MCP endpoint provided by your environment (check console output for the running port and endpoint).

If you need to run the server directly without npm start, you can run:

  • node index.js

Additional notes

Tips and common issues:

  • The server reads Gmail OAuth credentials from the .env file; ensure this file is secure and not committed to version control.
  • The default analysis fetches a set number of recent emails (as configured in index.js). Update the fetch limit to suit your needs.
  • Available tools under Gmail MCP include:
    • gmail_list_messages: List recent messages
    • gmail_get_message: Get a specific message by ID
    • gmail_search_messages: Search messages with Gmail query syntax
    • gmail_send_message: Send an email
    • gmail_create_draft: Create a draft email
  • If you modify index.js or related config, restart the server for changes to take effect.
  • Ensure the Gmail API scope includes read access for listing and reading messages if you intend to fetch data.
  • Check logs for authentication errors and ensure the OAuth token is valid or refreshed as needed.

Related MCP Servers

Sponsor this space

Reach thousands of developers