tammy-rb/google-drive-mcp-server
If you are the rightful owner of google-drive-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A Model Context Protocol (MCP) server that provides secure access to Google Drive files, allowing users to list, search, and read files through the MCP protocol.
Google Drive MCP Server
A Model Context Protocol (MCP) server that provides secure access to Google Drive files. This server allows you to list, search, and read files from your Google Drive through the MCP protocol.
Features
- 📁 List Drive Files: Browse files with pagination and filtering
- 🔍 Search Files: Search by file name or content
- 📖 Read Files: Access file content with automatic format conversion
- 🔐 Secure Authentication: OAuth 2.0 with Google Drive API
- 🏗️ MCP Protocol: Standard Model Context Protocol implementation
Setup
Prerequisites
- Python 3.8+
- Google Cloud Platform account
- Google Drive API credentials
1. Install Dependencies
Using uv (recommended):
# Install uv if you haven't already
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
# Navigate to project directory
cd gdrive-mcp
# Create virtual environment and install dependencies
uv venv
.venv\Scripts\activate
uv add mcp[cli] httpx google-api-python-client google-auth google-auth-oauthlib python-dotenv
2. Google Drive API Setup
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable the Google Drive API
- Create OAuth 2.0 credentials:
- Go to "Credentials" → "Create Credentials" → "OAuth 2.0 Client IDs"
- Choose "Desktop application"
- Download the JSON file
- Save the JSON file as
credentials/gcp-oauth.keys.json
3. Configuration
The server will automatically handle OAuth authentication on first run. Make sure your credentials/gcp-oauth.keys.json file is properly configured.
Usage
Running the MCP Server
# Activate virtual environment
.venv\Scripts\activate
# Run the server
python gdrive_server.py
Testing the Server
# Run the test client
python test_client.py
Using with MCP Clients
The server implements the standard MCP protocol and can be used with any MCP-compatible client.
Available Tools
-
list_drive_files
- List files in Google Drive
- Parameters:
page_size(int),cursor(string),query(string)
-
read_drive_file
- Read content of a specific file
- Parameters:
file_id(string, required)
-
search_drive_files
- Search for files by name or content
- Parameters:
query(string, required),page_size(int)
Available Resources
gdrive://files- Lists recent files from Google Drive
Project Structure
gdrive-mcp/
├── credentials/
│ ├── gcp-oauth.keys.json # Google OAuth credentials
│ └── .gdrive-server-credentials.json # Saved user tokens (auto-generated)
├── gdrive_server.py # Main MCP server implementation
├── test_client.py # Test client for the server
├── agent.py # Original agent implementation
├── pyproject.toml # Project configuration
└── README.md # This file
File Types Supported
The server automatically handles different Google Drive file types:
- Google Docs: Exported as Markdown
- Google Sheets: Exported as CSV
- Google Slides: Exported as plain text
- Text files: Read directly
- Binary files: Base64 encoded
Authentication Flow
- First run will open browser for OAuth consent
- Credentials are saved locally for future use
- Server uses read-only access to your Google Drive
Security Notes
- Server only requests read-only access to Google Drive
- Credentials are stored locally and never transmitted
- OAuth tokens are securely managed by Google's client libraries
Troubleshooting
Common Issues
- Authentication Error: Ensure
gcp-oauth.keys.jsonis valid and properly placed - Permission Denied: Check that Google Drive API is enabled in your GCP project
- File Not Found: Verify file IDs and that files exist in your Drive
Debug Mode
Enable debug logging by setting the environment variable:
export LOG_LEVEL=DEBUG
Development
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test with the provided test client
- Submit a pull request
Adding New Features
The server is built with extensibility in mind. To add new tools:
- Define a new Pydantic model for arguments
- Add the tool definition in
list_tools() - Implement the tool logic in
call_tool() - Add corresponding implementation function
License
This project is licensed under the MIT License - see the LICENSE file for details.