# π§ Technical Documentation
*Advanced setup and development guide for developers and technical users.*
## ποΈ Architecture Overview
```
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Claude AI βββββΊβ MCP Server βββββΊβ Google Drive β
β β β β β API β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
β β β
WebSocket/ Node.js HTTPS/
stdio transport Express OAuth2
```
### Components
- **MCP Server**: Node.js application implementing the Model Context Protocol
- **Google Drive Client**: googleapis library for Drive API interactions
- **Authentication Layer**: Supports both Service Account and OAuth 2.0
- **Transport**: stdio-based communication with Claude Desktop
## π Project Structure
```
mcp-google-drive-server/
βββ server.js # Main MCP server implementation
βββ auth.js # OAuth authentication helper
βββ test.js # Basic functionality test
βββ debug-test.js # Authentication debugging
βββ package.json # Node.js dependencies
βββ service-account.json # Service account credentials (not in repo)
βββ credentials.json # OAuth credentials (not in repo)
βββ token.json # OAuth tokens (not in repo)
βββ docs/ # Documentation
β βββ SETUP-GUIDE.md
β βββ FAQ.md
β βββ TROUBLESHOOTING.md
βββ README.md # Main documentation
```
## π Authentication Methods
### Service Account (Recommended for Production)
**Pros:**
- No user interaction required
- Suitable for server environments
- Consistent access without token expiration
- Can be shared across team members
**Cons:**
- Requires explicit folder sharing
- More complex initial setup
- Requires Google Cloud project management
**Implementation:**
```javascript
const auth = new google.auth.GoogleAuth({
credentials: serviceAccount,
scopes: [
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/drive.file',
'https://www.googleapis.com/auth/drive.readonly',
'https://www.googleapis.com/auth/drive.metadata.readonly'
]
});
```
### OAuth 2.0 (For Development/Personal Use)
**Pros:**
- Access to user's entire Drive (with permission)
- Easier for personal use
- Standard Google OAuth flow
**Cons:**
- Requires periodic re-authentication
- User interaction needed for initial setup
- Tokens can expire
**Implementation:**
```javascript
const oAuth2Client = new google.auth.OAuth2(
client_id,
client_secret,
redirect_uris[0]
);
```
## π οΈ API Implementation
### Tool Definitions
The server implements these MCP tools:
| Tool | Description | Parameters |
|------|-------------|------------|
| `list_files` | List and search files | `query`, `maxResults`, `folderId`, `includeShared` |
| `read_file` | Read file contents | `fileId` |
| `create_file