- Explore MCP Servers
- mcp-server-with-google-auth
Mcp Server With Google Auth
What is Mcp Server With Google Auth
The mcp-server-with-google-auth is a project that implements an MCP (Model Context Protocol) server integrated with Google Drive, allowing clients to interact with it using the Gemini framework.
Use cases
Use cases include building applications that require user authentication via Google, leveraging Google Drive for file storage, and utilizing AI models for data processing and analysis.
How to use
To use mcp-server-with-google-auth, clone the repository, set up a virtual environment, install dependencies, configure Google OAuth credentials, and set environment variables as specified in the README.
Key features
Key features include integration with Google Drive, support for OAuth 2.0 authentication, a web framework built with FastAPI, and the ability to utilize Google Generative AI through the Google API client.
Where to use
This server can be used in fields such as cloud computing, AI development, and web applications that require secure authentication and interaction with Google services.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Mcp Server With Google Auth
The mcp-server-with-google-auth is a project that implements an MCP (Model Context Protocol) server integrated with Google Drive, allowing clients to interact with it using the Gemini framework.
Use cases
Use cases include building applications that require user authentication via Google, leveraging Google Drive for file storage, and utilizing AI models for data processing and analysis.
How to use
To use mcp-server-with-google-auth, clone the repository, set up a virtual environment, install dependencies, configure Google OAuth credentials, and set environment variables as specified in the README.
Key features
Key features include integration with Google Drive, support for OAuth 2.0 authentication, a web framework built with FastAPI, and the ability to utilize Google Generative AI through the Google API client.
Where to use
This server can be used in fields such as cloud computing, AI development, and web applications that require secure authentication and interaction with Google services.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
MCP Server Google Auth Project
This project demonstrates an MCP (Model Context Protocol) server with Google Drive integration and a client to interact with it using Gemini.
Prerequisites
- Python 3.12+
uv
(Python package installer and virtual environment manager)- Google Cloud Project with Vertex AI API enabled.
- OAuth 2.0
credentials.json
file from Google Cloud Console.
Setup
-
Clone the repository:
git clone https://github.com/Nvillaluenga/mcp-server-with-google-auth.git cd mcp-server-with-google-auth
-
Create and activate a virtual environment with
uv
:uv venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies with
uv sync
from pyproject.toml:uv sync
The dependencies are defined in
pyproject.toml
and include:fastapi
- Web framework for the MCP serverfastmcp
- MCP server implementationgoogle-api-python-client
- Google API clientgoogle-auth
andgoogle-auth-oauthlib
- Google authenticationgoogle-genai
- Google Generative AI interface
-
Set up Google OAuth Credentials:
- Go to the Google Cloud Console
- Navigate to “APIs & Services” > “Credentials”
- Create OAuth 2.0 Client IDs (Web application)
- Add
http://localhost:8081
to “Authorized JavaScript origins” - Add
http://localhost:8081/oauth2callback
to “Authorized redirect URIs” - Download and rename the credentials file to
credentials.json
and place it in the project root
-
Configure Environment Variables:
- Create
.env
from the template:cp .env.template .env
- Edit
.env
with your configuration:PROJECT
: Your Google Cloud Project IDLOCATION
: Your GCP region (e.g.,us-central1
)DEFAULT_MODEL
: Gemini model name (e.g.,gemini-2.0-flash-001
)HOST
: Server host (default:localhost
)PORT
: Server port (default:8081
)
- Create
Running the Application
You’ll need two terminals with active uv
environments:
1. Start the MCP Server:
python drive_web_mcp_server.py
2. Run the Client:
python main.py
Or specify a server URL:
python main.py http://your-server-address:port
The client will prompt you to authenticate with Google Drive:
- Open the displayed URL in your browser
- Complete the Google authentication flow
- Return to the terminal and start querying Gemini with access to Google Drive
How it Works
-
drive_web_mcp_server.py
: FastAPI-based MCP server that:- Handles OAuth 2.0 authentication with Google
- Exposes tools for the LLM to call
- Stores client credentials in memory by
client_id
-
mcp_client.py
: ContainsMCPClient
andGeminiMCPClient
classes:- Manages connections to MCP servers
- Handles authentication flow
- Interfaces with Gemini models
- Translates between MCP tools and Gemini function calls
-
main.py
: CLI to interact withGeminiMCPClient
-
.env
and.env.template
: Environment configuration -
credentials.json
: Google OAuth 2.0 client secrets (never commit this)
Authentication Flow Diagram
The following diagram illustrates the authentication process between the MCP client, MCP server and Google OAuth:
Available Tools
search_drive_files(query: str)
: Search files in Google Drivecheck_authentication_status()
: Check client authentication status
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.