Sponsored by Deepsite.site

Redshift MCP Server (TypeScript)

Created By
paschmaria8 months ago
Content

Redshift MCP Server (TypeScript)

This is a Model Context Protocol (MCP) server for Amazon Redshift implemented in TypeScript. It follows Anthropic's implementation pattern and provides Cursor IDE and other MCP-compatible clients with rich contextual information about your Redshift data warehouse. This server enables LLMs to inspect database schemas and execute read-only queries.

Integration with MCP Clients

Project-Specific Configuration

Create a .cursor/mcp.json file in your project directory:

{
  "mcpServers": {
    "redshift-mcp": {
      "command": "node",
      "args": ["path/to/dist/index.js"],
      "env": {
        "DATABASE_URL": "redshift://username:password@hostname:port/database?ssl=true"
      }
    }
  }
}

Global Configuration

For using across all projects, create ~/.cursor/mcp.json in your home directory with the same configuration.

Client-Specific Setup

Cursor IDE

  1. The server will be automatically detected if configured in mcp.json
  2. Tools will appear under "Available Tools" in MCP settings
  3. Agent will automatically use the tools when relevant

Other MCP Clients

Configure the server using stdio transport:

{
  "servers": [
    {
      "name": "redshift-mcp",
      "transport": {
        "kind": "stdio",
        "command": ["node", "path/to/dist/index.js"]
      }
    }
  ]
}

Prerequisites

  • Node.js 16 or higher
  • TypeScript
  • Access to an Amazon Redshift cluster
  • Basic knowledge of Redshift and SQL
  • Cursor IDE installed

Installation

  1. Clone this repository or copy the files to your local system
  2. Install the dependencies:
npm install
  1. Build the TypeScript code:
npm run build

Usage

The server requires a Redshift connection URL via the DATABASE_URL environment variable:

export DATABASE_URL="redshift://username:password@hostname:port/database?ssl=true"
npm start

Or you can run directly:

DATABASE_URL="redshift://username:password@hostname:port/database?ssl=true" node dist/index.js

For development, you can use:

DATABASE_URL="redshift://username:password@hostname:port/database?ssl=true" npm run dev

Connection URL Format

redshift://username:password@hostname:port/database?ssl=true
  • username: Your Redshift username
  • password: Your Redshift password
  • hostname: Your Redshift cluster endpoint
  • port: Usually 5439 for Redshift
  • database: The name of your database
  • ssl: Set to "true" for secure connection (recommended)

Additional connection parameters:

  • ssl=true: Required for secure connections (recommended)
  • timeout=10: Connection timeout in seconds
  • keepalives=1: Enable TCP keepalive
  • keepalives_idle=130: TCP keepalive idle time

Project Structure

  • src/index.ts: Main TypeScript implementation
  • dist/: Compiled JavaScript output
  • package.json: Project dependencies and scripts
  • tsconfig.json: TypeScript configuration

Components

Tools Available in Cursor

  • query

    • Execute read-only SQL queries against the connected Redshift database
    • Example: "Write a query to show all tables in the public schema"
  • describe_table

    • Get detailed information about a specific table
    • Example: "Show me the structure of the users table"
  • find_column

    • Find tables containing columns with specific name patterns
    • Example: "Find all tables that have a column containing 'email'"

Resources Available to Cursor

The server provides schema information that Cursor can use:

  • Schema Listings (redshift://<host>/schema/<schema_name>)

    • Lists all tables within a specific schema
    • Automatically discovered from database metadata
  • Table Schemas (redshift://<host>/<schema>/<table>/schema)

    • JSON schema information for each table
    • Includes column names, data types, and Redshift-specific attributes (distribution and sort keys)
  • Sample Data (redshift://<host>/<schema>/<table>/sample)

    • Sample rows from each table (limited to 5)
    • Sensitive data is automatically redacted
  • Statistics (redshift://<host>/<schema>/<table>/statistics)

    • Table statistics including size, row count, and creation time
    • Distribution and compression information

Security Considerations

This server:

  • Uses read-only transactions for queries to prevent modifications
  • Sanitizes inputs to prevent SQL injection
  • Does not expose raw password information in resource URIs
  • Automatically redacts sensitive data in sample results (email, phone)
  • Should be used in a secure environment since it has access to your database

Example Cursor Interactions

Here are some example questions you can ask Cursor once connected:

  1. "Show me all tables in the public schema"
  2. "What's the structure of the customers table?"
  3. "Find all tables that contain customer information"
  4. "Write a query to count orders by status"
  5. "Show me sample data from the products table"

Extending the Server

You can extend this server by:

  1. Adding new resource types in the ListResourcesRequestSchema and ReadResourceRequestSchema handlers
  2. Adding new tools in the ListToolsRequestSchema and CallToolRequestSchema handlers
  3. Enhancing security features or adding authentication

Development

For development, you can use the npm run dev command, which uses ts-node to run the TypeScript code directly without pre-compilation.

License

MIT

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Serper MCP ServerA Serper MCP Server
DeepChatYour AI Partner on Desktop
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
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.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
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.
Amap Maps高德地图官方 MCP Server
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
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"
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
ChatWiseThe second fastest AI chatbot™
CursorThe AI Code Editor
Playwright McpPlaywright MCP server
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Tavily Mcp