advanced-commands.sh•3.73 kB
#!/bin/bash
# Google Drive MCP Server - Advanced CLI Commands
# This script demonstrates advanced usage patterns and automation
echo "=== Google Drive MCP Server - Advanced CLI Commands ==="
echo
# Advanced search with multiple filters
echo "1. Advanced search with date and type filters"
npx google-drive-mcp search \
--query "quarterly report" \
--type "pdf,document" \
--modified-after "2024-01-01" \
--modified-before "2024-12-31" \
--order-by "modifiedTime" \
--limit 10 \
--format json
echo
# Search in specific folder with detailed output
echo "2. Search in specific folder with detailed metadata"
npx google-drive-mcp search \
--query "*" \
--folder-id "root" \
--include-permissions \
--include-metadata \
--format table
echo
# Batch content extraction
echo "3. Batch content extraction from search results"
SEARCH_RESULTS=$(npx google-drive-mcp search --query "meeting notes" --format json --limit 5)
echo "$SEARCH_RESULTS" | jq -r '.files[].id' | while read file_id; do
if [ ! -z "$file_id" ]; then
echo "Extracting content from file: $file_id"
npx google-drive-mcp content \
--file-id "$file_id" \
--start-char 0 \
--end-char 2000 \
--output "content_${file_id}.md"
fi
done
echo
# Content search within files
echo "4. Search for specific content within files"
npx google-drive-mcp content \
--file-id "FILE_ID" \
--search "executive summary" \
--context-lines 3 \
--highlight
echo
# Export file in different formats
echo "5. Export file in different formats"
# npx google-drive-mcp export --file-id "FILE_ID" --format markdown --output summary.md
# npx google-drive-mcp export --file-id "FILE_ID" --format plain --output content.txt
echo "Commands:"
echo " npx google-drive-mcp export --file-id FILE_ID --format markdown --output summary.md"
echo " npx google-drive-mcp export --file-id FILE_ID --format plain --output content.txt"
echo
# Cache management
echo "6. Advanced cache management"
echo "Cache statistics:"
npx google-drive-mcp cache stats
echo "Cache cleanup (files older than 7 days):"
npx google-drive-mcp cache cleanup --older-than 7d
echo "Clear specific file from cache:"
# npx google-drive-mcp cache clear --file-id "FILE_ID"
echo "Command: npx google-drive-mcp cache clear --file-id FILE_ID"
echo
# Configuration management
echo "7. Configuration management"
echo "Validate configuration:"
npx google-drive-mcp config validate
echo "Show specific config section:"
npx google-drive-mcp config show cache
npx google-drive-mcp config show processing
echo
# Monitoring and diagnostics
echo "8. Monitoring and diagnostics"
echo "Server health check:"
npx google-drive-mcp health --detailed
echo "Performance metrics:"
npx google-drive-mcp metrics
echo "Test all components:"
npx google-drive-mcp test all
echo
# Authentication management
echo "9. Authentication management"
echo "Check authentication status:"
npx google-drive-mcp auth status
echo "Refresh authentication tokens:"
npx google-drive-mcp auth refresh
echo "Reset authentication (will require re-auth):"
# npx google-drive-mcp auth reset
echo "Command: npx google-drive-mcp auth reset"
echo
# Batch operations
echo "10. Batch operations"
echo "Process all files in a folder:"
# npx google-drive-mcp batch --folder-id "FOLDER_ID" --action extract --output-dir ./extracted/
echo "Command: npx google-drive-mcp batch --folder-id FOLDER_ID --action extract --output-dir ./extracted/"
echo "Batch metadata extraction:"
# npx google-drive-mcp batch --search "*.pdf" --action metadata --output metadata.json
echo "Command: npx google-drive-mcp batch --search '*.pdf' --action metadata --output metadata.json"
echo
echo "=== Advanced CLI Commands Complete ==="