home / mcp / google spanner mcp server

Google Spanner MCP Server

Provides read-only access to live Google Spanner data via MCP for natural-language querying.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "cdatasoftware-google-spanner-mcp-server-by-cdata": {
      "command": "java",
      "args": [
        "-jar",
        "/PATH/TO/CDataMCP-jar-with-dependencies.jar",
        "/PATH/TO/google-spanner.prp"
      ]
    }
  }
}

You run a local MCP server that exposes live Google Spanner data through a simple MCP interface. This lets you ask natural-language questions and receive up-to-date results without writing SQL, using the CData JDBC Driver under the hood. The server is read-only by default, designed for querying data on the fly from Google Spanner.

How to use

You connect an MCP-compatible client (such as Claude Desktop) to the Google Spanner MCP server to query your data. The server exposes a small set of tools that let you discover what data is available and to run read-only queries. You do not need to write SQL to fetch data; instead, you can ask natural-language questions and the client translates them into the appropriate queries.

How to install

# Prerequisites
- Java Runtime Environment (JRE) 8+ or JDK 8+
- Maven for building the MCP server

# 1) Clone the project
git clone https://github.com/cdatasoftware/google-spanner-mcp-server-by-cdata.git
cd google-spanner-mcp-server-by-cdata

# 2) Build the server
mvn clean install
# This creates the JAR: CDataMCP-jar-with-dependencies.jar
# 3) Install the CData JDBC Driver for Google Spanner
# Download from: https://www.cdata.com/drivers/googlespanner/download/jdbc

# 4) License the driver
# Locate the lib directory of the driver installation and run the license command
# Example (adjust paths to your environment)
java -jar cdata.jdbc.googlespanner.jar --license
# Enter your name, email, and TRIAL (or your license key)
# 5) Configure your connection to Google Spanner (example below)
java -jar cdata.jdbc.googlespanner.jar
# Use the Connection String utility, Test Connection, then copy the resulting JDBC URL
# 6) Create a .prp file for the JDBC connection (google-spanner.prp)
# Example content
Prefix=googlespanner
ServerName=CDataGoogleSpanner
ServerVersion=1.0
DriverPath=PATH\\TO\\cdata.jdbc.googlespanner.jar
DriverClass=cdata.jdbc.googlespanner.GoogleSpannerDriver
JdbcUrl=jdbc:googlespanner:InitiateOAuth=GETANDREFRESH;
Tables=
# 7) Start the MCP server using the prepared .prp file
java -jar /PATH/TO/CDataMCP-jar-with-dependencies.jar /PATH/TO/google-spanner.prp
```
Note: The server runs using stdio, so it is intended for use with clients that run on the same machine as the server.

Additional configuration and notes

The MCP server is designed to be run locally with a single configuration file that points to the JDBC driver and connection details. Ensure the path to the JAR and the path to your .prp file are correct. If your data source requires OAuth, complete authentication in the browser during the connection setup.

Troubleshooting

If you cannot see the MCP server in your client, ensure you have fully quit and restarted the client so the new server plugin is loaded. Double-check that the .prp file contains a valid JdbcUrl and that the driver JAR path is correct. If you encounter connection errors, re-run the Connection String utility and copy a fresh JDBC URL into the .prp file.

Security and usage notes

This server is configured for read-only access by default to prevent accidental data modification. If you need write capabilities, a separate server with write permissions should be used, following the appropriate configuration and licensing steps.

API and tools available

The MCP server exposes a small set of tools for interacting with the data source. The core tools are: - googlespanner_get_tables - Retrieves a list of tables available in the Google Spanner data source. The output is in CSV format with column headers on the first line. - googlespanner_get_columns - Retrieves a list of columns for a specified table. The output is in CSV format with column headers on the first line. - googlespanner_run_query - Executes a SQL SELECT query and returns results.

Concrete MCP server configuration

{
  "mcpServers": {
    "googlespanner": {
      "type": "stdio",
      "name": "googlespanner",
      "command": "java",
      "args": [
        "-jar",
        "/PATH/TO/CDataMCP-jar-with-dependencies.jar",
        "/PATH/TO/google-spanner.prp"
      ]
    }
  }
}

Notes on tools and usage patterns

After configuring, ask your MCP-enabled AI client to query your Google Spanner data. Typical usage involves asking questions like which accounts exist, how many rows match specific criteria, or what trends appear in a given dataset. The tools will handle listing tables, listing columns, and executing select queries under the hood.

Available tools

google_spanner_get_tables

Retrieves a list of available tables in the Google Spanner data source. Output is CSV with headers.

google_spanner_get_columns

Retrieves a list of columns for a specified table. Output is CSV with headers.

google_spanner_run_query

Executes a SQL SELECT query against Google Spanner and returns results.