spanner-mcp-server
Provides read-only query execution and schema introspection (tables, indexes, DDL) for a single Google Cloud Spanner database.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@spanner-mcp-serverlist all tables in the database"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
spanner-mcp-server
A Model Context Protocol (MCP) server that exposes schema introspection and read-only queries for a single Google Cloud Spanner instance and database. Authentication uses a Google Service Account JSON key file.
Built with Node.js 24+, TypeScript, and well-established packages:
@modelcontextprotocol/sdk— MCP server (stdio transport)@google-cloud/spanner— official Cloud Spanner clientzod— configuration & input validation
Safety model
Every query runs inside a Spanner read-only snapshot transaction, so the API
cannot mutate data regardless of the SQL submitted. As defence-in-depth, a
SQL guard rejects anything that is not a single SELECT/WITH statement
(comments and string literals are stripped before keyword analysis, and multiple
statements are refused). Grant the service account only the
Cloud Spanner Database Reader (roles/spanner.databaseReader) role.
Related MCP server: BigQuery MCP Server
Tools
Tool | Arguments | Description |
| — | Target project/instance/database and SQL dialect. |
| — | Full DDL ( |
| — | User tables and views, with interleave parents. |
|
| Columns: name, type, nullability, generated. |
|
| Indexes and their key columns. |
|
| Runs a read-only query; rows returned as JSON. |
Results from spanner_execute_query are capped at SPANNER_MAX_ROWS; the
response includes a truncated flag when the cap is reached.
Configuration
Set via environment variables (see .env.example):
Variable | Required | Default | Description |
| ✅ | — | Path to the service account JSON key file. |
| ✅ | — | Target Spanner instance id. |
| ✅ | — | Target Spanner database id. |
| — | project from key file | GCP project id. |
| — |
| Max rows returned per query. |
| — |
| Per-query timeout (ms). |
Both GoogleSQL and PostgreSQL dialect databases are supported; the
dialect is detected at startup and query parameters are adapted automatically
(@name for GoogleSQL, $1 for PostgreSQL).
Install & build
npm install
npm run buildRun
# For local development (loads .env, runs TypeScript directly):
npm run dev
# Production (after `npm run build`):
node dist/index.jsThe server speaks MCP over stdio; protocol traffic uses stdout and all logs go to stderr.
Use with an MCP client
Example client configuration (e.g. Claude Desktop / any MCP-compatible host):
{
"mcpServers": {
"spanner": {
"command": "node",
"args": ["/absolute/path/to/spanner-mcp-server/dist/index.js"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/absolute/path/to/service-account.json",
"SPANNER_PROJECT_ID": "my-gcp-project",
"SPANNER_INSTANCE_ID": "my-instance",
"SPANNER_DATABASE_ID": "my-database"
}
}
}
}Example query call
// tool: spanner_execute_query
{
"sql": "SELECT SingerId, FirstName FROM Singers WHERE SingerId = @id",
"params": { "id": 1 }
}Project layout
src/
index.ts # stdio entrypoint & lifecycle
server.ts # MCP server + tool registration
spanner.ts # Spanner client wrapper (schema + read-only queries)
config.ts # environment validation (zod)
sql-guard.ts # read-only SQL statement guardLicense
MIT
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/catalyst-edu-llc/spanner-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server