singlestore mcp server
A server for interacting with SingleStore databases, enabling table querying, schema descriptions, and ER diagram generation with secure SSL support and TypeScript safety.
A server for interacting with SingleStore databases, enabling table querying, schema descriptions, and ER diagram generation with secure SSL support and TypeScript safety.
A Model Context Protocol (MCP) server for interacting with SingleStore databases. This server provides tools for querying tables, describing schemas, and generating ER diagrams.
To install SingleStore MCP Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @madhukarkumar/singlestore-mcp-server --client claude
Clone the repository:
git clone <repository-url>
cd mcp-server-singlestore
Install dependencies:
npm install
Build the server:
npm run build
The server requires the following environment variables for database connection:
SINGLESTORE_HOST=your-host.singlestore.com
SINGLESTORE_PORT=3306
SINGLESTORE_USER=your-username
SINGLESTORE_PASSWORD=your-password
SINGLESTORE_DATABASE=your-database
All these environment variables are required for the server to establish a connection to your SingleStore database. The connection uses SSL with the SingleStore CA bundle, which is automatically fetched from the SingleStore portal.
For SSE (Server-Sent Events) protocol support:
SSE_ENABLED=true # Enable the SSE HTTP server (default: false if not set)
SSE_PORT=3333 # HTTP port for the SSE server (default: 3333 if not set)
In Your Shell: Set the variables in your terminal before running the server:
export SINGLESTORE_HOST=your-host.singlestore.com
export SINGLESTORE_PORT=3306
export SINGLESTORE_USER=your-username
export SINGLESTORE_PASSWORD=your-password
export SINGLESTORE_DATABASE=your-database
In Client Configuration Files: Add the variables to your MCP client configuration file as shown in the integration sections below.
This server supports two protocols for client integration:
Both protocols expose the same tools and functionality, allowing you to choose the best integration method for your use case.
No parameters required
use_mcp_tool({
server_name: "singlestore",
tool_name: "list_tables",
arguments: {}
})
query_table
Parameters:
use_mcp_tool({
server_name: "singlestore",
tool_name: "query_table",
arguments: {
query: "SELECT * FROM your_table LIMIT 5"
}
})
describe_table
Parameters:
use_mcp_tool({
server_name: "singlestore",
tool_name: "describe_table",
arguments: {
table: "your_table"
}
})
generate_er_diagram
No parameters required
use_mcp_tool({
server_name: "singlestore",
tool_name: "generate_er_diagram",
arguments: {}
})
run_read_query
Parameters:
use_mcp_tool({
server_name: "singlestore",
tool_name: "run_read_query",
arguments: {
query: "SELECT * FROM your_table LIMIT 5"
}
})
create_table
Parameters:
use_mcp_tool({
server_name: "singlestore",
tool_name: "create_table",
arguments: {
table_name: "new_table",
columns: [
{
name: "id",
type: "INT",
nullable: false,
auto_increment: true
},
{
name: "name",
type: "VARCHAR(255)",
nullable: false
}
],
table_options: {
shard_key: ["id"],
sort_key: ["name"]
}
}
})
generate_synthetic_data
Parameters:
use_mcp_tool({
server_name: "singlestore",
tool_name: "generate_synthetic_data",
arguments: {
table: "customers",
count: 1000,
column_generators: {
"customer_id": {
"type": "sequence",
"start": 1000
},
"status": {
"type": "values",
"values": ["active", "inactive", "pending"]
},
"signup_date": {
"type": "formula",
"formula": "NOW() - INTERVAL FLOOR(RAND() * 365) DAY"
}
},
batch_size: 500
}
})
optimize_sql
use_mcp_tool({
server_name: "singlestore",
tool_name: "optimize_sql",
arguments: {
query: "SELECT * FROM customers JOIN orders ON customers.id = orders.customer_id WHERE region = 'west'"
}
})
Build the server:
npm run build
Run the server with MCP protocol only:
node build/index.js
Run the server with both MCP and SSE protocols:
SSE_ENABLED=true SSE_PORT=3333 node build/index.js
When SSE is enabled, the server exposes the following HTTP endpoints:
Root Endpoint
GET /
Returns server information and available endpoints.
Health Check
GET /health
Returns status information about the server.
SSE Connection
GET /sse
Establishes a Server-Sent Events connection for real-time updates.
List Tools
GET /tools
Returns a list of all available tools, same as the MCP list_tools
functionality.
Also supports POST requests for MCP Inspector compatibility:
POST /tools
Content-Type: application/json
{
"jsonrpc": "2.0",
"id": "request-id",
"method": "mcp.list_tools",
"params": {}
}
Call Tool
POST /call-tool
Content-Type: application/json
{
"name": "tool_name",
"arguments": {
"param1": "value1",
"param2": "value2"
},
"client_id": "optional_sse_client_id_for_streaming_response"
}
Executes a tool with the provided arguments.
If client_id
is provided, the response is streamed to that SSE client.
client_id
is omitted, the response is returned directly in the HTTP response.Also supports standard MCP format for MCP Inspector compatibility:
POST /call-tool
Content-Type: application/json
{
"jsonrpc": "2.0",
"id": "request-id",
"method": "mcp.call_tool",
"params": {
"name": "tool_name",
"arguments": {
"param1": "value1",
"param2": "value2"
},
"_meta": {
"client_id": "optional_sse_client_id_for_streaming_response"
}
}
}
When using SSE connections, the server sends the following event types:
All events follow the JSON-RPC 2.0 format used by the MCP protocol. The system uses the standard message
event type for compatibility with the MCP Inspector and most SSE client libraries.
// Connect to SSE endpoint
const eventSource = new EventSource('http://localhost:3333/sse');
let clientId = null;
// Handle connection establishment via unnamed event
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === 'connection_established') {
clientId = data.clientId;
console.log(`Connected with client ID: ${clientId}`);
}
};
// Handle open event
eventSource.addEventListener('open', (event) => {
console.log('SSE connection opened via open event');
});
// Handle all MCP messages
eventSource.addEventListener('message', (event) => {
const data = JSON.parse(event.data);
if (data.jsonrpc === '2.0') {
if (data.result) {
console.log('Tool result:', data.result);
} else if (data.error) {
console.error('Tool error:', data.error);
} else if (data.method === 'mcp.call_tool.update') {
console.log('Tool update:', data.params);
}
}
});
// Call a tool with streaming response (custom format)
async function callTool(name, args) {
const response = await fetch('http://localhost:3333/call-tool', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: name,
arguments: args,
client_id: clientId
})
});
return response.json();
}
// Call a tool with streaming response (MCP format)
async function callToolMcp(name, args) {
const response = await fetch('http://localhost:3333/call-tool', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 'request-' + Date.now(),
method: 'mcp.call_tool',
params: {
name: name,
arguments: args,
_meta: {
client_id: clientId
}
}
})
});
return response.json();
}
// Example usage
callTool('list_tables', {})
.then(response => console.log('Request accepted:', response));
The MCP Inspector is a browser-based tool for testing and debugging MCP servers. To use it with this server:
npm run inspector
Or start just the server with:
npm run start:inspector
npx @modelcontextprotocol/inspector
The inspector will open in your default browser.
a. Enter the URL in the connection field:
http://localhost:8081
Note: The actual port may vary depending on your configuration. Check the server
startup logs for the actual port being used. The server will output:
```
MCP SingleStore SSE server listening on port XXXX
```
b. Make sure "SSE" is selected as the transport type
c. Click "Connect"
a. Try connecting to a specific endpoint:
http://localhost:8081/stream
b. Try using your machine's actual IP address:
http://192.168.1.x:8081
c. If running in Docker:
http://host.docker.internal:8081
a. Verify the server is running by visiting http://localhost:8081 in your browser
b. Check the server logs for connection attempts
c. Try restarting both the server and inspector
d. Make sure no other service is using port 8081
e. Test SSE connection with the provided script:
npm run test:sse
Or manually with curl:
```bash
curl -N http://localhost:8081/sse
```
f. Verify your firewall settings allow connections to port 8081
⚠️ Note: When using the MCP Inspector, you must use the full URL, including the http://
prefix.
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%Claudeclaude_desktop_config.json
{
"mcpServers": {
"singlestore": {
"command": "node",
"args": ["path/to/mcp-server-singlestore/build/index.js"],
"env": {
"SINGLESTORE_HOST": "your-host.singlestore.com",
"SINGLESTORE_PORT": "3306",
"SINGLESTORE_USER": "your-username",
"SINGLESTORE_PASSWORD": "your-password",
"SINGLESTORE_DATABASE": "your-database",
"SSE_ENABLED": "true",
"SSE_PORT": "3333"
}
}
}
}
The SSE_ENABLED and SSE_PORT variables are optional. Include them if you want to enable the HTTP server with SSE support alongside the standard MCP protocol.
Restart the Claude Desktop App
In your conversation with Claude, you can now use the SingleStore MCP server with:
use_mcp_tool({
server_name: "singlestore",
tool_name: "list_tables",
arguments: {}
})
~/Library/Application Support/Windsurf/config.json
%APPDATA%Windsurfconfig.json
{
"mcpServers": {
"singlestore": {
"command": "node",
"args": ["path/to/mcp-server-singlestore/build/index.js"],
"env": {
"SINGLESTORE_HOST": "your-host.singlestore.com",
"SINGLESTORE_PORT": "3306",
"SINGLESTORE_USER": "your-username",
"SINGLESTORE_PASSWORD": "your-password",
"SINGLESTORE_DATABASE": "your-database",
"SSE_ENABLED": "true",
"SSE_PORT": "3333"
}
}
}
}
The SSE_ENABLED and SSE_PORT variables are optional, but enable additional functionality through the SSE HTTP server.
Restart Windsurf
In your conversation with Claude in Windsurf, the SingleStore MCP tools will be available automatically when Claude needs to access database information.
{
"singlestore": {
"command": "node",
"args": ["path/to/mcp-server-singlestore/build/index.js"],
"env": {
"SINGLESTORE_HOST": "your-host.singlestore.com",
"SINGLESTORE_PORT": "3306",
"SINGLESTORE_USER": "your-username",
"SINGLESTORE_PASSWORD": "your-password",
"SINGLESTORE_DATABASE": "your-database",
"SSE_ENABLED": "true",
"SSE_PORT": "3333"
}
}
}
The SSE_ENABLED and SSE_PORT variables allow web applications to connect to the server via HTTP and receive real-time updates through Server-Sent Events.
Restart Cursor
When using Claude AI within Cursor, the SingleStore MCP tools will be available for database operations.
mcp-server-singlestore/
├── src/
│ └── index.ts # Main server implementation
├── package.json
├── tsconfig.json
├── README.md
└── CHANGELOG.md
npm run build
npm test
Check your firewall settings to allow outbound connections to your SingleStore database
Build Issues
Check Node.js version compatibility (should be 16+)
MCP Integration Issues
MIT License - see LICENSE file for details
[
{
"description": "Generate a Mermaid ER diagram of the database schema",
"inputSchema": {
"properties": {},
"required": [],
"type": "object"
},
"name": "generate_er_diagram"
},
{
"description": "List all tables in the database",
"inputSchema": {
"properties": {},
"required": [],
"type": "object"
},
"name": "list_tables"
},
{
"description": "Execute a query on a table",
"inputSchema": {
"properties": {
"query": {
"description": "SQL query to execute",
"type": "string"
}
},
"required": [
"query"
],
"type": "object"
},
"name": "query_table"
},
{
"description": "Get detailed information about a table",
"inputSchema": {
"properties": {
"table": {
"description": "Name of the table to describe",
"type": "string"
}
},
"required": [
"table"
],
"type": "object"
},
"name": "describe_table"
},
{
"description": "Execute a read-only (SELECT) query on the database",
"inputSchema": {
"properties": {
"query": {
"description": "SQL SELECT query to execute",
"type": "string"
}
},
"required": [
"query"
],
"type": "object"
},
"name": "run_read_query"
},
{
"description": "Create a new table in the database with specified columns and constraints",
"inputSchema": {
"properties": {
"columns": {
"description": "List of columns to create",
"items": {
"properties": {
"auto_increment": {
"description": "Whether the column should auto increment",
"type": "boolean"
},
"default": {
"description": "Default value for the column",
"type": "string"
},
"name": {
"description": "Column name",
"type": "string"
},
"nullable": {
"description": "Whether the column can be NULL",
"type": "boolean"
},
"type": {
"description": "Data type (e.g., INT, VARCHAR(255), etc.)",
"type": "string"
}
},
"required": [
"name",
"type"
],
"type": "object"
},
"type": "array"
},
"table_name": {
"description": "Name of the table to create",
"type": "string"
},
"table_options": {
"properties": {
"auto_increment_start": {
"description": "Starting value for auto increment columns",
"type": "number"
},
"compression": {
"description": "Table compression type",
"enum": [
"SPARSE"
],
"type": "string"
},
"is_reference": {
"description": "Whether this is a reference table",
"type": "boolean"
},
"shard_key": {
"description": "Columns to use as shard key",
"items": {
"type": "string"
},
"type": "array"
},
"sort_key": {
"description": "Columns to use as sort key",
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
}
},
"required": [
"table_name",
"columns"
],
"type": "object"
},
"name": "create_table"
},
{
"description": "Generate and insert synthetic data into an existing table",
"inputSchema": {
"properties": {
"batch_size": {
"default": 1000,
"description": "Number of rows to insert in each batch",
"type": "number"
},
"column_generators": {
"additionalProperties": {
"properties": {
"end": {
"description": "Ending value for random number generator",
"type": "number"
},
"formula": {
"description": "SQL expression for formula generator",
"type": "string"
},
"start": {
"description": "Starting value for sequence generator",
"type": "number"
},
"type": {
"description": "Type of generator to use",
"enum": [
"sequence",
"random",
"values",
"formula"
],
"type": "string"
},
"values": {
"description": "Array of values to choose from for values generator",
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"description": "Custom generators for specific columns (optional)",
"type": "object"
},
"count": {
"default": 100,
"description": "Number of rows to generate and insert",
"type": "number"
},
"table": {
"description": "Name of the table to insert data into",
"type": "string"
}
},
"required": [
"table"
],
"type": "object"
},
"name": "generate_synthetic_data"
},
{
"description": "Analyze a SQL query using PROFILE and provide optimization recommendations",
"inputSchema": {
"properties": {
"query": {
"description": "SQL query to analyze and optimize",
"type": "string"
}
},
"required": [
"query"
],
"type": "object"
},
"name": "optimize_sql"
}
]