dbbaskette/gdrive-mcp-server
If you are the rightful owner of gdrive-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 server for Google Drive, now updated to support Streamable HTTP (SSE) with per-session server instances.
Google Drive MCP Server (Streamable HTTP/SSE)
A Model Context Protocol server for Google Drive, now updated to support Streamable HTTP (SSE) with per-session server instances.
Overview
This server allows AI agents (via the Model Context Protocol) to access and search Google Drive files. It handles multiple users concurrently by requiring a forwarded Google Access Token for each connection.
Features
- Transport: HTTP Server-Sent Events (SSE) (replaces
stdio) - Authentication: Forwarded Bearer Token (Stateless, Per-Request)
- Tools:
search: Search for files using Google Drive query syntax.
- Resources:
- Access file contents (automatically exports Google Docs/Sheets to text/markdown/csv).
gdrive:///<file_id>URI scheme.
Installation
npm install
npm run build
Running the Server
Local Development
You can run the server locally on port 3000:
./run.sh
Deploying to Cloud Foundry
To build and push to your Cloud Foundry instance:
./run.sh --cf
Connection & Authentication
This server implements the MCP SSE transport specification.
Endpoints
GET /mcp: Initial connection endpoint (SSE stream).POST /mcp: Message submission endpoint (JSON-RPC).DELETE /mcp: Close session endpoint.
How to Connect
Clients must provide a valid Google OAuth Access Token in the Authorization header when establishing the SSE connection.
Example (Java SDK / Nexus)
The server expects the token to be injected into the initial HTTP GET request:
GET /mcp HTTP/1.1
Host: your-mcp-server.com
Authorization: Bearer <YOUR_GOOGLE_ACCESS_TOKEN>
Accept: text/event-stream
Once connected, the server will manage the session and handle standard MCP JSON-RPC messages.
API / Tool Usage
search Tool
Search for files in Google Drive.
- Input:
query(string) - A Google Drive API query string (e.g., "name contains 'Project'"). - Output: List of matching files with names and IDs.
Resources
The server exposes Google Drive files as resources. Reading a resource at gdrive:///<file_id> will download the file content.
- Google Docs -> Converted to Markdown
- Google Sheets -> Converted to CSV
- Google Slides -> Converted to Text
- Images/Binary -> Base64 encoded
License
MIT
Testing with MCP Inspector
To test the server with the MCP Inspector:
-
Run the server locally:
npm run build node dist/index.js -
Open the MCP Inspector:
npx @modelcontextprotocol/inspector -
Configure the connection:
- Transport type: Select "Streamable HTTP"
- URL:
http://localhost:3000/mcp
-
Click "Connect" to establish the connection.
-
Optional: If you want to test authenticated features (listing files, searching), you'll need to provide a Google OAuth access token via the
Authorizationheader. The standard MCP Inspector may not support custom headers, so discovery (listing tools) works without authentication, but actual file operations will require a token.
Implementation Notes
This server implements the MCP Streamable HTTP transport specification (2025-03-26):
- Single
/mcpendpoint handles GET, POST, and DELETE - POST requests with JSON-RPC requests are upgraded to SSE streams
- Sessions are managed via
Mcp-Session-Idheader - Supports concurrent multi-user access with separate sessions per user