This guide will walk you through the necessary steps to authorize the MCP application to access your Gmail account. The process is in two parts:
-
Part 1: Generating the
credentials.jsonFile. This is your application's unique ID, which you will get from the Google Cloud Console. You only need to do this once. -
Part 2: Configuring the MCP Application. You will update your configuration file with the path to your
credentials.jsonfile and specify a location for thetoken.jsonfile to be created.
After configuring, the MCP application itself will handle the final authorization step and the creation of token.json.
Prerequisites
- A Google Account (e.g., your personal
@gmail.comaccount). - Access to the JSON configuration file for your MCP application.
Follow these steps to create and download your unique application credentials from Google.
Step 1: Create a Google Cloud Project
- Navigate to the Google Cloud Console and log in.
- In the top-left corner, click the project dropdown menu (it may say "Select a project").
- Click "NEW PROJECT".
- Enter a Project name, for example, "MCP Gmail Access".
- Click "CREATE".
Step 2: Enable the Gmail API
- You must enable the Gmail API for your new project.
- Ensure your new project is selected in the top project dropdown.
- Click the navigation menu (☰) and go to APIs & Services > Library.
- In the search bar, type "Gmail API" and select it from the results.
- Click the blue "ENABLE" button and wait for the process to complete.
Step 3: Configure the OAuth Consent Screen
This screen is what you will see when you grant permission for the app to access your account.
- From the navigation menu (☰), go to APIs & Services > OAuth consent screen.
- For "User Type", select "External" and click "CREATE".
- App Information:
- App name: Enter a descriptive name like "My Local MCP Client".
- User support email: Select your email address.
- Developer contact information: Enter your email address again.
- Click "SAVE AND CONTINUE".
- Scopes: Now, specify the permissions the app will request.
- Click "ADD OR REMOVE SCOPES".
- In the filter, type "Gmail API".
- For broad access (reading, sending, managing mail), check the box for the scope:
https://www.googleapis.com/auth/gmail.modify. - Click "UPDATE".
- Click "SAVE AND CONTINUE".
- Test Users: While the app is in "testing" status, only explicitly added users can authorize it.
- Click "ADD USERS".
- Enter your own Gmail address (the one you will use with the MCP application).
- Click "ADD".
- Click "SAVE AND CONTINUE", then review the summary and click "BACK TO DASHBOARD".
Step 4: Create and Download the Credentials This is the final step to get your file.
- From the navigation menu (☰), go to APIs & Services > Credentials.
- Click "+ CREATE CREDENTIALS" at the top of the page and select "OAuth client ID".
- For Application type, choose "Desktop app" ( Note that this configuration is for it to be used with desktop client such as Claude or your preferred/custom client.).
- Give it a name, such as "MCP Desktop Credentials".
- Click "CREATE".
- A pop-up will appear. Click the "DOWNLOAD JSON" button.
- The file will be saved to your computer. It is highly recommended to rename this file to
credentials.jsonfor clarity. - Move this
credentials.jsonfile to a secure and permanent location on your computer (e.g.,C:\Apps\MCP_Configor~/Documents/MCP_Config). You will need the full path to this file in the next part.
Success! You now have the credentials.json file. Do not share it with anyone.
Now, you will tell the MCP application where to find your credentials file and where it should save the authorization token.
Step 1: Get the Full File Paths
You need to define two file paths:
GOOGLE_CREDENTIALS_FILE_PATH: This is the full path to thecredentials.jsonfile you just downloaded and saved.GOOGLE_PREFERRED_TOKEN_FILE_PATH: This is the full path where you want the MCP application to create and store thetoken.jsonfile. This file does not exist yet. It's best to place it in the same secure folder as yourcredentials.json.
Example:
-
If you saved
credentials.jsoninC:\Apps\MCP_Config, your paths would be:- Credentials Path:
C:\Apps\MCP_Config\credentials.json - Token Path:
C:\Apps\MCP_Config\token.json
- Credentials Path:
Step 2: Update Your JSON Configuration
Open the JSON configuration file for your MCP application. Locate the email_mcp section and update the env object with the file paths you determined in the previous step.
Original Configuration (Locally):
"email_mcp": {
"command": "uv",
"args": [ "--directory", "PATH\\TO\\MailNet", "run", "-m", "mcp_launcher.server" ],
"env": {
"AZURE_APPLICATION_CLIENT_ID": "",
"AZURE_CLIENT_SECRET_VALUE": "",
"AZURE_PREFERRED_TOKEN_FILE_PATH": "",
"GOOGLE_CREDENTIALS_FILE_PATH": "",
"GOOGLE_PREFERRED_TOKEN_FILE_PATH": ""
}
}
Updated Configuration Example (Windows):
Important: In JSON strings, you must escape backslashes () by using a double backslash (\\).
"email_mcp": {
"command": "uv",
"args": [ "--directory", "PATH\\TO\\MailNet", "run", "-m", "mcp_launcher.server" ],
"env": {
"AZURE_APPLICATION_CLIENT_ID": "",
"AZURE_CLIENT_SECRET_VALUE": "",
"AZURE_PREFERRED_TOKEN_FILE_PATH": "",
"GOOGLE_CREDENTIALS_FILE_PATH": "C:\\Apps\\MCP_Config\\credentials.json",
"GOOGLE_PREFERRED_TOKEN_FILE_PATH": "C:\\Apps\\MCP_Config\\token.json"
}
}
Updated Configuration Example (macOS / Linux):
Forward slashes ( / ) do not need to be escaped.
"email_mcp": {
"command": "uv",
"args": [ "--directory", "PATH/TO/MailNet", "run", "-m", "mcp_launcher.server" ],
"env": {
"AZURE_APPLICATION_CLIENT_ID": "",
"AZURE_CLIENT_SECRET_VALUE": "",
"AZURE_PREFERRED_TOKEN_FILE_PATH": "",
"GOOGLE_CREDENTIALS_FILE_PATH": "/home/user/Documents/MCP_Config/credentials.json",
"GOOGLE_PREFERRED_TOKEN_FILE_PATH": "/home/user/Documents/MCP_Config/token.json"
}
}
Step 3: Run the MCP Application and Authorize
- Save your updated JSON configuration file.
- Run the MCP application as you normally would.
- The first time you run it after this configuration, the application will:
- Read your credentials.json.
- Automatically open a new tab in your web browser.
- In the browser:
- Choose the Google Account you added as a "Test User".
- You will see a warning screen: "Google hasn’t verified this app". This is expected. Click "Advanced" and then click "Go to [your app name] (unsafe)".
- Grant the requested permissions by clicking "Allow".
- The browser tab will show a success message and can be closed.
- The MCP application will now proceed. It has successfully used your permission to create the
token.jsonfile in the location you specified.
You will not have to repeat the browser authorization step on subsequent runs, as the application will reuse the generated token.json.