Google Workspace Automation MCP server

Integrates with Google Workspace services through Google Apps Script Web Apps to automate Gmail, Calendar, Drive, Docs, Sheets, Slides, and Forms operations including email management, event scheduling, file handling, document creation, and form building with weather data retrieval and presentation generation capabilities.
Back to servers
Setup instructions
Provider
Kanshi Tanaike
Release date
Jul 04, 2025
Language
Python
Stats
20 stars

This guide demonstrates how to set up and use a Model Context Protocol (MCP) server with Google Apps Script to enhance Gemini CLI capabilities. The integration allows Gemini to interact directly with Google Workspace services like Gmail, Drive, Calendar, and more.

Setting Up the MCP Server

Create a Google Apps Script Project

First, create a standalone Google Apps Script project by visiting script.google.com.

Install Required Libraries

Install these libraries to your project:

  • MCPApp

    • Project Key: 1TlX_L9COAriBlAYvrMLiRFQ5WVf1n0jChB6zHamq2TNwuSbVlI5sBUzh
    • Identifier: MCPApp
  • ToolsForMCPServer

    • Project Key: 1lnE7UL1jQgPDbTB9yjhiwZM0SaS9MObhzvWUWb_t8FisO6A3bLepvM2j
    • Identifier: ToolsForMCPServer

Add the Script

Copy this script to your project:

const apiKey = "###"; // API key for Gemini API

/**
 * This function is automatically run when the MCP client accesses Web Apps.
 */
const doPost = e => main(e);

function main(eventObject) {
  const m = ToolsForMCPServer;
  m.apiKey = apiKey;
  const object = { eventObject, items: m.getServer() };
  return new MCPApp
    .mcpApp({ accessKey: "sample" })
    .setServices({ lock: LockService.getScriptLock() })
    .server(object);
}

Note: If you plan to use the generate_presentation_with_google_slides tool, uncomment the apiKey line and add a valid Gemini API key.

Deploy as a Web App

  1. Click DeployNew deployment
  2. Select Web App as the type
  3. Enter a description
  4. Set Execute as to "Me"
  5. Set Who has access to "Anyone"
  6. Click Deploy
  7. Copy the Web App URL (looks like https://script.google.com/macros/s/###/exec)

Configuring Gemini CLI

Install Gemini CLI

Follow the instructions at the official Gemini CLI repository.

Edit settings.json

Locate your settings file (~/.gemini/settings.json on macOS/Linux or %USERPROFILE%.gemini\settings.json on Windows) and add:

{
  "theme": "Default",
  "selectedAuthType": "###",
  "mcpServers": {
    "gas_web_apps": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://script.google.com/macros/s/###/exec?accessKey=sample"
      ],
      "env": {}
    }
  }
}

Replace the URL with your Web App URL. If you haven't installed mcp-remote, install it with npm.

Using the MCP Server

Checking Available Tools

Type /mcp in the Gemini CLI to see all available tools. You should see 23 tools including:

  • Gmail tools (search, send, draft creation)
  • Google Drive tools (search, upload, download)
  • Google Calendar tools (search, create events)
  • Google Docs and Sheets tools (read, write)
  • Google Forms and Slides tools (generate surveys, quizzes, presentations)

Example Use Cases

Search Files in Google Drive

Ask: "Search for files with the filename of 'sample file' from Google Drive."

Check Your Calendar

Ask: "Tell me my today's schedule."

Read Emails

Ask: "Tell me my today's emails from [email address]."

Send Emails

Ask: "Create an email to thank [name] for [something]. Their email address is [email]."

Create Documents

Ask: "Create a new Google Document and put the following text into it: [text]"

Generate Presentations

Ask: "Please create a presentation about [topic]. My name is [name]."

Create Surveys and Quizzes

Ask: "Generate a survey about [topic] using Google Forms and send the URL to [email]."

Adding Custom Tools

If you want to extend the MCP server with your own tools, use this template:

function getCustomTools() {
  const functions = {
    params_: {
      function_name1: {
        description: "###",
        parameters: {}
      },
      function_name2: {
        description: "###",
        parameters: {}
      }
    },

    function_name1: (object) => { },
    function_name2: (object) => { },
  };

  // for MCP
  const itemsForMCP = [
    {
      "type": "initialize",
      "value": {
        "protocolVersion": "2024-11-05", // or "2025-03-26"
        "capabilities": { "tools": { "listChanged": false } },
        "serverInfo": { "name": "gas_web_apps", "version": "1.0.0" }
      }
    },
    ...Object.keys(functions.params_).map(f => (
      {
        "type": "tools/list",
        "function": functions[f],
        "value": {
          name: f,
          description: functions.params_[f].description,
          inputSchema: functions.params_[f].parameters,
        }
      }))
  ];

  return itemsForMCP;
}

Then modify your main function to include both the built-in and custom tools:

function main(eventObject) {
  const m = ToolsForMCPServer;
  m.apiKey = apiKey;
  const object = { eventObject, items: [...m.getServer(), ...getCustomTools()] };
  return new MCPApp
    .mcpApp({ accessKey: "sample" })
    .setServices({ lock: LockService.getScriptLock() })
    .server(object);
}

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "gas_web_apps" '{"command":"npx","args":["mcp-remote","https://script.google.com/macros/s/###/exec?accessKey=sample"],"env":[]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "gas_web_apps": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://script.google.com/macros/s/###/exec?accessKey=sample"
            ],
            "env": []
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "gas_web_apps": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://script.google.com/macros/s/###/exec?accessKey=sample"
            ],
            "env": []
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later