Sponsored by Deepsite.site

Spreadsheet MCP Server

Created By
Ryo-Muramatsu8 months ago
Content

Spreadsheet MCP Server

このプロジェクトは、Google SpreadsheetのデータにアクセスするためのModel Context Protocol (MCP) サーバーです。LLMがスプレッドシート情報を直接利用できるようにします。

機能

  • スプレッドシートの基本情報(シート一覧など)の取得
  • 特定シートのデータの取得とマークダウン形式での整形
  • MCPクライアント(Claude for Desktopなど)と統合

インストール

# リポジトリのクローン
git clone https://github.com/your-username/spreadsheet-mcp-server.git
cd spreadsheet-mcp-server

# 依存関係のインストール
npm install

# 環境変数の設定
cp .env.example .env
# .envファイルを編集してGAS_WEB_APP_URLとGAS_API_KEYを設定

# ビルド
npm run build

環境変数の設定

サーバーの設定には、以下の環境変数が使用されます:

  • GAS_WEB_APP_URL: Google Apps Script Web AppのURL
  • GAS_API_KEY: Google Apps Script Web Appのアクセス用APIキー

これらの環境変数は .env ファイルに設定できます:

GAS_WEB_APP_URL=https://script.google.com/macros/s/your-deployment-id/exec
GAS_API_KEY=your-api-key

環境変数が設定されていない場合、サーバーはモックモードで動作し、実際のGoogleスプレッドシートにはアクセスしません。

使用方法

スタンドアロンでの起動

npm start

Claude for Desktopとの統合

Claude for Desktopの設定ファイル (claude_desktop_config.json) に以下を追加します:

{
  "mcpServers": {
    "spreadsheet": {
      "command": "node",
      "args": ["<absolute-path-to-project>/build/index.js"]
    }
  }
}

環境変数を設定するには、以下のようにenvフィールドを追加します:

{
  "mcpServers": {
    "spreadsheet": {
      "command": "node",
      "args": ["<absolute-path-to-project>/build/index.js"],
      "env": {
        "GAS_WEB_APP_URL": "https://script.google.com/macros/s/your-deployment-id/exec",
        "GAS_API_KEY": "your-api-key"
      }
    }
  }
}

設定ファイルは以下の場所にあります:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %AppData%\\Claude\\claude_desktop_config.json

MCP Inspectorでテスト

npx @modelcontextprotocol/inspector node build/index.js

提供するツール

getSpreadsheet

スプレッドシートの基本情報と含まれるシート一覧を取得します。

入力パラメータ:

  • url: スプレッドシートのURL

出力:

  • スプレッドシート名、ID、シート一覧(行数・列数を含む)

getSheetData

スプレッドシートの特定シートのデータを取得します。

入力パラメータ:

  • url: スプレッドシートのURL
  • sheetName: 取得するシート名

出力:

  • シートデータ(マークダウンテーブル形式)

開発

プロジェクト構造

src/
├── index.ts           # エントリポイント
├── server.ts          # MCPサーバー設定
├── config.ts          # 環境変数と設定管理
├── tools/             # ツール実装
│   ├── getSpreadsheet.ts
│   ├── getSheetData.ts
│   └── index.ts
├── api/               # API処理
│   ├── README.md      # API仕様
│   ├── spreadsheet.ts
│   └── types.ts
└── utils/             # ユーティリティ
    └── format.ts

テスト

# 単体テスト実行
npm test

# ウォッチモードでテスト
npm run test:watch

Google Apps Scriptとの連携について

このサーバーは、実際の使用時にはGoogle Apps ScriptのWeb Appと連携して動作します:

  1. Google Apps ScriptでWeb Appを作成する
  2. Webアプリ側でスプレッドシートにアクセスするAPIを実装する(api/README.md参照)
  3. APIキーを設定し、環境変数GAS_WEB_APP_URLGAS_API_KEYで連携する

このアプローチにより、Google認証フローを回避し、スプレッドシートのセキュリティを維持できます。

環境変数が設定されていない場合は、モックモードで動作し、テスト用のデータが返されます。

ライセンス

MIT

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Tavily Mcp
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Playwright McpPlaywright MCP server
WindsurfThe new purpose-built IDE to harness magic
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
CursorThe AI Code Editor
Amap Maps高德地图官方 MCP Server
ChatWiseThe second fastest AI chatbot™
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
DeepChatYour AI Partner on Desktop
Serper MCP ServerA Serper MCP Server
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.