0.3.2 • Published 2 months ago

@sowonai/mcp-google-drive v0.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

@sowonai/mcp-google-drive

A Model Context Protocol (MCP) server for Google Drive integration.

X Threads

What is MCP?

MCP (Model Context Protocol) is an open protocol that allows AI assistants, such as Claude Desktop, to interact with external services and tools through a standardized interface. By running this server, you can connect Google Drive to Claude Desktop and manage your files using natural language commands.

Features

  • List files and folders (gdrive_listFiles)
  • Get detailed file information (gdrive_getFileDetails)
  • Create folders (gdrive_createFolder)
  • Upload files to Google Drive (gdrive_uploadFile)
  • Download files from Google Drive (gdrive_downloadFile)
  • Delete files and folders (gdrive_deleteFile)
  • Share files with specific users or make them publicly accessible (gdrive_shareFile)
  • Move files between folders (gdrive_moveFile)

Installation and Configuration

To use this MCP server, you first need to generate a configuration snippet that you can add to your AI assistant's (e.g., Claude Desktop) settings. This process involves an initial authentication step to grant the necessary permissions.

  1. Obtain Credentials: Follow the steps in the "Creating a Google Cloud Project and Obtaining Credentials" section below to get your credentials.json file.
  2. Run the Install Script: Execute the following command in your terminal, replacing /path/to/credentials.json with the actual path to your downloaded credentials file:
npx @sowonai/mcp-google-drive --install --credentials /path/to/credentials.json

MCP usage

Claude desktop config (claude_desktop_config.json)

The configuration generated by the --install script should be used here. A typical structure looks like this:

{
  "mcpServers": {
    "GoogleDrive": {
      "command": "npx",
      "args": ["-y", "@sowonai/mcp-google-drive"],
      "env": {
        "GOOGLE_CLIENT_ID": "YOUR_CLIENT_ID.apps.googleusercontent.com",
        "GOOGLE_CLIENT_SECRET": "YOUR_CLIENT_SECRET",
        "GOOGLE_REFRESH_TOKEN": "YOUR_REFRESH_TOKEN_FROM_INSTALL_STEP"
      }
    }
  }
}

Ensure the GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and GOOGLE_REFRESH_TOKEN in the env section are correctly populated from the output of the --install command.

SowonFlow Integration Example

You can utilize the Google Drive MCP in a YAML-based workflow like this:

const workflow = new Workflow({
  mainWorkflow: `
version: "agentflow/v1"
kind: "WorkflowSpec"
metadata:
  name: "Google Drive Assistant"
  description: "Google Drive MCP usage example"
  version: "0.1.0"

agents:
  - id: "drive_agent"
    inline:
      type: "agent"
      model: "openai/gpt-4.1-mini"
      system_prompt: |
        You are a Google Drive assistant that helps manage files and folders.
        Use MCP tools to answer user questions. (MCP tools have the prefix "mcp__")
        
        <information>
        Current time: '${new Date().toISOString()}'
        </information>

      mcp: ["mcp-google-drive"]
        
nodes:
  start:
    type: "agent_task"
    agent: "drive_agent"
    next: "end"
  
  end:
    type: "end"
`,
  mcpServers: {
    "mcp-google-drive": {
      "command": "npx",
      "args": ["-y", "@sowonai/mcp-google-drive"],
      "env": {
        "GOOGLE_CLIENT_ID": "YOUR_CLIENT_ID.apps.googleusercontent.com",
        "GOOGLE_CLIENT_SECRET": "YOUR_CLIENT_SECRET",
        "GOOGLE_REFRESH_TOKEN": "YOUR_REFRESH_TOKEN_FROM_INSTALL_STEP"
      }
    }
  }
});

// Ask a question to the workflow
const result = await workflow.ask("Show me my recent files");
console.log(result.content);

This example defines an agent in the workflow that can answer file-related questions using the Google Drive MCP server. SowonFlow is an AI-based workflow engine that interprets and executes workflows defined in YAML.

What is SowonFlow?

SowonFlow is a workflow product designed to conveniently utilize LLMs, featuring embedded workflows and lightweight workflows as its key characteristics. It can be used to create assistants available on Slack within the SowonAI service, and SowonFlow can also be embedded into your company's services. It can be utilized to create expert assistants that handle specific tasks on Slack.

Creating a Google Cloud Project and Obtaining Credentials

  1. Go to the Google Cloud Console.
  2. Create a new project or select an existing one.
  3. Enable the Google Drive API for your project:
    • Navigate to "APIs & Services" > "Library"
    • Search for "Google Drive API" and enable it
  4. Go to "APIs & Services" > "Credentials".
  5. Click "Create Credentials" > "OAuth client ID".
  6. Choose Desktop application as the application type.
  7. Name your OAuth client and click "Create".
  8. Download the JSON file containing your credentials.
  9. Save this file as credentials.json and specify the path when running the MCP server.
  10. Click "Create" and download the OAuth client JSON file.
  11. Rename the downloaded file to credentials.json. You will need to provide the path to this file when running the --install command.

Warning:
Never commit your credentials.json to a public repository. This file contains sensitive client secret information. The refresh token obtained during the --install process should also be kept secure.

How to Authenticate

To authenticate, call the authenticate tool using a JSON-RPC request:

{
  "jsonrpc": "2.0",
  "id": "1",
  "method": "tools/call",
  "params": {
    "name": "authenticate",
    "arguments": {}
  }
}

If you are using this server with Claude Desktop or another AI assistant, you can simply request authentication in natural language. The AI will automatically call the authenticate tool for you when needed.

This will start the authentication process and open a browser window for Google login. After successful authentication, your token will be saved automatically.

Token Storage Location

When you authenticate, your Gmail access token is securely saved in your home directory under the following path:

~/.sowonai/google-drvie-token.json

This file is used to maintain your login session. Do not share or commit this file to any public repository.