SingleStore MCP Server

平台与服务

by madhukarkumar

通过标准化协议与 SingleStore 数据库交互,可执行查询、查看 schema,并轻松生成 ER 图。

什么是 SingleStore MCP Server

通过标准化协议与 SingleStore 数据库交互,可执行查询、查看 schema,并轻松生成 ER 图。

核心功能 (8 个工具)

generate_er_diagram

Generate a Mermaid ER diagram of the database schema

list_tables

List all tables in the database

query_table

Execute a query on a table

describe_table

Get detailed information about a table

run_read_query

Execute a read-only (SELECT) query on the database

create_table

Create a new table in the database with specified columns and constraints

generate_synthetic_data

Generate and insert synthetic data into an existing table

optimize_sql

Analyze a SQL query using PROFILE and provide optimization recommendations

README

SingleStore MCP Server

smithery badge

A Model Context Protocol (MCP) server for interacting with SingleStore databases. This server provides tools for querying tables, describing schemas, and generating ER diagrams.

Features

  • List all tables in the database
  • Execute custom SQL queries
  • Get detailed table information including schema and sample data
  • Generate Mermaid ER diagrams of database schema
  • SSL support with automatic CA bundle fetching
  • Proper error handling and TypeScript type safety

Prerequisites

  • Node.js 16 or higher
  • npm or yarn
  • Access to a SingleStore database
  • SingleStore CA bundle (automatically fetched from portal)

Installation

Installing via Smithery

To install SingleStore MCP Server for Claude Desktop automatically via Smithery:

bash
npx -y @smithery/cli install @madhukarkumar/singlestore-mcp-server --client claude
  1. Clone the repository:
bash
git clone <repository-url>
cd mcp-server-singlestore
  1. Install dependencies:
bash
npm install
  1. Build the server:
bash
npm run build

Environment Variables

Required Environment Variables

The server requires the following environment variables for database connection:

env
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.

Optional Environment Variables

For SSE (Server-Sent Events) protocol support:

env
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)

Setting Environment Variables

  1. In Your Shell: Set the variables in your terminal before running the server:

    bash
    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
    
  2. In Client Configuration Files: Add the variables to your MCP client configuration file as shown in the integration sections below.

Usage

Protocol Support

This server supports two protocols for client integration:

  1. MCP Protocol: The standard Model Context Protocol using stdio communication, used by Claude Desktop, Windsurf, and Cursor.
  2. SSE Protocol: Server-Sent Events over HTTP for web-based clients and applications that need real-time data streaming.

Both protocols expose the same tools and functionality, allowing you to choose the best integration method for your use case.

Available Tools

  1. list_tables

    • Lists all tables in the database
    • No parameters required
    typescript
    use_mcp_tool({
      server_name: "singlestore",
      tool_name: "list_tables",
      arguments: {}
    })
    
  2. query_table

    • Executes a custom SQL query
    • Parameters:
      • query: SQL query string
    typescript
    use_mcp_tool({
      server_name: "singlestore",
      tool_name: "query_table",
      arguments: {
        query: "SELECT * FROM your_table LIMIT 5"
      }
    })
    
  3. describe_table

    • Gets detailed information about a table
    • Parameters:
      • table: Table name
    typescript
    use_mcp_tool({
      server_name: "singlestore",
      tool_name: "describe_table",
      arguments: {
        table: "your_table"
      }
    })
    
  4. generate_er_diagram

    • Generates a Mermaid ER diagram of the database schema
    • No parameters required
    typescript
    use_mcp_tool({
      server_name: "singlestore",
      tool_name: "generate_er_diagram",
      arguments: {}
    })
    
  5. run_read_query

    • Executes a read-only (SELECT) query on the database
    • Parameters:
      • query: SQL SELECT query to execute
    typescript
    use_mcp_tool({
      server_name: "singlestore",
      tool_name: "run_read_query",
      arguments: {
        query: "SELECT * FROM your_table LIMIT 5"
      }
    })
    
  6. create_table

    • Create a new table in the database with specified columns and constraints
    • Parameters:
      • table_name: Name of the table to create
      • columns: Array of column definitions
      • table_options: Optional table configuration
    typescript
    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"]
        }
      }
    })
    
  7. generate_synthetic_data

    • Generate and insert synthetic data into an existing table
    • Parameters:
      • table: Name of the table to insert data into
      • count: Number of rows to generate (default: 100)
      • column_generators: Custom generators for specific columns
      • batch_size: Number of rows to insert in each batch (default: 1000)
    typescript
    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
      }
    })
    
  8. optimize_sql

    • Analyze a SQL query using PROFILE and provide optimization recommendations
    • Parameters:
      • query: SQL query to analyze and optimize
    typescript
    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'"
      }
    })
    
    • The response includes:
      • Original query
      • Performance profile summary (total runtime, compile time, execution time)
      • List of detected bottlenecks
      • Optimization recommendations with impact levels (high/medium/low)
      • Suggestions for indexes, joins, memory usage, and other optimizations

Running Standalone

  1. Build the server:
bash
npm run build
  1. Run the server with MCP protocol only:
bash
node build/index.js
  1. Run the server with both MCP and SSE protocols:
bash
SSE_ENABLED=true SSE_PORT=3333 node build/index.js

Using the SSE Protocol

When SSE is enabled, the server exposes the following HTTP endpoints:

  1. Root Endpoint

    code
    GET /
    

    Returns server information and available endpoints.

  2. Health Check

    code
    GET /health
    

    Returns status information about the server.

  3. SSE Connection

    code
    GET /sse
    

    Establishes a Server-Sent Events connection for real-time updates.

  4. List Tools

    code
    GET /tools
    

    Returns a list of all available tools, same as the MCP list_tools functionality.

    Also supports POST requests for MCP Inspector compatibility:

    code
    POST /tools
    Content-Type: application/json
    
    {
      "jsonrpc": "2.0",
      "id": "request-id",
      "method": "mcp.list_tools",
      "params": {}
    }
    
  5. Call Tool

    code
    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.
    • If client_id is omitted, the response is returned directly in the HTTP response.

    Also supports standard MCP format for MCP Inspector compatibility:

    code
    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"
        }
      }
    }
    

SSE Event Types

When using SSE connections, the server sends the following event types:

  1. message (unnamed event): Sent when an SSE connection is successfully established.
  2. open: Additional connection established event.
  3. message: Used for all MCP protocol messages including tool start, result, and error events.

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.

Example JavaScript Client

javascript
// 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));

Using with MCP Inspector

The MCP Inspector is a browser-based tool for testing and debugging MCP servers. To use it with this server:

  1. Start both the server and MCP inspector in one command:

    bash
    npm run inspector
    

    Or start just the server with:

    bash
    npm run start:inspector
    
  2. To install and run the MCP Inspector separately:

    bash
    npx @modelcontextprotocol/inspector
    

    The inspector will open in your default browser.

  3. When the MCP Inspector opens:

    a. Enter the URL in the connection field:

    code
    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:

    code
    MCP SingleStore SSE server listening on port XXXX
    

    b. Make sure "SSE" is selected as the transport type

    c. Click "Connect"

  4. If you encounter connection issues, try these alternatives:

    a. Try connecting to a specific endpoint:

    code
    http://localhost:8081/stream
    

    b. Try using your machine's actual IP address:

    code
    http://192.168.1.x:8081
    

    c. If running in Docker:

    code
    http://host.docker.internal:8081
    
  5. Debugging connection issues:

    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:

    bash
    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

  6. Once connected, the inspector will show all available tools and allow you to test them interactively.

⚠️ Note: When using the MCP Inspector, you must use the full URL, including the http:// prefix.

MCP Client Integration

Installing in Claude Desktop

  1. Add the server configuration to your Claude Desktop config file located at:
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
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.

  1. Restart the Claude Desktop App

  2. In your conversation with Claude, you can now use the SingleStore MCP server with:

code
use_mcp_tool({
  server_name: "singlestore",
  tool_name: "list_tables",
  arguments: {}
})

Installing in Windsurf

  1. Add the server configuration to your Windsurf config file located at:
    • macOS: ~/Library/Application Support/Windsurf/config.json
    • Windows: %APPDATA%\Windsurf\config.json
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.

  1. Restart Windsurf

  2. In your conversation with Claude in Windsurf, the SingleStore MCP tools will be available automatically when Claude needs to access database information.

Installing in Cursor

  1. Add the server configuration to your Cursor settings:
    • Open Cursor
    • Go to Settings (gear icon) > Extensions > Claude AI > MCP Servers
    • Add a new MCP server with the following configuration:
json
{
  "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.

  1. Restart Cursor

  2. When using Claude AI within Cursor, the SingleStore MCP tools will be available for database operations.

Security Considerations

  1. Never commit credentials to version control
  2. Use environment variables or secure configuration management
  3. Consider using a connection pooling mechanism for production use
  4. Implement appropriate access controls and user permissions in SingleStore
  5. Keep the SingleStore CA bundle up to date

Development

Project Structure

code
mcp-server-singlestore/
├── src/
│   └── index.ts      # Main server implementation
├── package.json
├── tsconfig.json
├── README.md
└── CHANGELOG.md

Building

bash
npm run build

Testing

bash
npm test

Troubleshooting

  1. Connection Issues

    • Verify credentials and host information in your environment variables
    • Check SSL configuration
    • Ensure database is accessible from your network
    • Check your firewall settings to allow outbound connections to your SingleStore database
  2. Build Issues

    • Clear node_modules and reinstall dependencies
    • Verify TypeScript configuration
    • Check Node.js version compatibility (should be 16+)
  3. MCP Integration Issues

    • Verify the path to the server's build/index.js file is correct in your client configuration
    • Check that all environment variables are properly set in your client configuration
    • Restart your client application after making configuration changes
    • Check client logs for any error messages related to the MCP server
    • Try running the server standalone first to validate it works outside the client

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

MIT License - see LICENSE file for details

常见问题

SingleStore MCP Server 是什么?

通过标准化协议与 SingleStore 数据库交互,可执行查询、查看 schema,并轻松生成 ER 图。

SingleStore MCP Server 提供哪些工具?

提供 8 个工具,包括 generate_er_diagram、list_tables、query_table

相关 Skills

MCP构建

by anthropics

Universal
热门

聚焦高质量 MCP Server 开发,覆盖协议研究、工具设计、错误处理与传输选型,适合用 FastMCP 或 MCP SDK 对接外部 API、封装服务能力。

想让 LLM 稳定调用外部 API,就用 MCP构建:从 Python 到 Node 都有成熟指引,帮你更快做出高质量 MCP 服务器。

平台与服务
未扫描109.6k

Slack动图

by anthropics

Universal
热门

面向Slack的动图制作Skill,内置emoji/消息GIF的尺寸、帧率和色彩约束、校验与优化流程,适合把创意或上传图片快速做成可直接发送的Slack动画。

帮你快速做出适配 Slack 的动图,内置约束规则和校验工具,少踩上传与播放坑,做表情包和演示都更省心。

平台与服务
未扫描109.6k

接口设计评审

by alirezarezvani

Universal
热门

审查 REST API 设计是否符合行业规范,自动检查命名、HTTP 方法、状态码与文档覆盖,识别破坏性变更并给出设计评分,适合评审接口方案和版本迭代前把关。

做API和架构方案时,它能帮你提前揪出接口设计问题并对齐最佳实践,评审视角系统,团队协作更省心。

平台与服务
未扫描9.0k

相关 MCP Server

Slack 消息

编辑精选

by Anthropic

热门

Slack 是让 AI 助手直接读写你的 Slack 频道和消息的 MCP 服务器。

这个服务器解决了团队协作中需要 AI 实时获取 Slack 信息的痛点,特别适合开发团队让 Claude 帮忙汇总频道讨论或发送通知。不过,它目前只是参考实现,文档有限,不建议在生产环境直接使用——更适合开发者学习 MCP 如何集成第三方服务。

平台与服务
82.9k

by netdata

热门

io.github.netdata/mcp-server 是让 AI 助手实时监控服务器指标和日志的 MCP 服务器。

这个工具解决了运维人员需要手动检查系统状态的痛点,最适合 DevOps 团队让 Claude 自动分析性能数据。不过,它依赖 NetData 的现有部署,如果你没用过这个监控平台,得先花时间配置。

平台与服务
78.3k

by d4vinci

热门

Scrapling MCP Server 是专为现代网页设计的智能爬虫工具,支持绕过 Cloudflare 等反爬机制。

这个工具解决了爬取动态网页和反爬网站时的头疼问题,特别适合需要批量采集电商价格或新闻数据的开发者。不过,它依赖外部浏览器引擎,资源消耗较大,不适合轻量级任务。

平台与服务
34.5k

评论