MCP Google Drive Server
Provides tools to read and update files in Google Drive by URL or file ID, auto-detecting file types and supporting export of Google Docs as Markdown, Sheets as CSV, and Slides as text.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Google Drive Server Append today's meeting notes to this Doc: https://docs.google.com/document/d/abc123"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
📁 MCP Google Drive Server
Servidor MCP (Model Context Protocol) para interactuar con Google Drive
� Tabla de Contenidos
Related MCP server: Google Drive MCP Server
🎯 Descripción
Este servidor MCP proporciona una interfaz para interactuar con Google Drive a través del Model Context Protocol. Permite a las aplicaciones de IA leer y actualizar archivos de Google Drive de manera sencilla y eficiente.
¿Qué es MCP?
Model Context Protocol (MCP) es un protocolo estándar que permite a las aplicaciones de IA interactuar con fuentes de datos externas de manera estructurada y segura.
✨ Características
🔍 Lectura inteligente de archivos: Soporta Google Docs (Markdown), Sheets (CSV), Slides y archivos de texto
📝 Actualización de contenido: Modifica archivos de Google Drive directamente
🔗 URLs amigables: Acepta URLs completas de Google Drive (no necesitas extraer el ID manualmente)
🐳 Docker-ready: Despliega fácilmente con Docker y Docker Compose
🔄 Auto-detección de tipos: Detecta automáticamente el tipo de archivo y usa el método apropiado
📋 Formato estructurado: Google Docs exportados en Markdown para preservar formato
🛡️ Manejo de errores robusto: Mensajes de error claros y descriptivos
📋 Requisitos Previos
Python 3.14+
uv (gestor de paquetes Python)
Cuenta de Google Cloud con API de Drive habilitada
Docker (opcional, para deployment)
🚀 Instalación
Opción 1: Instalación Local
Clona el repositorio
git clone <repository-url> cd mcp-pyInstala las dependencias
uv syncConfigura las credenciales (ver sección Configuración)
Opción 2: Usando Docker
Clona el repositorio
git clone <repository-url> cd mcp-pyConfigura las credenciales (ver sección Configuración)
Levanta el contenedor
docker-compose up --build -d
🔧 Configuración
1. Obtener Credenciales de Google Cloud
Ve a Google Cloud Console
Crea un nuevo proyecto o selecciona uno existente
Habilita la Google Drive API
Ve a Credenciales > Crear credenciales > Cuenta de servicio
Descarga el archivo JSON de credenciales
Guarda el archivo como
credentials.jsonen la raíz del proyecto
2. Configurar Permisos de Archivos
Para que el servidor pueda acceder a tus archivos de Google Drive:
Abre el archivo
credentials.jsonCopia el valor del campo
client_email(ej:my-service@project.iam.gserviceaccount.com)En Google Drive:
Haz clic derecho en el archivo que deseas compartir
Selecciona Compartir
Pega el email de la cuenta de servicio
Dale permisos de Editor
Haz clic en Enviar
⚠️ Importante: Sin compartir el archivo con la cuenta de servicio, obtendrás errores de "Permiso denegado".
3. Variables de Entorno
El servidor detecta automáticamente el entorno:
Desarrollo (local): Lee
credentials.jsonde la raíz del proyectoProducción (Docker): Lee credenciales desde
/run/secrets/google_creds
Para forzar modo producción:
export APP_ENV=production🎮 Uso
Ejecutar Localmente
uv run mcp dev mcp_server/main.py:mcpEsto iniciará el servidor MCP en modo desarrollo con inspector en http://localhost:6274
Ejecutar con Docker
# Iniciar el servidor
docker-compose up --build -d
# Ver logs
docker-compose logs -f
# Detener el servidor
docker-compose downHerramientas Disponibles
1. get_drive_file_tool
Obtiene el contenido de un archivo de Google Drive.
Parámetros:
Parámetro | Tipo | Descripción |
|
| URL completa de Google Drive o file_id |
Tipos de archivos soportados:
✅ Google Docs → Exportado como Markdown (preserva estructura: títulos, listas, negritas, cursivas)
✅ Google Sheets → Exportado como CSV (datos tabulares)
✅ Google Slides → Exportado como texto plano
✅ Archivos de texto →
.txt,.md,.json, etc.✅ Otros archivos binarios → Con contenido de texto
💡 Nota sobre Markdown: Google Docs se exporta en formato Markdown, lo que preserva la estructura del documento (encabezados, listas, formato) y facilita la lectura y modificación programática del contenido.
Ejemplos de uso:
# Con URL completa de Google Docs
url = "https://docs.google.com/document/d/1h9sRNgBe.../edit?usp=sharing"
content = await get_drive_file_tool(url)
# Con URL de Google Sheets
url = "https://docs.google.com/spreadsheets/d/1h9sRNgBe.../edit"
csv_content = await get_drive_file_tool(url)
# Con file_id directo
file_id = "1h9sRNgBeEpC3aa3aXqjVaWTUrbjqKAWtvcoIBXdVdss"
content = await get_drive_file_tool(file_id)Ejemplo de respuesta (Google Docs en Markdown):
# Mi Documento
## Introducción
Este es un párrafo con **texto en negrita** y *texto en cursiva*.
## Sección Principal
- Item de lista 1
- Item de lista 2
- Sub-item
### Subsección
1. Elemento numerado 1
2. Elemento numerado 2
> Esto es una cita o nota importanteEjemplo de respuesta (Google Sheets en CSV):
Nombre,Edad,Ciudad
Juan,30,Madrid
María,25,Barcelona
Pedro,35,Valencia2. update_drive_file_tool
Actualiza el contenido de un archivo en Google Drive.
Parámetros:
Parámetro | Tipo | Descripción |
|
| ID del archivo a actualizar |
|
| Nuevo contenido del archivo |
Ejemplo de uso:
file_id = "1h9sRNgBeEpC3aa3aXqjVaWTUrbjqKAWtvcoIBXdVdss"
new_content = "Este es el nuevo contenido del archivo"
result = await update_drive_file_tool(file_id, new_content)Respuesta:
{
"status": "success",
"file_name": "Mi Documento.txt"
}3. test_server_tool
Verifica que el servidor está funcionando correctamente.
Parámetros: Ninguno
Ejemplo de uso:
response = await test_server_tool()Respuesta:
"Test de mcp py exitosa"🔌 Integración con IDEs
⚠️ Importante: Todas las configuraciones a continuación usan Docker. Asegúrate de que el contenedor esté corriendo:
docker-compose up -d
Warp Terminal
Agrega esta configuración a tu archivo de configuración MCP:
{
"mcp-py-drive-server": {
"command": "docker",
"args": [
"exec",
"-i",
"mcp-py",
"uv",
"run",
"mcp",
"run",
"mcp_server/main.py:mcp"
],
"env": {},
"working_directory": null
}
}VS Code
Agrega a tu settings.json:
{
"mcp.servers": {
"google-drive": {
"command": "docker",
"args": [
"exec",
"-i",
"mcp-py",
"uv",
"run",
"mcp",
"run",
"mcp_server/main.py:mcp"
],
"env": {}
}
}
}Claude Desktop
Edita ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"google-drive": {
"command": "docker",
"args": [
"exec",
"-i",
"mcp-py",
"uv",
"run",
"mcp",
"run",
"mcp_server/main.py:mcp"
]
}
}
}Cursor
Agrega a tu configuración de MCP en Cursor:
{
"mcp.servers": {
"google-drive": {
"command": "docker",
"args": [
"exec",
"-i",
"mcp-py",
"uv",
"run",
"mcp",
"run",
"mcp_server/main.py:mcp"
]
}
}
}Windsurf
Configura el servidor MCP en Windsurf:
{
"mcp.servers": {
"google-drive": {
"command": "docker",
"args": [
"exec",
"-i",
"mcp-py",
"uv",
"run",
"mcp",
"run",
"mcp_server/main.py:mcp"
]
}
}
}Configuración Alternativa (Sin Docker)
Si prefieres ejecutar el servidor localmente sin Docker:
{
"command": "uv",
"args": ["run", "mcp", "run", "mcp_server/main.py:mcp"],
"cwd": "/ruta/absoluta/a/mcp-py"
}💡 Tip: La configuración con Docker es recomendada para ambientes de producción y asegura consistencia entre diferentes máquinas.
🏗️ Arquitectura
Este proyecto sigue una arquitectura en capas clara y modular:
mcp-py/
├── mcp_server/ # Servidor MCP
│ ├── main.py # Punto de entrada del servidor MCP
│ ├── gateway/ # Integraciones con servicios externos
│ │ └── google_drive_client.py
│ ├── services/ # Lógica de negocio
│ │ └── drive_service.py
│ └── tools/ # Herramientas MCP
│ ├── get_drive_file.py
│ ├── update_drive_file.py
│ └── test_server.py
├── credentials.json # Credenciales de Google Cloud
├── pyproject.toml # Dependencias del proyecto
└── docker-compose.yml # Configuración de DockerFlujo de datos:
Cliente MCP → Docker → mcp_server/main.py → tools/ → services/ → gateway/ → Google Drive APIPara más detalles sobre la arquitectura, consulta ARCHITECTURE.md.
🐛 Solución de Problemas
Error: "Servicio de Drive no inicializado"
Causa: El archivo credentials.json no se encuentra o tiene errores.
Solución:
Verifica que
credentials.jsonexiste en la raíz del proyectoVerifica que el JSON es válido
Verifica que las credenciales no han expirado
Error: "Permiso denegado" (403)
Causa: El archivo no está compartido con la cuenta de servicio.
Solución:
Abre
credentials.jsony copia elclient_emailComparte el archivo de Google Drive con ese email
Dale permisos de Editor
El servidor no responde
Solución:
Verifica que el servidor está corriendo:
docker pso revisa logsVerifica que el puerto no esté en uso
Reinicia el servidor:
docker-compose restart
Error al extraer file_id de la URL
Causa: El formato de la URL no es reconocido.
Solución: El servidor acepta estos formatos:
https://docs.google.com/document/d/FILE_ID/edithttps://drive.google.com/file/d/FILE_ID/viewFILE_ID(directo)
Si tu URL es diferente, usa el file_id directamente.
📚 Recursos Adicionales
📄 Licencia
Este proyecto está bajo la licencia MIT. Ver el archivo LICENSE para más detalles.
🤝 Contribuciones
Las contribuciones son bienvenidas! Por favor:
Fork el proyecto
Crea una rama para tu feature (
git checkout -b feature/AmazingFeature)Commit tus cambios (
git commit -m 'Add some AmazingFeature')Push a la rama (
git push origin feature/AmazingFeature)Abre un Pull Request
📧 Soporte
Si encuentras algún problema o tienes preguntas:
Revisa la sección Solución de Problemas
Busca en los Issues existentes
Crea un nuevo Issue si es necesario
Hecho con ❤️ usando MCP
Available Tools
3 toolsget_drive_file_toolA
Tool: Get the content of a Google Drive file from its URL
Args: url: The complete Google Drive URL or file ID Examples: - https://docs.google.com/document/d/FILE_ID/edit?usp=sharing - https://drive.google.com/file/d/FILE_ID/view - FILE_ID (direct ID also works) return_json: If True (default), convert Google Docs/Sheets to structured JSON. If False, return raw markdown/csv content.
Returns: String containing the file content (JSON format for Google Workspace files by default)
Inputs: url (required), return_json. Returns: result
test_server_toolA
Tool: Execute a simple connection test to verify the server is responding
Inputs: no named parameters. Returns: result
update_drive_file_toolC
Tool: Update the content of a specific file in Google Drive
Inputs: content (required), file_id (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
The three tools have clearly distinct actions: read a file, update a file, and ping the server. There is no real risk of misselection, though the update tool's description is so terse (no args or behavior detail) that an agent must infer how it differs operationally from get beyond the verb.
All three names follow the same verb_noun_tool pattern: get_drive_file_tool, update_drive_file_tool, test_server_tool. The convention is applied uniformly without mixing styles.
Only three tools are exposed, one of which (test_server_tool) is infrastructure rather than domain functionality, leaving just two real Drive operations. This feels thin for a server whose stated purpose is Google Drive access.
The surface covers only reading and updating file content; there is no listing, searching, creating, deleting, or metadata retrieval, so an agent cannot discover files or manage them beyond a known ID/URL. These are significant gaps for a Drive server.
Maintenance
Related MCP Connectors
Files and tables your AI reads and writes from any chat, with version history and sharing.
Give Claude only the Google Drive files you choose. Every action logged.
File tools for your AI chat: PDF tables to Excel, merge PDFs, images to PDF, fill PDF forms.
Connect AI assistants to Google Sheets through controlled tools for reading and updating rows.
Related MCP Servers
- -licenseNot gradedqualityNot gradedmaintenanceEnables AI agents to efficiently access and process Google Drive documents by converting them to markdown and offering selective content extraction. Features intelligent caching, advanced search capabilities, and respect for Drive permissions to optimize context window usage.-
- AlicenseNot gradedqualityDmaintenanceEnables AI models to search, list, and read files from Google Drive with automatic format conversion for Google Workspace documents.MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to interact with Google Drive, supporting file operations like list, search, read, create, update, delete, share, and manage permissions.74MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to interact with Google Drive, including reading, searching, listing folders, and uploading files.71MIT