Skip to content

mrbit-dev/mcp-google-driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 MCP Google Drive Server

Một MCP (Model Context Protocol) Server đầy đủ tính năng cho Google Drive, tương thích với tất cả AI clients hỗ trợ MCP:

  • Antigravity (Google DeepMind)
  • Claude Desktop (Anthropic)
  • Claude Code (CLI)
  • Cursor
  • Windsurf
  • Continue.dev
  • ✅ Và bất kỳ MCP-compatible client nào khác

🧩 Tính năng

Tool Mô tả
list_files Liệt kê files/folders trong Drive
search_files Tìm kiếm theo tên hoặc nội dung
get_file_info Xem metadata chi tiết của file
read_file Đọc nội dung file (Docs, Sheets, text...)
create_file Tạo file mới với nội dung
update_file Cập nhật nội dung file
create_folder Tạo thư mục mới
delete_file Xóa file (vào thùng rác hoặc vĩnh viễn)
restore_file Khôi phục từ thùng rác
move_file Di chuyển file sang folder khác
copy_file Sao chép file
rename_file Đổi tên file/folder
share_file Chia sẻ với người dùng hoặc công khai
get_permissions Xem danh sách quyền chia sẻ
get_storage_quota Xem dung lượng Drive

⚙️ Cài đặt

Bước 1: Clone và cài dependencies

git clone https://github.com/mrbit-dev/mcp-google-driver.git
cd mcp-google-driver
npm install

Bước 2: Tạo Google Cloud Project và OAuth2 Credentials

  1. Truy cập Google Cloud Console
  2. Tạo project mới hoặc chọn project có sẵn
  3. Vào APIs & Services > Enable APIs
  4. Bật Google Drive API
  5. Vào APIs & Services > Credentials
  6. Tạo OAuth 2.0 Client ID:
    • Application type: Desktop app
    • Tải file JSON về
  7. Copy client_idclient_secret

Bước 3: Tạo file .env

cp .env.example .env

Mở .env và điền thông tin:

GOOGLE_CLIENT_ID=your_client_id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your_client_secret

Bước 4: Lấy Refresh Token

npm run build

Script sẽ tự động mở trình duyệt, bạn đăng nhập và cấp quyền, sau đó refresh token sẽ được tự động lưu vào .env.

Bước 5: Build project

npm run build

🔧 Cấu hình MCP Client

Antigravity / Claude Desktop

Thêm vào file claude_desktop_config.json (Windows: %APPDATA%\Claude\claude_desktop_config.json):

{
  "mcpServers": {
    "google-drive": {
      "command": "node",
      "args": ["/path/to/mcp-google-driver/dist/index.js"],
      "env": {
        "GOOGLE_CLIENT_ID": "your_client_id",
        "GOOGLE_CLIENT_SECRET": "your_client_secret",
        "GOOGLE_REFRESH_TOKEN": "your_refresh_token"
      }
    }
  }
}

Lưu ý: Nếu đã có file .env trong project directory, bạn có thể bỏ qua phần env trong config (dotenv sẽ tự load).

Important

Chú ý về đường dẫn (/path/to/mcp-google-drive/): Bạn cần thay thế /path/to/mcp-google-drive bằng đường dẫn thư mục thực tế trên máy tính của bạn sau khi clone dự án về (ví dụ: C:/projects/mcp-google-drive/dist/index.js hoặc e:/laragon/www/MCP_GOOGLE_Driver/dist/index.js).

Claude Code (CLI)

claude mcp add google-drive node /path/to/mcp-google-drive/dist/index.js

Hoặc thêm vào .claude/settings.json:

{
  "mcpServers": {
    "google-drive": {
      "command": "node",
      "args": ["/path/to/mcp-google-drive/dist/index.js"]
    }
  }
}

Cursor

Thêm vào ~/.cursor/mcp.json:

{
  "mcpServers": {
    "google-drive": {
      "command": "node",
      "args": ["/path/to/mcp-google-drive/dist/index.js"]
    }
  }
}

Windsurf

Thêm vào ~/.codeium/windsurf/mcp_config.json:

{
  "mcpServers": {
    "google-drive": {
      "command": "node",
      "args": ["/path/to/mcp-google-drive/dist/index.js"]
    }
  }
}

🧪 Test với MCP Inspector

npm run inspector

Mở trình duyệt tại http://localhost:5173 để kiểm tra từng tool.


🔐 Bảo mật

  • File .envservice-account-key.json đã được thêm vào .gitignore
  • KHÔNG commit credentials lên Git
  • Sử dụng refresh token thay vì access token (tự động làm mới)
  • Hỗ trợ Service Account cho server-to-server authentication

🐛 Troubleshooting

Lỗi "Missing credentials"

→ Kiểm tra file .env đã có đủ GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, GOOGLE_REFRESH_TOKEN

Lỗi "Access denied"

→ Chạy lại npm run auth để lấy refresh token mới

Lỗi "Cannot find module"

→ Chạy npm run build trước khi start

Lỗi CORS hoặc redirect_uri_mismatch

→ Đảm bảo OAuth Client Type là Desktop app (không phải Web app)

About

MCP for AI agent use google driver

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors