概述
安装
工具列表
内容详情
替代品
什么是MCP服务器?
MCP服务器是一种通过Model Context Protocol (MCP)与AI模型(如Gemini)进行交互的工具。它允许AI模型调用外部服务和API,从而执行复杂任务。如何使用MCP服务器?
通过将Google Apps Script项目部署为Web App,并配置Gemini CLI连接到该服务器,用户可以轻松地让Gemini调用Google Workspace服务(如Gmail、Drive、Calendar等)。适用场景
适用于自动化日常任务,例如管理日历事件、发送邮件、处理文档和文件等。适合希望利用AI增强生产力的开发者和普通用户。主要功能
优势与局限性
如何使用
使用案例
常见问题
相关资源
安装
{
"theme": "Default",
"selectedAuthType": "###",
"mcpServers": {
"gas_web_apps": {
"command": "npx",
"args": [
"mcp-remote",
"https://script.google.com/macros/s/###/exec?accessKey=sample"
],
"env": {}
}
}
}
🚀 基于MCP服务器的Gemini CLI:借助Google Apps Script拓展可能性
本项目借助低代码平台Google Apps Script(GAS)构建的MCP服务器,结合Gemini CLI,为用户提供了与Google的Gemini模型进行交互的强大命令行界面。通过利用模型上下文协议(MCP),CLI可以使用自定义工具进行扩展。本项目简化了Google Workspace API(如Gmail、Drive、Calendar等)的授权流程,使Gemini能够在Google生态系统内直接执行复杂的多步骤任务。
🚀 快速开始
准备MCP服务器
1. 创建Google Apps Script项目
首先,创建一个新的独立Google Apps Script项目。独立项目不绑定特定的Google表格、文档或表单,非常适合创建通用的Web服务。你可以通过访问 script.google.com 创建一个。参考
2. 安装库
为了简化MCP服务器的构建,我们将使用预构建的Google Apps Script库。这些库封装了复杂的MCP处理逻辑,并提供了现成的工具,使主脚本保持简洁。
本示例使用两个Google Apps Script库:
- MCPApp:管理MCP服务器的生命周期和通信协议。
- ToolsForMCPServer:提供一套预构建的工具,用于与Google Workspace服务(如Gmail、Drive、Calendar等)进行交互。
库项目密钥和安装步骤
- 打开刚创建的项目的脚本编辑器。
- 安装MCPApp:
- 安装指南
- 项目密钥:
1TlX_L9COAriBlAYvrMLiRFQ5WVf1n0jChB6zHamq2TNwuSbVlI5sBUzh
- 标识符:
MCPApp
- 仓库:https://github.com/tanaikech/MCPApp
- 安装ToolsForMCPServer:
- 安装指南
- 项目密钥:
1lnE7UL1jQgPDbTB9yjhiwZM0SaS9MObhzvWUWb_t8FisO6A3bLepvM2j
- 标识符:
ToolsForMCPServer
- 仓库:https://github.com/tanaikech/ToolsForMCPServer
3. 编写脚本
请将以下脚本复制并粘贴到脚本编辑器中(替换任何现有代码),然后保存项目。
const apiKey = "###"; // Gemini API的API密钥
/**
* 当MCP客户端访问Web应用时,此函数会自动运行。
*/
const doPost = e => main(e);
function main(eventObject) {
const m = ToolsForMCPServer;
m.apiKey = apiKey;
const object = { eventObject, items: m.getTools() };
return new MCPApp
.mcpApp({ accessKey: "sample" })
.setServices({ lock: LockService.getScriptLock() })
.server(object);
}
注意:
- 如果你打算使用以下工具,必须取消脚本中
apiKey
行的注释,并提供有效的Gemini API密钥:generate_roadmap_to_google_sheets
:在Google表格中创建路线图。generate_description_on_google_drive
:为Google云端硬盘上的文件生成并设置描述。generate_image_on_google_drive
:根据提示生成图像并保存到Google云端硬盘。summarize_file_on_google_drive
:总结存储在Google云端硬盘上的文件。description_web_site
:根据网站URL提供网站描述。
- 如果发生与Drive API相关的错误,请在高级Google服务中启用Drive API。
- 如果你想使用API的批量更新方法管理文档、表格和幻灯片,请在高级Google服务中启用Docs API、Sheets API和Slides API。
显示所有工具
运行此脚本时,库中的所有工具将以JSON对象的形式显示。
function showAlltools() {
const res = ToolsForMCPServer.getToolList();
console.log(res);
}
过滤工具
当你想使用特定工具时,也可以使用以下脚本。
此脚本仅使用 get_exchange_rate
工具。
function main(eventObject) {
const enables = ["get_exchange_rate"];
const m = ToolsForMCPServer;
m.apiKey = apiKey;
const object = { eventObject, items: m.getTools({ enables }) };
return new MCPApp
.mcpApp({ accessKey: "sample" })
.setServices({ lock: LockService.getScriptLock() })
.server(object);
}
此脚本使用除 get_exchange_rate
之外的所有工具。
function main(eventObject) {
const disables = ["get_exchange_rate"];
const m = ToolsForMCPServer;
m.apiKey = apiKey;
const object = { eventObject, items: m.getTools({ disables }) };
return new MCPApp
.mcpApp({ accessKey: "sample" })
.setServices({ lock: LockService.getScriptLock() })
.server(object);
}
4. 部署Web应用
为了让Gemini CLI与我们的脚本进行通信,必须将其部署为Web应用。这将创建一个唯一的URL,作为我们的MCP服务器端点。
你可以在 官方文档 中找到详细信息。
请按照以下步骤在脚本编辑器中部署Web应用:
- 在脚本编辑器的右上角,点击 部署 -> 新建部署。
- 点击 选择类型 -> Web应用。
- 在 部署配置 下的字段中输入Web应用的描述。
- 为 “以谁的身份执行” 选择 “我”。这很关键,因为它允许脚本以你的权限运行,以访问你的Google服务。
- 为 “谁可以访问” 选择 “任何人”。这使得该URL可以从互联网调用。访问由不可猜测的URL和脚本中定义的
accessKey
控制。 - 点击 部署。
- 授权必要的范围后,复制 Web应用URL。它看起来类似于
https://script.google.com/macros/s/###/exec
。这就是你的MCP服务器端点。
重要提示:当你修改Apps Script代码时,必须创建一个新的部署版本来发布更改。点击 部署 > 管理部署,选择你的活动部署,点击铅笔图标,然后从版本下拉菜单中选择 “新版本”。更多信息
准备Gemini CLI
1. 安装Gemini CLI
按照官方文档在你的系统上安装Gemini CLI。参考
2. 修改 settings.json
要将Gemini CLI连接到新的Apps Script服务器,你需要编辑其设置文件。此文件通常位于macOS/Linux上的 ~/.gemini/settings.json
或Windows上的 %USERPROFILE%\.gemini\settings.json
。
添加如下所示的 mcpServers
配置块。
- 将
https://script.google.com/macros/s/###/exec
替换为你之前复制的Web应用URL。 - 确保
accessKey
查询参数与你在Google Apps Script中定义的accessKey
匹配(本示例中为sample
)。
{
"theme": "Default",
"selectedAuthType": "###",
"mcpServers": {
"gas_web_apps": {
"command": "npx",
"args": [
"mcp-remote",
"https://script.google.com/macros/s/###/exec?accessKey=sample"
],
"env": {}
}
}
}
"gas_web_apps"
:你的服务器的本地标识符。"command"
和"args"
:这些告诉Gemini CLI如何调用mcp-remote
工具,该工具处理与你的Web应用URL的通信。
如果你从未安装过 mcp-remote
,请进行安装。参考
3. 传输文件内容(2025年7月9日新增)
最近,我发布了一篇题为 "使用基于Google Apps Script构建的MCP服务器的Gemini CLI处理文件内容" 的报告 参考。在这份报告中,我得出结论,在后台使用Drive API在Gemini CLI和Google Drive之间传输文件内容比直接在提示中嵌入base64数据更有效。因此,为了方便这种有效的传输,我使用了 ggsrun 这个CLI工具。
3.1. ggsrun
设置指南
要使用此方法,你首先需要设置 ggsrun
。
- 下载
ggsrun
:从 ggsrun发布页面 获取最新版本。主仓库 在此。 - 创建Google Cloud项目:访问 Google Cloud Platform资源管理器 并点击 创建项目。
- 启用Drive API:在你的新项目中,导航到 API和服务 > 已启用的API和服务。搜索并启用 Drive API。
- 创建凭据:导航到 API和服务 > 凭据。
- 配置OAuth客户端ID:点击 创建凭据,选择 OAuth客户端ID,然后选择 Web应用程序。
- 设置重定向URI:在 "已授权的重定向URI" 下,添加
http://localhost:8080
。 - 创建并下载凭据:点击 创建,然后点击 下载JSON。重要提示:将下载的文件重命名为
client_secret.json
并将其放在你的工作目录中。 - 对
ggsrun
进行身份验证:- 打开包含
client_secret.json
的目录中的终端。 - 运行命令
ggsrun auth
。 - 复制终端中显示的URL,粘贴到你的浏览器中,并授权请求的范围。
- 从浏览器的地址栏中复制授权码,并将其粘贴回终端。
- 打开包含
要验证设置是否成功,运行 ggsrun di
以显示你的Google云端硬盘信息。
3.2. 为 ggsrun
配置Gemini CLI
要使Gemini CLI能够使用 ggsrun
,请将以下工具定义添加到你的 GEMINI.md
文件中。此文件通常位于macOS/Linux上的 ~/.gemini/GEMINI.md
或Windows上的 %USERPROFILE%\.gemini\GEMINI.md
。
# 使用ggsrun在本地PC和Google Drive之间传输文件内容
* GitHub仓库:[https://github.com/tanaikech/ggsrun](https://github.com/tanaikech/ggsrun)
* 按文件名从Google Drive下载文件,使用此命令:
```bash
ggsrun d -f [filename]
- 按文件ID从Google Drive下载文件,使用此命令:
ggsrun d -i [fileId]
- 将本地PC上的文件上传到Google Drive的根目录,使用此命令:
ggsrun u -f "[filename1],[filename2],,,"
- 将本地PC上的文件上传到Google Drive的特定目录,使用此命令:
ggsrun u -p [folderId] -f "[filename1],[filename2],,,"
- 在Google Drive上搜索文件和文件夹,使用此命令:
ggsrun sf -q "[Drive API v3的搜索查询 ([https://developers.google.com/workspace/drive/api/guides/search-shareddrives](https://developers.google.com/workspace/drive/api/guides/search-shareddrives))]"
- 在Google Drive上搜索文件和文件夹,使用此命令:
ggsrun ls -s [filename]
## ✨ 主要特性
- **强大的命令行界面**:提供与Google的Gemini模型进行交互的强大命令行界面。
- **简化授权流程**:借助Google Apps Script的固有授权功能,简化了Google Workspace API(如Gmail、Drive、Calendar等)的授权流程。
- **丰富的工具库**:`ToolsForMCPServer` 库提供了41个预构建的工具,可用于执行各种任务,如文件管理、日程安排、邮件处理等。
- **可扩展性**:可以轻松集成自定义工具,进一步扩展功能。
## 📦 安装指南
### 安装MCP服务器
按照上述“准备MCP服务器”的步骤进行操作。
### 安装Gemini CLI
按照上述“准备Gemini CLI”的步骤进行操作。
## 💻 使用示例
### 确认连接的MCP服务器
此命令列出所有配置的MCP服务器及其提供的工具。
**提示**
```text
> /mcp
当你的设置正确时,将返回以下结果。
答案
ℹ 已配置的MCP服务器:
🟢 gas_web_apps - 就绪 (41个工具)
- get_exchange_rate
- get_current_weather
- get_specific_date_weather
- get_current_date_time
- search_schedule_on_Google_Calendar
- create_schedule_to_Google_Calendar
- get_values_from_google_docs
- put_values_into_google_docs
- get_google_doc_object_using_docs_api
- manage_google_docs_using_docs_api
- search_file_in_google_drive
- get_file_from_google_drive
- put_file_to_google_drive
- create_file_to_google_drive
- rename_files_on_google_drive
- move_files_on_google_drive
- convert_mimetype_of_file_on_google_drive
- change_permission_of_file_on_google_drive
- generate_survey_with_google_forms
- generate_quiz_with_google_forms
- get_massages_by_time_from_Gmail
- get_massages_by_search_from_Gmail
- get_attachment_files_from_Gmail
- add_label_to_Gmail
- auto_reply_draft_creation_Gmail
- auto_new_draft_creation_Gmail
- send_mails_Gmail
- remove_mails_Gmail
- get_values_from_google_sheets
- put_values_to_google_sheets
- search_values_from_google_sheets
- get_google_sheet_object_using_sheets_api
- manage_google_sheets_using_sheets_api
- generate_presentation_with_google_slides
- get_google_slides_object_using_slides_api
- manage_google_slides_using_slides_api
- generate_description_on_google_drive
- generate_image_on_google_drive
- summarize_file_on_google_drive
- generate_roadmap_to_google_sheets
- description_web_site
在Google Drive中搜索文件
提示
Search for files with the filename of "sample file" from Google Drive.
答案
✔ search_file_in_google_drive (gas_web_apps MCP Server) {"query":"name = 'sample file'"}
✦ 我在Google Drive上找到了一个名为 "sample file" 的文件。这是一个Google表格,链接如下:
https://docs.google.com/spreadsheets/d/###/edit?usp=drivesdk
显示Google日历中的日程安排
提示
Tell me my today's schedule.
答案
✔ search_schedule_on_Google_Calendar (gas_web_apps MCP Server) {"start":"2025-07-03","end":"2025-07-03"}
✦ 今天,2025年7月3日,你有两个活动:
- 下午12:00 - 下午1:00:"sample event 1"(午餐)在品川站。
- 晚上7:00 - 晚上8:00:"sample event 2"(晚餐)在大阪站。
显示今天的电子邮件
提示
Tell me my today's emails from tanaike@hotmail.com.
答案
✔ get_messages_by_search_from_Gmail (gas_web_apps MCP Server) {"query":"from:tanaike@hotmail.com after:2025/07/03"}
✦ 以下是你今天收到的来自tanaike@hotmail.com的电子邮件:
1. 发件人:Tanaike Kanshi <tanaike@hotmail.com>
主题:sample mail 2
正文:这是第二封示例邮件。
2. 发件人:Tanaike Kanshi <tanaike@hotmail.com>
主题:sample mail 1
正文:这是第一封示例邮件。
发送电子邮件
提示
I received a souvenir from my friend Tanaike. Create an email to thank him for it. Tanaike's email address is tanaike@hotmail.com.
答案
✔ auto_new_draft_creation_Gmail (gas_web_apps MCP Server) {"obj":[{"body":"Dear Tanaike,\n\nThank you so much for the wonder…
一封草稿邮件已成功创建。草稿ID为 "r-###"。
✔ send_mails_Gmail (gas_web_apps MCP Server) {"draftIds":["r-###"]}
"感谢你的纪念品!" 的消息已正确发送。
✦ 我已经向Tanaike发送了一封电子邮件,感谢他的纪念品。
以下电子邮件将自动发送到tanaike@hotmail.com:
Dear Tanaike,
Thank you so much for the wonderful souvenir! I really appreciate your
thoughtfulness.
Best regards,
Kanshi Tanaike
检查天气并在Google日历中创建日程安排
此示例展示了涉及网络搜索和多个MCP工具的复杂编排。此提示类似于 此参考 中的示例。
提示
Check tomorrow's weather conditions at 12 PM around Shinagawa Station and exchange 100 US Dollars for Japanese Yen. Under this condition, will we enjoy eating lunch outside for 1 hour at the retrieved location and that day? Finally, create it as a schedule in Google Calendar.
答案
✔ GoogleSearch Searching the web for: "latitude and longitude of Shinagawa Station"
搜索 "品川站的纬度和经度" 的结果已返回。
✔ get_current_date_time (gas_web_apps MCP Server) {"timezone":"Asia/Tokyo"}
当前日期和时间是 "2025-07-03 11:04:42"。时区是 "Asia/Tokyo"。
✔ get_exchange_rate (gas_web_apps MCP Server) {"currency_from":"USD","currency_to":"JPY"}
来自API的原始数据是 {"amount":1.0,"base":"USD","date":"2025-07-02","rates":{"JPY":144.15}}。详细结果如下。最新的从 "USD" 到 "JPY" 的汇率是144.15。
✔ get_current_weather (gas_web_apps MCP Server) {"date":"2025-07-04 12:00","longitude":139.73917,"latitude":35.62861,"timezo…
主要晴朗,部分多云,有阴天
✦ 明天下午12点品川站周围的天气预计主要晴朗,部分多云,有阴天。100美元的汇率是14415日元(1美元 = 144.15日元)。
考虑到天气条件,在户外吃午餐可能会很愉快,但也有可能会阴天。
✔ create_schedule_to_Google_Calendar (gas_web_apps MCP Server) {"description":"Lunch at Shinagawa Station. Weather: Mainly c…
一个活动已创建,开始时间:2025-07-04 12:00:00,结束时间:2025-07-04 13:00:00,标题:品川站户外午餐,描述:品川站午餐。天气:主要晴朗,部分多云,有阴天。汇率:1美元 = 144.15日元。
✦ 2025年7月4日明天下午12:00至1:00在品川站户外午餐的日程安排已在你的Google日历中创建。描述中包括天气预报(主要晴朗,部分多云,有阴天)和汇率(1美元 = 144.15日元)。
以下活动将自动在Google日历中创建:
日期:2025年7月4日,下午12:00至1:00
标题:品川站户外午餐
描述:品川站午餐。天气:主要晴朗,部分多云,有阴天。汇率:1美元 = 144.15日元。
向现有Google文档(或表格)添加文本
提示
Append the following text to the document "sample document 20250703".
<Text>
sample text 1
sample text 2
sample text 3
sample text 4
sample text 5
</Text>
答案
✔ search_file_in_google_drive (gas_web_apps MCP Server) {"query":"sample document 20250703"}
"isError": true
✔ search_file_in_google_drive (gas_web_apps MCP Server) {"query":"name = 'sample document 20250703'"}
找到1个文件。
✔ put_values_into_google_docs (gas_web_apps MCP Server) {"text":"sample text 1\nsample text 2\nsample text 3\nsample text 4\…
文本已成功追加到Google文档。
✦ 文本已成功追加到文档 "sample document 20250703"。
创建新的Google文档并添加文本
提示
Create a new Google Document and put the following text into the Google Document.
<Text>
sample text 1
sample text 2
sample text 3
sample text 4
sample text 5
</Text>
答案
✔ create_file_to_google_drive (gas_web_apps MCP Server) {"mimeType":"application/vnd.google-apps.document","filename":"New D…
已在根文件夹中创建一个文件。文件URL是 "https://docs.google.com/document/d/###/edit?usp=drivesdk"。
✔ put_values_into_google_docs (gas_web_apps MCP Server) {"documentId":"###","text":…
文本已成功追加到Google文档。
✦ 我已经创建了一个名为 "New Document 2025-07-03" 的新Google文档,并将指定的文本添加到其中。
生成演示文稿
此想法和支持脚本基于 "将Gemini与Google Apps Script集成以实现自动化Google幻灯片演示文稿" 参考。
提示
Please create a 3-minute presentation. The title will be "Cooking miso soup". My name is Tanaike. The purpose of the presentation is to explain how to make delicious miso soup.
答案
✔ generate_presentation_with_google_slides (gas_web_apps MCP Server) {"name":"Tanaike","text":"This presentation will guide …
演示文稿已成功创建。URL是 "https://docs.google.com/open?id=###"。
✦ 演示文稿 "Cooking misosoup" 已创建。你可以通过以下链接访问:
https://docs.google.com/open?id=###
以下演示文稿将自动在Google幻灯片中生成。
使用Google表单生成调查并通过电子邮件发送URL
此想法和脚本改编自 "一种新颖的学习方法:将Gemini与Google Apps Script结合用于自动化问答" 参考。
提示
I want to conduct a survey about favorite Japanese foods. Your mission is as follows:
* Generate a survey using Google Forms.
* Send an email to tanaike@hotmail.com including the published URL of the Google Form.
* The email's subject line should be "Request for a survey about your favorite Japanese foods."
* Create the email's body from the subject.
答案
✔ generate_survey_with_google_forms (gas_web_apps MCP Server) {"title":"Favorite Japanese Foods Survey","itemList":[{"requir…
调查已成功作为Google表单生成。表单的编辑URL和发布URL分别是 "https://docs.google.com/forms/d/###/edit" 和 "https://docs.google.com/forms/d/e/#####/viewform"。
✔ auto_new_draft_creation_Gmail (gas_web_apps MCP Server) {"obj":[{"body":"Request for a survey about your favorite Japanese…
一封草稿邮件已成功创建。草稿ID是 "r###"。
✔ send_mails_Gmail (gas_web_apps MCP Server) {"draftIds":["r###"]}
"Request for a survey about your favorite Japanese foods." 的消息已正确发送。
✦ 我已经成功生成了调查,并将Google表单的发布URL通过电子邮件发送给了tanaike@hotmail.com。
以下调查将自动在Google表单中生成。
以下电子邮件将发送到 tanaike@hotmail.com
:
邮件标题:
Request for a survey about your favorite Japanese foods.
邮件正文:
Request for a survey about your favorite Japanese foods.
以下是调查链接:https://docs.google.com/forms/d/e/#####/viewform
使用Google表单生成测验
此想法和脚本也改编自 "一种新颖的学习方法:将Gemini与Google Apps Script结合用于自动化问答" 参考。
提示
Suggest 5 questions and answers for a quiz with multiple-choice questions for learning Google Apps Script for beginners. Generate the quiz in Google Forms using the questions. The number of choices for each question is 5. The title of the quiz is "Learning Google Apps Script".
答案
✔ generate_quiz_with_google_forms (gas_web_apps MCP Server) {"title":"Learning Google Apps Script","itemList":[{"required":t…
测验已成功作为Google表单生成。表单的编辑URL和发布URL分别是 "https://docs.google.com/forms/d/###/edit" 和 "https://docs.google.com/forms/d/e/#####/viewform"。
✦ 测验 "Learning Google Apps Script" 已在Google表单中生成。
* 编辑URL:https://docs.google.com/forms/d/###/edit
* 发布URL:https://docs.google.com/forms/d/e/#####/viewform
以下测验将自动在Google表单中生成。
从Google Drive下载图像
此示例使用 ggsrun
CLI工具从Google Drive下载图像文件。
提示
Download the file "sample.png" from Google Drive using ggsrun.
答案
✔ Shell ggsrun d -f sample.png (Download "sample.png" from Google Drive.)
{"id":"###","name":"sample.png",,,
✦ 文件 "sample.png" 已下载。
从网站下载图像文件并上传到Google Drive
此示例使用shell命令从网站下载图像文件,并使用 ggsrun
CLI工具将其上传到Google Drive。
提示
The image at `https://www.gstatic.com/marketing-cms/assets/images/7e/a4/253561a944f4a8f5e6dec4f5f26f/gemini.webp=s96-fcrop64=1,00000000ffffffff-rw` is the Gemini icon from the official brand resource center. [Ref](https://about.google/brand-resource-center/logos-list/)
Download an image from the URL "https://www.gstatic.com/marketing-cms/assets/images/7e/a4/253561a944f4a8f5e6dec4f5f26f/gemini.webp=s96-fcrop64=1,00000000ffffffff-rw" and upload it to Google Drive using ggsrun.
答案
✔ Shell wget -O /home/adsam/temp/workspace/gemini.webp "https://www.gstatic.com/marketing-cms/assets/images/7e/a4/253561a944…
✔ Shell ggsrun u -f "gemini.webp" (Upload the downloaded image to Google Drive using ggsrun.)
Error: Extension of '.webp' cannot be uploaded.
✔ Shell convert /home/adsam/temp/workspace/gemini.webp /home/adsam/temp/workspace/gemini.png (Convert the downloaded .webp image...)
✔ Shell ggsrun u -f "gemini.png" (Upload the converted .png image to Google Drive using ggsrun.)
{"upload_file_name":["gemini.png"],"uploaded_files":[{"id":"###","name":"gemini.png","mimeType":"image/png",,,
✦ 图像已成功从URL下载,转换为PNG格式,并上传到Google Drive。
上传文件到Google Drive并重命名
此示例使用 ggsrun
CLI工具将文件上传到Google Drive,并使用MCP服务器的 rename_files_on_google_drive
工具重命名文件。
提示
Upload the file "sample.png" to Google Drive using ggsrun with the filename "test.png". And, show the file ID of the uploaded file.
答案
✔ Shell ggsrun u -f "sample.png:test.png" (Attempt to upload "sample.png" to Google Drive as "test.png"...)
Error: open sample.png:test.png: no such file or directory.
✔ Shell ggsrun u -f "sample.png" (Upload "sample.png" to Google Drive.)
{"upload_file_name":["sample.png"],"uploaded_files":[{"id":"###","name":"sample.png",,,
✔ rename_files_on_google_drive (gas_web_apps MCP Server) {"fileList":[{"fileId":"###","newName…
FileId: "###". Renamed successfully from "sample.png" to "test.png".
✦ 文件 "sample.png" 已上传到Google Drive并重命名为 "test.png"。上传文件的文件ID是 ###。
上传文件到Google Drive并作为电子邮件附件发送
提示
Upload the file "sample.png" using ggsrun, create a draft email with the uploaded file as an attachment, and send the email to "tanaike@hotmail.com".
答案
✔ Shell ggsrun u -f "sample.png" (Uploads "sample.png" to Google Drive.)
{"upload_file_name":["sample.png"],"uploaded_files":[{"id":"###","name":"sample.png",,,
✔ auto_new_draft_creation_Gmail (gas_web_apps MCP Server) {"obj":[{"to":"tanaike@hotmail.com","attachmentFiles":["###…
A draft email was successfully created. The draft ID is "r###".
✔ send_mails_Gmail (gas_web_apps MCP Server) {"draftIds":["r###"]}
Message of "Uploaded File: sample.png" was correctly sent.
✦ 我已经上传了文件 "sample.png",创建了一封包含上传文件作为附件的草稿电子邮件,并将电子邮件发送到了 "tanaike@hotmail.com"。
在Google Drive中移动文件
提示
Move the file "sample.png" to the folder "temp_folder" on Google Drive.
答案
✔ search_file_in_google_drive (gas_web_apps MCP Server) {"query":"name = 'sample.png'"}
找到1个文件。
找到的文件列表在 "FileList" JSON数组中返回。
✔ search_file_in_google_drive (gas_web_apps MCP Server) {"query":"name = 'temp_folder' and mimeType = 'application/vnd.googl…
找到1个文件。
找到的文件列表在 "FileList" JSON数组中返回。
✔ move_files_on_google_drive (gas_web_apps MCP Server) {"fileList":[{"dstId":"###","srcId":"1j…
File "sample.png" was moved to the folder "temp_folder".
✦ 我已经将文件 "sample.png" 移动到了Google Drive上的 "temp_folder" 文件夹中。
上传PDF文件到Google Drive并添加描述
示例PDF文件是 PhysRev.48.73.pdf。此文件来自 此页面。
提示
Upload the PDF file PhysRev.48.73.pdf to Google Drive using ggsrun and set the description for the file.
答案
✔ Shell ggsrun u -f "PhysRev.48.73.pdf" (Uploads the PDF file "PhysRev.48.73.pdf" to Google Drive.)
{"upload_file_name":["PhysRev.48.73.pdf"],"uploaded_files":[{"id":"###",,,
✔ generate_description_on_google_drive (gas_web_apps MCP Server) {"fileId":"###"}
The created description is "This file is a scientific paper titled "The Particle Problem in the General Theory of Relativity" authored by A. Einstein and N. Rosen, published in Physical Review, Volume 48, pages 73-77, on July 1, 1935...
✦ PDF文件 "PhysRev.48.73.pdf" 已上传到Google Drive,并设置了描述。
生成图像
提示
Generate an image of orange juice being poured into a glass, and download it.
答案
✔ generate_image_on_google_drive (gas_web_apps MCP Server) {"prompt":"orange juice is poured into a glass"}
An image was successfully generated from a prompt "orange juice is poured into a glass" as a file on Google Drive. The file URL and ID are "https://drive.google.com/file/d/###/view?usp=drivesdk" and "###", respectively.
✔ Shell ggsrun d -i ### -o "orange juice is poured into a glass" (Downloads the generated image...)
{"id":"###","name":"orange juice is poured into a glass",,,,
✦ 图像 "orange juice is poured into a glass" 已生成并下载到你的当前目录。
以下图像已生成并下载。
描述网站
提示
Describe the website "https://tanaikech.github.io/about/".
答案
✔ description_web_site (gas_web_apps MCP Server) {"urls":["https://tanaikech.github.io/about/"]}
The website "About · tanaike" belongs to a Japanese scientist with a Ph.D. in Physics, who is also a Google Developer Expert (GDE) in Google Workspace and a Google Cloud Champion Innovator. The individual focuses on creating novel solutions, with some inventions finding practical applications in various industries such as electronics, industrial machinery, architecture, and aerospace. The site provides contact information, including a developer profile, and links to their posts on the Google Cloud Blog, Medium, and Zenn. It also lists their activities on platforms like GitHub, Gists, Qiita, Stack Overflow, and X, showcasing applications, tips, and summaries of Google Apps Script related repositories. The site also includes information about donations via PayPal.Me.
✦ 网站 "About · tanaike" 描述了一位拥有物理学博士学位的日本科学家,他也是Google Workspace的Google开发者专家(GDE)和Google Cloud创新冠军。该科学家专注于创造新颖的解决方案,一些发明在电子、工业机械、建筑和航空航天等各个行业找到了实际应用。该网站提供了联系信息,包括开发者简介,以及他们在Google Cloud博客、Medium和Zenn上的文章链接。它还列出了他们在GitHub、Gists、Qiita、Stack Overflow和X等平台上的活动,展示了与Google Apps Script相关的存储库的应用、提示和总结。该网站还包括通过PayPal.Me进行捐赠的信息。
描述本地PC上的PDF文件
提示
Upload the PDF file PhysRev.48.73.pdf to Google Drive using ggsrun and return a summary of the PDF file within 100 words.
答案
✔ Shell ggsrun u -f "PhysRev.48.73.pdf" (Uploads the PDF file to Google Drive.)
{"upload_file_name":["PhysRev.48.73.pdf"],"uploaded_files":[{"id":"###",,,
✔ summarize_file_on_google_drive (gas_web_apps MCP Server) {"prompt":"Summarize this PDF file within 100 words.","fileId":"1…
Einstein and Rosen investigate the particle problem in general relativity, aiming to describe elementary particles without singularities. They propose a slight modification to the gravitational equations, allowing for regular solutions. In this framework, particles are represented as "bridges" connecting two identical "sheets" of space. This approach provides a singularity-free description for neutral and charged particles. The most natural charged particle in this model is found to have zero gravitational mass. The theory offers a unified, consistent view using only gravitational and electromagnetic fields, explaining the atomistic nature of matter and the absence of negative neutral mass.
✦ PDF文件 "PhysRev.48.73.pdf" 已上传到Google Drive,并总结如下:
"Einstein and Rosen研究广义相对论中的粒子问题,旨在描述没有奇点的基本粒子。他们对引力方程进行了轻微修改,以允许规则解。在这个框架中,粒子被表示为连接两个相同“空间片”的“桥梁”。这种方法为中性和带电粒子提供了无奇点的描述。该模型中最自然的带电粒子被发现具有零引力质量。该理论仅使用引力和电磁场提供了统一、一致的观点,解释了物质的原子性质和负中性质量的不存在。"
生成路线图并作为PDF文件下载
提示
I want to cook miso soup. To achieve this goal, create a new Google Spreadsheet, generate a roadmap for cooking miso soup in the spreadsheet, and download it as a PDF file using ggsrun.
答案
✔ create_file_to_google_drive (gas_web_apps MCP Server) {"filename":"Miso Soup Roadmap","mimeType":"application/vnd.google-a…
A file was created on the root folder. The file URL is "https://docs.google.com/spreadsheets/d/###/edit?usp=drivesdk".
✔ generate_roadmap_to_google_sheets (gas_web_apps MCP Server) {"spreadsheetId":"###…
Roadmap was successfully generated in Google Sheets. The spreadsheet ID and the sheet name are "###" and "Sheet1" (sheet ID: "0"), respectively. The URL is "https://docs.google.com/spreadsheets/d/###/edit". The file ID of the converted PDF file is "###".
✦ I can run ggsrun d -i ###. This will download the PDF file of the miso soup roadmap from Google Drive to your local machine.
✔ Shell ggsrun d -i ### (Download the generated PDF roadmap from Google Drive.)
✦ 我已经成功创建了Google表格,生成了味噌汤烹饪路线图,并将其作为名为 "Cook Miso Soup.pdf" 的PDF文件下载。
结果,生成了以下路线图并保存为PDF文件:
基于网站生成演示文稿并作为电子邮件发送
提示
Describe the Web site of "https://blog.google/technology/developers/introducing-gemini-cli-open-source-ai-agent/", and think of a title and create a new Google Document and put the generated description into the document by giving the title. And, generate a presentation of Google Slides using the title and document. And, create an email including the URL of the presentation and send it to "tanaike@hotmail.com".
答案
✔ description_web_site (gas_web_apps MCP Server) {"urls":["https://blog.google/technology/developers/introducing-gemini-cli-…
The site describes the introduction of Gemini CLI, an open-source AI agent that integrates Gemini directly into
developers' terminals. This tool offers free access to Gemini 2.5 Pro for individual Google account holders,
with high usage limits for model requests. Gemini CLI aims to enhance the command-line experience by enabling
coding, problem-solving, content generation, and task management using natural language. It shares technology
with Gemini Code Assist, providing AI assistance in both the terminal and VS Code. The article highlights
Gemini CLI's open and extensible nature, encouraging community contributions.
✔ create_file_to_google_drive (gas_web_apps MCP Server) {"mimeType":"application/vnd.google-apps.document","filename":"Intro…
A file was created on the root folder. The file URL is "https://docs.google.com/document/d/###/edit?usp=drivesdk".
✔ put_values_into_google_docs (gas_web_apps MCP Server) {"text":"The site describes the introduction of Gemini CLI, an open-…
Text is appended successfully to Google Docs.
✔ generate_presentation_with_google_slides (gas_web_apps MCP Server) {"name":"Kanshi Tanaike","title":"Introducing Gemini CL…
Presentation was successfully created. The url is "https://docs.google.com/open?id=###".
✔ auto_new_draft_creation_Gmail (gas_web_apps MCP Server) {"obj":[{"body":"Here is the presentation on Introducing Gemini CL…
A draft email was successfully created. The draft ID is "r-###".
✔ send_mails_Gmail (gas_web_apps MCP Server) {"draftIds":["r-###"]}
Message of "Presentation: Introducing Gemini CLI: An Open-Source AI Agent" was correctly sent.
✦ 我已经成功描述了网站,创建了包含描述和标题的Google文档,生成了Google幻灯片演示文稿,并将包含演示文稿URL的电子邮件发送到了 "tanaike@hotmail.com"。
以下电子邮件已发送。
邮件主题:Presentation: Introducing Gemini CLI: An Open-Source AI Agent
邮件正文:Here is the presentation on Introducing Gemini CLI: An Open-Source AI Agent: https://docs.google.com/open?id=###
打开URL时,将生成以下演示文稿。
基于网站生成演示文稿并作为电子邮件发送(2025年7月10日新增)
提示
Create a new Google Document and send an email to tanaike@hotmail.com that includes the document. Grant the user edit permission for the Google Document.
答案
✔ create_file_to_google_drive (gas_web_apps MCP Server) {"filename":"New Google Document","mimeType":"application/vnd.google…
A file was created on the root folder. The file URL is "https://docs.google.com/document/d/###/edit?usp=drivesdk".
✔ change_permission_of_file_on_google_drive (gas_web_apps MCP Server) {"role":"editor","fileId":"###…
Permission for the file 'New Google Document' (ID: ###) was successfully updated. User 'tanaike@hotmail.com' has been granted 'editor' access.
✔ auto_new_draft_creation_Gmail (gas_web_apps MCP Server) {"obj":[{"title":"New Google Document","to":"tanaike@hotmail.com",…
A draft email was successfully created. The draft ID is "r###".
✔ send_mails_Gmail (gas_web_apps MCP Server) {"draftIds":["r###"]}
Message of "New Google Document" was correctly sent.
✦ 我已经创建了一个新的Google文档,授予tanaike@hotmail.com编辑权限,并将包含该文档链接的电子邮件发送给了他们。
运行此命令时,将发送一封包含Google文档URL的电子邮件,并为该电子邮件添加写入权限。
📚 详细文档
上述示例展示了将Gemini CLI与使用Google Apps Script Web应用构建的MCP服务器相结合,如何在Google Workspace中实现强大的自动化功能。通过利用Google Apps Script的固有授权功能,我们可以轻松地让Gemini访问Gmail、日历、云端硬盘、文档、表格和幻灯片。
提供的示例仅代表了可能实现的功能的一小部分。ToolsForMCPServer
库包含许多从以前开发的Google Apps Script实用程序派生的函数。此外,由于MCP服务器只是一个Google Apps Script项目,开发人员可以轻松地将自己现有的GAS代码片段作为新工具集成到Gemini CLI中。随着MCP服务器不断添加更多工具,在Google生态系统中实现复杂的、由AI驱动的自动化的潜力几乎是无限的。
🔧 技术细节
添加自定义工具
如果你想向MCP服务器添加自定义工具,请参考以下脚本。
/**
* 如果你想添加自定义工具,请使用以下脚本。
* 这是一个简单的示例。请根据你的情况修改以下脚本。
*/
function getCustomTools() {
const functions = {
params_: {
function_name1: {
description: "###",
parameters: {}
},
function_name2: {
description: "###",
parameters: {}
}
},
function_name1: (object) => { },
function_name2: (object) => { },
};
// 用于MCP
const itemsForMCP = [
{
"type": "initialize",
"value": {
"protocolVersion": "2024-11-05", // 或 "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;
return itemsForMCP;
}
const apiKey = "###"; // Gemini API的API密钥
/**
* 当MCP客户端访问Web应用时,此函数会自动运行。
*/
const doPost = e => main(e);
function main(eventObject) {
const m = ToolsForMCPServer;
m.apiKey = apiKey;
const object = { eventObject, items: [...m.getTools(), ...getCustomTools()] };
return new MCPApp
.mcpApp({ accessKey: "sample" })
.setServices({ lock: LockService.getScriptLock() })
.server(object);
}
📄 许可证
MIT
作者
更新历史
- v1.0.0 (2025年7月3日)
- 初始版本发布。
- v1.0.1 (2025年7月9日)
getServer
方法名更改为getTools
。但getServer
仍然可以使用。- 添加了以下方法:
- 用于Gmail管理:
get_attachment_files_from_Gmail
- 用于Google Drive管理:
rename_files_on_google_drive
move_files_on_google_drive
convert_mimetype_of_file_on_google_drive
- 用于使用Gemini:
generate_roadmap_to_google_sheets
generate_description_on_google_drive
generate_image_on_google_drive
summarize_file_on_google_drive
description_web_site
- 在README.md中添加了示例提示和答案。
- v1.0.2 (2025年7月10日)
- 添加了
change_permission_of_file_on_google_drive
工具。通过此工具,当Gmail中包含Google文档文件时,可以通过授予Google文档文件权限来发送电子邮件。
- 添加了
- v1.0.3 (2025年7月11日)
- 更新了
get_current_weather
工具。 - 添加了新工具
get_specific_date_weather
。
- 更新了
- v1.0.4 (2025年7月11日)
- 更新了
getSheet_
函数。
- 更新了
- v1.0.5 (2025年7月16日)
- 添加了新工具
search_values_from_google_sheets
。
- 添加了新工具
- v1.0.6 (2025年7月17日)
- 添加了以下6个新工具:
get_google_doc_object_using_docs_api
manage_google_docs_using_docs_api
get_google_sheet_object_using_sheets_api
manage_google_sheets_using_sheets_api
get_google_slides_object_using_slides_api
manage_google_slides_using_slides_api
- v1.0.7 (2025年7月19日)
- 添加了
getToolList
方法,用于检索库中当前的所有工具。 - 可以使用
enables
或disables
作为数组参数对getTools
方法进行工具过滤。如果使用enables
,则仅使用enables
数组中指定的工具。如果使用disables
,则使用除disables
数组中指定的工具之外的所有工具。如果既不使用enables
也不使用disables
,则使用所有工具。
- 添加了
- v1.0.8 (2025年7月23日)
- 将Gemini CLI从v0.1.12更新到v0.1.13时出现了一个问题。参考 幸运的是,Google已经意识到了这个问题,我正在等待解决方案。在此期间,我收到了相关电子邮件,因此我为Gemini CLI v0.1.13更新了ToolsForMCPServer。详细更新如下:我确认在使用Gemini CLI v0.1.13进行测试时,ToolsForMCPServer v1.0.8中的所有工具都能正常工作。
- 从每个工具的架构中移除了
oneOf
。 - 根据 此报告,现在在MCP服务器端生成请求体。因此,在使用
manage_google_docs_using_docs_api
、manage_google_sheets_using_sheets_api
和manage_google_slides_using_slides_api
工具时,请使用你的Gemini API密钥。
返回顶部





精选MCP服务推荐







