一个简单的 MCP 服务器,提供用于处理 Google 表格和 Google 表单的工具、资源和提示。
list_spreadsheets - 列出你的 Google 表格read_sheet - 从 Google 表格读取数据write_sheet - 向 Google 表格写入数据append_sheet - 追加数据到 Google 表格create_spreadsheet - 创建新的表格create_form - 创建新的 Google 表单sheet://{spreadsheet_id}/{range_name} - 作为资源访问表格数据analyze_sheet_data - 分析表格数据的模板create_report_template - 创建报告表格的模板form_to_sheet - 表单到表格的工作流程模板cd gsheets-mcp-server
python -m venv .venv
source .venv/bin/activate # 在 Windows 上:.venv\Scripts\activate
pip install -r requirements.txt
credentials.jsonnpx @modelcontextprotocol/inspector python gsheets_server.py
在你的 Claude Desktop 配置文件中添加以下内容:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"gsheets": {
"command": "python",
"args": [
"/FULL/PATH/TO/gsheets-mcp-server/gsheets_server.py"
],
"env": {
"GOOGLE_CREDENTIALS_PATH": "/FULL/PATH/TO/gsheets-mcp-server/credentials.json"
}
}
}
}
重要: 将 /FULL/PATH/TO/ 替换为该目录的实际绝对路径。
首次运行时,服务器会打开浏览器窗口进行 Google 身份验证。授权应用程序后,将创建一个 token.pickle 文件以存储您的凭据供将来使用。
配置完成后,您可以向 Claude 发出如下请求:
表格 ID 在 URL 中:
https://docs.google.com/spreadsheets/d/SPREADSHEET_ID_HERE/edit
token.pickle 并重新运行