jitzian/MyGoogleDriveServer
If you are the rightful owner of MyGoogleDriveServer and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
This is an MCP server that provides access to Google Drive files through various tools.
Google Drive MCP Server
This is an MCP (Model Context Protocol) server that provides access to Google Drive files through two main tools:
Features
- List Drive Files - Lists all files in the Google Drive with metadata
- Read File Content - Reads and processes content from various file types including:
- Text files (.txt, .md, .json, etc.)
- Documents (.doc, .docx, .pdf)
- Images (.png, .jpg, .gif, etc.) - with metadata extraction - TO BE IMPLEMENTED
- Videos (.mp4, .mov, etc.) - with metadata extraction - TO BE IMPLEMENTED
- Spreadsheets (.xls, .xlsx)
- Presentations (.ppt, .pptx) - TO BE IMPLEMENTED
Setup
Prerequisites
Before you can use this MCP server, you need to set up a Google Cloud Platform service account and enable the Google Drive API.
Step 1: Create a Google Cloud Platform Project
- Sign in to Google Cloud Console: Navigate to Google Cloud Console and sign in with your Google account.
- Create a New Project:
- Click on the project dropdown at the top of the page
- Click "New Project"
- Enter a project name (e.g., "MCP-Drive-Server")
- Click "Create"
Reference: Create a Google Cloud Platform service account
Step 2: Enable Google Drive API
- Navigate to API Library:
- In the Google Cloud Console, click on "APIs & Services" > "Library"
- Use the left navigation menu or search for it
- Enable Google Drive API:
- Search for "Google Drive API" in the search bar
- Click on "Google Drive API" from the results
- Click the "Enable" button
Reference: Using Google Drive API with Python and a service account
Step 3: Create a Service Account
- Navigate to Service Accounts:
- Click on "IAM & Admin" > "Service Accounts" from the left navigation menu
- Create Service Account:
- Click "Create Service Account" button at the top
- Enter a service account name (e.g., "mcp-drive-server")
- Optionally add a description
- Click "Create and Continue"
- Grant Permissions (Optional):
- You can skip this step for basic Drive access
- Click "Continue" and then "Done"
Important: Service accounts are used for machine-to-machine authentication and don't require username/password. They're ideal for automated processes.
Step 4: Generate and Download JSON Key
- Access Service Account Keys:
- In the Service Accounts list, find your newly created service account
- Click on the service account email to open its details
- Navigate to the "Keys" tab
- Create New Key:
- Click "Add Key" > "Create new key"
- Select "JSON" as the key type
- Click "Create"
- Download and Store Securely:
- A JSON file will be automatically downloaded to your computer
- IMPORTANT: Never commit this file to version control (Git, GitHub, etc.)
- Store it securely as it contains sensitive credentials
Reference: Step-by-Step: How to Create a Service Account to Access Google API
Step 5: Configure the MCP Server
-
Place the JSON Key File:
- Rename your downloaded JSON file to
service-account.json - Move it to
src/main/resources/service-account.jsonin this project - The file should be in the resources folder so it's included in the classpath
- Rename your downloaded JSON file to
-
Share Google Drive Files with Service Account:
- Open your
service-account.jsonfile - Find the
client_emailfield (e.g.,mcp-drive-server@your-project.iam.gserviceaccount.com) - In Google Drive, share the folders/files you want to access with this email address
- Give it "Viewer" or "Editor" permissions as needed
- Open your
Step 6: Build and Run the Server
# Build the project
./gradlew build
# Run the server
./gradlew run
The server will start on http://localhost:3002/sse
Alternative: Using the Management Script
You can also use the provided management script:
# Start the server
./manage_server.sh start
# Stop the server
./manage_server.sh stop
# Check server status
./manage_server.sh status
Architecture
The codebase follows clean architecture principles:
src/main/kotlin/
├── Main.kt # Application entry point
├── GoogleDriveService.kt # Google Drive API client
├── constants/
│ └── GlobalConstants.kt # Application constants
├── domain/
│ ├── FileInfo.kt # File metadata model
│ └── FileContent.kt # File content model
└── tools/ # MCP Tools (following single responsibility)
├── ToolManager.kt # Registers all tools
├── ListDriveFilesTool.kt # Lists Google Drive files
├── ReadFileContentTool.kt # Reads file contents
└── FileContentExtractor.kt # Extracts content from various file formats
Available Tools
1. list_drive_files
Lists all files in the Google Drive root folder.
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "list_drive_files",
"arguments": {}
}
}
Response:
Returns a JSON array of FileInfo objects with:
id: Google Drive file IDname: File namemimeType: MIME type of the filesize: File size in bytesmodifiedTime: Last modification timestamp
2. read_file_content
Reads and processes the content of a specific file.
Request:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "read_file_content",
"arguments": {
"fileId": "your-google-drive-file-id"
}
}
}
Response:
Returns a FileContent object with:
id: File IDname: File namemimeType: MIME typesize: File sizecontent: Extracted content (text, metadata description, etc.)contentType: Type of content extraction performedmetadata: Additional metadata extracted from the file
Content Processing Capabilities
The server can handle various file types:
- Text Files: Direct text extraction
- Documents (DOC, DOCX): Text extraction using Apache Tika
- PDFs: Text extraction using Apache Tika
- Images: Metadata extraction (dimensions, format, EXIF data)
- Videos: Metadata extraction (format, duration, codec info)
- Spreadsheets: Content extraction from Excel files
- Binary Files: Basic metadata and description
Dependencies
Key libraries used:
- Kotlin MCP SDK: For MCP protocol implementation
- Google Drive API: For accessing Google Drive
- Apache Tika: For content extraction from various file formats
- Apache POI: For Microsoft Office document processing
- PDFBox: For PDF processing
- Ktor: For HTTP server functionality
Usage with MCP Clients
This server is designed to work with MCP-compatible clients like Claude Desktop or other AI assistants that support the Model Context Protocol.
To connect this server to Claude Desktop, add it to your MCP configuration:
{
"mcpServers": {
"google-drive": {
"command": "java",
"args": ["-jar", "path/to/your/server.jar"],
"env": {}
}
}
}
Error Handling
The server includes comprehensive error handling for:
- Google Drive API errors
- File processing errors
- Unsupported file types
- Network connectivity issues
All errors are returned as proper MCP error responses with descriptive messages.