CONFIGURATION.md•12.1 kB
# Configuration Guide
This guide covers all configuration options for the Google Drive MCP Server, including environment variables, configuration files, and advanced settings.
## Table of Contents
1. [Configuration Methods](#configuration-methods)
2. [Core Configuration](#core-configuration)
3. [Google Drive API Settings](#google-drive-api-settings)
4. [Cache Configuration](#cache-configuration)
5. [Processing Settings](#processing-settings)
6. [Server Configuration](#server-configuration)
7. [Security Settings](#security-settings)
8. [Monitoring and Logging](#monitoring-and-logging)
9. [Environment-Specific Configurations](#environment-specific-configurations)
## Configuration Methods
The server supports multiple configuration methods with the following priority order:
1. **Environment Variables** (highest priority)
2. **Configuration File** (`config.json`)
3. **Default Values** (lowest priority)
### Environment Variables
Set environment variables for quick configuration:
```bash
export GOOGLE_CLIENT_ID="your-client-id.googleusercontent.com"
export GOOGLE_CLIENT_SECRET="your-client-secret"
export CACHE_DIR="./cache"
export LOG_LEVEL="info"
```
### Configuration File
Create a `config.json` file in your project root:
```json
{
"google": {
"clientId": "your-client-id.googleusercontent.com",
"clientSecret": "your-client-secret"
},
"cache": {
"directory": "./cache",
"maxSize": "1GB"
}
}
```
## Core Configuration
### Required Settings
These settings are required for the server to function:
| Setting | Environment Variable | Description |
|---------|---------------------|-------------|
| `google.clientId` | `GOOGLE_CLIENT_ID` | Google OAuth client ID |
| `google.clientSecret` | `GOOGLE_CLIENT_SECRET` | Google OAuth client secret |
### Optional Core Settings
| Setting | Environment Variable | Default | Description |
|---------|---------------------|---------|-------------|
| `google.redirectUri` | `GOOGLE_REDIRECT_URI` | `http://localhost:8080/callback` | OAuth redirect URI |
| `google.applicationName` | `GOOGLE_APPLICATION_NAME` | `Google Drive MCP Server` | Application name for API requests |
## Google Drive API Settings
### OAuth Configuration
```json
{
"google": {
"clientId": "your-client-id.googleusercontent.com",
"clientSecret": "your-client-secret",
"redirectUri": "http://localhost:8080/callback",
"scopes": [
"https://www.googleapis.com/auth/drive.readonly",
"https://www.googleapis.com/auth/documents.readonly"
],
"applicationName": "Google Drive MCP Server"
}
}
```
### API Limits and Quotas
```json
{
"google": {
"quotas": {
"requestsPerSecond": 10,
"requestsPerDay": 1000000,
"requestsPerUser": 1000
},
"retryPolicy": {
"maxRetries": 3,
"baseDelay": 1000,
"maxDelay": 10000,
"backoffFactor": 2
}
}
}
```
## Cache Configuration
### Basic Cache Settings
```json
{
"cache": {
"directory": "./cache",
"maxSize": "1GB",
"defaultTTL": 3600,
"cleanupInterval": 300,
"enableCompression": true
}
}
```
### Advanced Cache Settings
```json
{
"cache": {
"directory": "./cache",
"maxSize": "5GB",
"defaultTTL": 7200,
"cleanupInterval": 600,
"enableCompression": true,
"compressionLevel": 6,
"evictionPolicy": "lru",
"maxFiles": 10000,
"enableMetrics": true,
"metadataTTL": 1800,
"contentTTL": 7200,
"searchResultsTTL": 300
}
}
```
### Cache Environment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| `CACHE_DIR` | `./cache` | Cache directory path |
| `CACHE_MAX_SIZE` | `1GB` | Maximum cache size |
| `CACHE_TTL` | `3600` | Default TTL in seconds |
| `CACHE_CLEANUP_INTERVAL` | `300` | Cleanup interval in seconds |
## Processing Settings
### File Processing Configuration
```json
{
"processing": {
"maxFileSize": "100MB",
"supportedMimeTypes": [
"application/vnd.google-apps.document",
"application/pdf",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"text/plain",
"text/markdown",
"text/html"
],
"chunkSize": 4000,
"summaryLength": 500,
"maxConcurrentFiles": 3,
"enableOCR": false,
"ocrLanguages": ["en", "es", "fr"],
"preserveFormatting": true,
"extractImages": false,
"extractTables": true
}
}
```
### Content Processing Options
| Setting | Environment Variable | Default | Description |
|---------|---------------------|---------|-------------|
| `processing.maxFileSize` | `MAX_FILE_SIZE` | `100MB` | Maximum file size to process |
| `processing.chunkSize` | `CHUNK_SIZE` | `4000` | Default chunk size for content extraction |
| `processing.maxConcurrentFiles` | `MAX_CONCURRENT_FILES` | `3` | Maximum files to process simultaneously |
### Format-Specific Settings
```json
{
"processing": {
"pdf": {
"enableOCR": false,
"ocrLanguages": ["en"],
"extractImages": false,
"preserveLayout": true
},
"docx": {
"preserveFormatting": true,
"extractImages": false,
"convertTables": true
},
"googleDocs": {
"exportFormat": "markdown",
"includeComments": false,
"includeSuggestions": false
}
}
}
```
## Server Configuration
### Basic Server Settings
```json
{
"server": {
"port": 3000,
"logLevel": "info",
"requestTimeout": 30000,
"enableHealthCheck": true,
"enableMetrics": true
}
}
```
### Advanced Server Settings
```json
{
"server": {
"port": 3000,
"host": "localhost",
"logLevel": "info",
"requestTimeout": 30000,
"keepAliveTimeout": 5000,
"headersTimeout": 60000,
"maxRequestSize": "50MB",
"enableHealthCheck": true,
"healthCheckPath": "/health",
"enableMetrics": true,
"metricsPath": "/metrics",
"enableCORS": false,
"corsOrigins": ["*"],
"enableCompression": true
}
}
```
### Server Environment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| `PORT` | `3000` | Server port |
| `HOST` | `localhost` | Server host |
| `LOG_LEVEL` | `info` | Logging level |
| `REQUEST_TIMEOUT` | `30000` | Request timeout in milliseconds |
## Security Settings
### Authentication Security
```json
{
"security": {
"enableRateLimiting": true,
"maxRequestsPerMinute": 60,
"maxRequestsPerHour": 1000,
"enableIPWhitelist": false,
"allowedIPs": [],
"enableAPIKeyAuth": false,
"apiKeys": [],
"tokenEncryption": {
"enabled": true,
"algorithm": "aes-256-gcm",
"keyDerivation": "pbkdf2"
}
}
}
```
### File Access Security
```json
{
"security": {
"fileAccess": {
"enforcePermissions": true,
"allowSharedFiles": true,
"allowPublicFiles": false,
"maxFileSize": "100MB",
"blockedMimeTypes": [
"application/x-executable",
"application/x-msdownload"
],
"scanForMalware": false
}
}
}
```
## Monitoring and Logging
### Logging Configuration
```json
{
"logging": {
"level": "info",
"format": "json",
"enableConsole": true,
"enableFile": true,
"fileOptions": {
"filename": "logs/server.log",
"maxSize": "10MB",
"maxFiles": 5,
"rotateDaily": true
},
"enableRequestLogging": true,
"enableErrorTracking": true,
"sensitiveFields": ["clientSecret", "accessToken"]
}
}
```
### Metrics and Monitoring
```json
{
"monitoring": {
"enableMetrics": true,
"metricsPort": 9090,
"enableHealthChecks": true,
"healthCheckInterval": 30000,
"enablePerformanceTracking": true,
"enableResourceMonitoring": true,
"alerting": {
"enableAlerts": false,
"webhookUrl": "",
"thresholds": {
"errorRate": 0.05,
"responseTime": 5000,
"memoryUsage": 0.8
}
}
}
}
```
## Environment-Specific Configurations
### Development Configuration
```json
{
"google": {
"clientId": "${GOOGLE_CLIENT_ID}",
"clientSecret": "${GOOGLE_CLIENT_SECRET}"
},
"cache": {
"directory": "./cache",
"maxSize": "500MB",
"defaultTTL": 1800
},
"server": {
"port": 3000,
"logLevel": "debug"
},
"processing": {
"maxFileSize": "50MB",
"maxConcurrentFiles": 2
}
}
```
### Production Configuration
```json
{
"google": {
"clientId": "${GOOGLE_CLIENT_ID}",
"clientSecret": "${GOOGLE_CLIENT_SECRET}",
"redirectUri": "${GOOGLE_REDIRECT_URI}"
},
"cache": {
"directory": "/var/cache/google-drive-mcp",
"maxSize": "10GB",
"defaultTTL": 7200,
"enableCompression": true
},
"server": {
"port": "${PORT:-3000}",
"host": "0.0.0.0",
"logLevel": "warn",
"requestTimeout": 60000
},
"processing": {
"maxFileSize": "500MB",
"maxConcurrentFiles": 5
},
"security": {
"enableRateLimiting": true,
"maxRequestsPerMinute": 120
},
"monitoring": {
"enableMetrics": true,
"enableHealthChecks": true,
"enableAlerts": true
}
}
```
### Docker Configuration
```json
{
"google": {
"clientId": "${GOOGLE_CLIENT_ID}",
"clientSecret": "${GOOGLE_CLIENT_SECRET}"
},
"cache": {
"directory": "/app/cache",
"maxSize": "${CACHE_MAX_SIZE:-2GB}",
"defaultTTL": 3600
},
"server": {
"port": 3000,
"host": "0.0.0.0",
"logLevel": "${LOG_LEVEL:-info}"
},
"logging": {
"enableConsole": true,
"enableFile": false,
"format": "json"
}
}
```
## Configuration Validation
### Validation Rules
The server validates configuration on startup:
1. **Required Fields**: `google.clientId` and `google.clientSecret` must be provided
2. **File Paths**: Cache directory must be writable
3. **Size Limits**: Memory and file size limits must be valid
4. **Network Settings**: Port must be available and valid
5. **Security Settings**: API keys and tokens must meet security requirements
### Validation Commands
```bash
# Validate current configuration
npx google-drive-mcp config validate
# Show current configuration
npx google-drive-mcp config show
# Test configuration with dry run
npx google-drive-mcp config test
```
## Configuration Templates
### Minimal Configuration
```json
{
"google": {
"clientId": "your-client-id.googleusercontent.com",
"clientSecret": "your-client-secret"
}
}
```
### Recommended Configuration
```json
{
"google": {
"clientId": "your-client-id.googleusercontent.com",
"clientSecret": "your-client-secret",
"redirectUri": "http://localhost:8080/callback"
},
"cache": {
"directory": "./cache",
"maxSize": "2GB",
"defaultTTL": 3600
},
"processing": {
"maxFileSize": "100MB",
"chunkSize": 4000
},
"server": {
"port": 3000,
"logLevel": "info",
"requestTimeout": 30000
}
}
```
### High-Performance Configuration
```json
{
"google": {
"clientId": "your-client-id.googleusercontent.com",
"clientSecret": "your-client-secret"
},
"cache": {
"directory": "./cache",
"maxSize": "10GB",
"defaultTTL": 7200,
"enableCompression": true,
"compressionLevel": 6
},
"processing": {
"maxFileSize": "500MB",
"maxConcurrentFiles": 8,
"chunkSize": 8000
},
"server": {
"port": 3000,
"requestTimeout": 60000,
"enableCompression": true
},
"security": {
"enableRateLimiting": true,
"maxRequestsPerMinute": 200
}
}
```
## Troubleshooting Configuration
### Common Issues
1. **Authentication Failures**: Check client ID and secret
2. **Cache Errors**: Verify directory permissions and disk space
3. **Performance Issues**: Adjust concurrent file limits and cache size
4. **Memory Issues**: Reduce max file size and chunk size
### Debug Configuration
```json
{
"server": {
"logLevel": "debug"
},
"logging": {
"enableRequestLogging": true,
"enableErrorTracking": true
},
"monitoring": {
"enablePerformanceTracking": true,
"enableResourceMonitoring": true
}
}
```
For more configuration examples, see the [examples/config](../examples/) directory.