Configure OAuth2 for Google Workspace APIs
mainThe mcp-gsuite server requires OAuth2 authorization to interact with Gmail and Calendar APIs.
1. Google Cloud Console Setup
- Create a project in the Google Cloud Console.
- Enable the Gmail API and Google Calendar API.
- Create OAuth client ID credentials (select 'Desktop app' or 'Web application').
- Configure the OAuth consent screen.
- Add
http://localhost:4100/codeto your authorized redirect URIs.
2. Required Scopes
The following scopes must be used:
[
"openid",
"https://mail.google.com/",
"https://www.googleapis.com/auth/calendar",
"https://www.googleapis.com/auth/userinfo.email"
]3. Create Configuration Files
Create a .gauth.json file in your working directory to store client credentials:
{
"web": {
"client_id": "$your_client_id",
"client_secret": "$your_client_secret",
"redirect_uris": ["http://localhost:4100/code"],
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token"
}
}Create a .accounts.json file to define the Google accounts the server can access:
{
"accounts": [
{
"email": "alice@bob.com",
"account_type": "personal",
"extra_info": "Additional info that you want to tell Claude: E.g. 'Contains Family Calendar'"
}
]
}4. Initial Authorization
When you first execute a tool for a specific account, a browser will open for you to log in. After successful authentication, the server stores credentials in a local file named .oauth.{email}.json.