How to Build a Gmail Agent with Claude Code and MCP

TL;DR
A solo creator building AI micro businesses walks through connecting a Gmail agent to Claude Code using an MCP server. The setup means enabling the Gmail API in Google Cloud, adding modify, read-only, and send scopes on the consent screen, creating a desktop-app OAuth client, downloading credentials.json, and authenticating to get a token so the agent can list, read, send, and reply to email.
Transcript
Hello. Hope you are doing well. So yeah, this is week two. If you watched the last episode, you know we are doing a bit of a different thing this year. We're just going to build out all these AI micro businesses from everything we learned the last 3 years. And we're going to track everything and I'm going to share a bit here what I'm doing each wee... Read More
Key Insights
- Building an AI micro business here means everything is AI generated: the creator built an AI video course platform from scratch using Claude Code, buying nothing and generating the product with AI rather than assembling it manually.
- A single AI-generated YouTube Short can go viral fast, pulling hundreds of thousands of views within hours and gaining subscribers rapidly, showing that faceless shorts channels can produce real ad revenue when the right format hits.
- A Gmail agent can be connected to Claude Code through MCP, letting the assistant list, read, send, reply to, and search emails once the Google Cloud credentials and token are in place.
- Setting up the Gmail API starts in Google Cloud Console by creating a project, then going to APIs and Services to find and enable the Gmail API, which the creator describes as a very easy step.
- Configuring the OAuth consent screen requires adding Gmail scopes: the modify scope, the read-only scope, and the send scope, all managed through the add and remove scopes interface under data access.
- Creating OAuth credentials means going to Credentials, creating an OAuth client ID, selecting the desktop app type, naming it something like Gmail MCP server, and downloading the resulting credentials.json file into the agent folder.
- Authentication produces a token by running an auth flow that opens a link, confirms success in the browser, and writes a token.json file the MCP server needs before it can be added to Claude Code.
- Planning mode in Claude Code lets you review the agent's proposed steps, such as required scopes, credential paths, and token handling, before executing, so you validate the approach before any code runs.
Install to Summarize YouTube Videos and Get Transcripts
Explore YouTube Video Summarizer or Get YouTube Transcript Extractor
Questions & Answers
Q: How do you build a Gmail agent with Claude Code?
You build it by using an MCP server to connect Claude Code to your Gmail account. First gather the Claude Code MCP documentation and save it as a docs file, then describe the plan to Claude Code. You need a Google Cloud Console project with the Gmail API enabled, OAuth consent scopes, a downloaded credentials.json, and a token. Once the MCP server is added, the agent can list, read, send, reply to, and search emails.
Q: What Gmail scopes do you need to add on the OAuth consent screen?
The creator adds Gmail scopes for modify, read-only, and send. These are configured under the OAuth consent screen through the add and remove scopes interface in the data access section. Adding these scopes lets the agent perform the full range of email actions it needs, including reading messages, sending new emails, and replying, rather than being limited to a single narrow permission.
Q: How do you enable the Gmail API in Google Cloud Console?
You start in Google Cloud Console and create a new project if you do not already have one. Then you go to APIs and Services, open the enabled APIs and services area, find the Gmail API, click on it, and enable it. The creator describes this as a super easy step. This exposes the Gmail endpoints the MCP server will use to interact with your inbox.
Q: What type of OAuth client do you create for the Gmail MCP server?
You create an OAuth client ID of the desktop app type. In Google Cloud Console you go to APIs and Services, then Credentials, then create credentials and choose OAuth client ID. You select desktop app as the application type and give it a name such as Gmail MCP server. After creating it, you download the credentials.json file containing the client ID and secret, and place it in your email agent folder.
Q: How do you get the token needed for the Gmail MCP server?
After downloading credentials.json into the agent folder, you run an authentication step that generates a link. You open the link, complete the authorization, and see an authentication successful message. This writes a token.json file back into your project. The token is required before you can add the MCP server to Claude Code, because the server needs it to actually access the Gmail account and perform email operations.
Q: Why does the creator use Claude Code's plan mode before building?
The creator switches to plan mode so Claude Code proposes a step-by-step plan before writing any code. This lets you review the required actions, such as the list, read, send, reply, and search capabilities, the credential paths, and the token handling, and confirm everything looks correct. Reviewing the plan first reduces surprises and gives you a clear guide to follow when setting things up in Google Cloud Console afterward.
Q: What is an AI micro business as described in the video?
An AI micro business is a small venture where the product is largely AI generated rather than manually built. The creator's example is an AI video course whose platform was built from scratch using Claude Code, with nothing purchased and everything generated by AI. Faceless shorts channels that produce AI-made videos are another example. The appeal is that these are relatively easy to make with AI while still producing revenue.
Q: Can AI-generated YouTube Shorts actually get views and earn revenue?
Yes. The creator shows a newly created channel whose single AI-generated short went viral, gaining a large number of views within hours and adding many subscribers in a single day, described as his most viral video ever with an upward trend. He argues this proves such videos do produce substantial views and short ad revenue, making faceless AI shorts channels a viable and accessible micro business to get into.
Summary & Key Takeaways
-
This is week two of a series documenting the solo build-out of AI micro businesses, using lessons from prior years. The creator tracks revenue from side-hustle ventures separate from the main YouTube channel, including an AI-built video course platform and several faceless shorts channels, and built a custom tool to track monthly growth.
-
The creator shows a newly created shorts channel whose single video went viral, accumulating a large number of views within hours and gaining many subscribers in a day. This is presented as proof that AI-generated shorts can produce meaningful ad revenue and is offered as an accessible AI micro business others can try.
-
The main build is a Gmail agent using Claude Code and an MCP server. The walkthrough covers gathering MCP documentation, dictating a plan to Claude Code, enabling the Gmail API, configuring the consent screen with the needed scopes, creating desktop-app credentials, authenticating for a token, adding the server, and testing it by listing recent emails.
Read in Other Languages (beta)
Share This Summary 📚
Summarize YouTube Videos and Get Video Transcripts with 1-Click
Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator
Explore More Summaries from All About AI 📚






Summarize YouTube Videos and Get Video Transcripts with 1-Click
Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator