- MCP Server for Spanner
MCP Server for Spanner
Content
MCP Server for Spanner
MCP Server for Spanner は、Google Cloud Spanner データベースに接続し、SQL クエリを実行するための Model Context Protocol (MCP) サーバーです。主に AI アシスタントなどが Spanner データベースとの対話を行うためのツールとして機能します。
機能
- SELECT クエリの実行
- データ更新 (INSERT, UPDATE, DELETE) クエリの実行
- DDL (CREATE TABLE, ALTER TABLE など) クエリの実行
- テーブル一覧の取得
- テーブル構造の詳細表示
インストール
前提条件
- Node.js 22 以上
- Spanner エミュレータ もしくは devcontainer を利用可能な環境
セットアップ
# リポジトリのクローン
git clone <repository-url>
cd mcp-server-spanner
# 依存関係のインストール
npm install
# TypeScriptのビルド
npm run build
注: 現在のところ、このツールは Spanner エミュレータへの接続のみをサポートしています。
使用方法
MCP サーバーの一般的な起動方法に準じます。 ここでは、具体的な利用例として Claude Desktop での利用方法と、開発用の MCP Inspector を利用した方法を記載します。
Claude Desktop での設定方法(Mac/Linux)
Claude Desktop の設定より、次の設定の Spanner エミュレータの接続情報部分を編集し、追加します。
"spanner": {
"command": "bash",
"args": [
"YOUR_LOCAL_REPOSITORY_ROOT/bin/mcp-server-spanner",
"--project-id=YOUR_PROJECT_ID",
"--instance-id=YOUR_INSTANCE_ID",
"--database-id=YOUR_DATABASE_ID",
"--api-endpoint=localhost:9010"
],
}
その後、Claude Desktop を再起動してください。
提供されるツール
MCP サーバーとして以下のツールを提供します:
read_query: SELECT クエリを実行list_tables: データベースのテーブル一覧を取得describe_table: 指定されたテーブルの構造を表示execute_ddl: DDL クエリを実行execute_write: 更新系 (INSERT, UPDATE, DELETE) クエリを実行
環境変数
| 環境変数 | 説明 | デフォルト値 |
|---|---|---|
| PROJECT_ID | Google Cloud Project ID | dev-project |
| INSTANCE_ID | Spanner Instance ID | dev-instance |
| DATABASE_ID | Spanner Database ID | dev-database |
| API_ENDPOINT | Spanner API エンドポイント (エミュレータ用) | spanner-emulator:9010 |
| SPANNER_EMULATOR_HOST | Spanner エミュレータのホスト | (API_ENDPOINT から自動設定) |
開発者向け情報
devcontainer での環境構築
本リポジトリは devcontainer での開発に対応しています。 VSCode で本リポジトリをクローン後、コンテナで開いてください。
devcontainer コンテナおよび Spanner エミュレータ、インスタンスおよびデータベースを自動で設定します。
インスペクタの使用
シェルから次のコマンドを実行します。
# MCPプロトコル形式でサーバーを起動
npm run inspect
使用する Spanner エミュレータのエンドポイントは環境変数で指定できます:
# 環境変数で接続情報を指定する例
export PROJECT_ID=your-project-id
export INSTANCE_ID=your-instance-id
export DATABASE_ID=your-database-id
export API_ENDPOINT=localhost:9010
npm run inspect
ライセンス
MIT
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Serper MCP ServerA Serper MCP Server
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.
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.
WindsurfThe new purpose-built IDE to harness magic
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
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
DeepChatYour AI Partner on Desktop
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
ChatWiseThe second fastest AI chatbot™
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Playwright McpPlaywright MCP server
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
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"
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Tavily Mcp