Redshift MCP Server

Redshift MCP Server

Enables LLMs and AI agents to securely query and interact with Amazon Redshift databases with configurable access modes (readonly, readwrite, admin) for safe data exploration and management.

Category
访问服务器

README

🚀 Redshift MCP Server

A plug-and-play Model Context Protocol (MCP) server for Amazon Redshift. Instantly connect LLMs and AI agents (Claude, ChatGPT, etc.) to your Redshift data — securely, safely, and with zero hassle.


🌟 Features

  • Production-ready: Secure, robust, and easy to deploy
  • MCP Standard: Exposes Redshift as standardized tools for LLMs/AI
  • Strict Access Modes: readonly, readwrite, admin (enforced by env var)
  • Auto-connect: Use environment variables or a .env file for seamless startup
  • No code changes needed: Just configure and run
  • Extensible: Add new tools or business logic easily
  • Works with Claude Desktop, ChatGPT, and any MCP client

⚡ Quickstart

  1. Clone & Install
    git clone <repo-url>
    cd my-redshift-mcp
    python3 -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
    
  2. Configure (recommended: create a .env file):
    REDSHIFT_HOST=your-cluster.region.redshift.amazonaws.com
    REDSHIFT_DATABASE=mydb
    REDSHIFT_USER=myuser
    REDSHIFT_PASSWORD=mypassword
    REDSHIFT_PORT=5439
    DB_MCP_MODE=readonly
    
  3. Run the server
    ./scripts/run_server.sh
    
  4. Connect from your LLM/MCP client (e.g., Claude Desktop)

🔗 What is Redshift MCP Server?

Redshift MCP Server is an open-source bridge between Amazon Redshift and modern AI assistants. It lets LLMs securely query, explore, and (optionally) modify your Redshift data using the Model Context Protocol (MCP). Perfect for:

  • Data teams enabling AI-powered analytics
  • Building AI workflows and automations
  • Secure, auditable LLM access to production data

About This Project

This repository provides a minimal, production-ready MCP server for Amazon Redshift using the FastMCP framework. It allows LLMs and AI agents to:

  • Query Redshift databases (with strict access controls)
  • List schemas and tables
  • Describe table structures
  • (Optionally) insert/update data, depending on configured mode

Key features:

  • Three access modes: readonly, readwrite, admin (see below)
  • Environment variable and .env support for easy configuration
  • Secure by default: starts in readonly mode
  • Compatible with Claude Desktop, ChatGPT, and any MCP client
  • Easy to extend with new tools or business logic

Features

This MCP server provides the following tools for Redshift database operations:

  • connect_db: Establish connection to a Redshift cluster (supports environment variables)
  • query: Execute SELECT queries with optional parameter binding
  • execute: Run INSERT, UPDATE, DELETE, or DDL statements
  • list_schemas: List all schemas in the database
  • list_tables: List tables in a specific schema
  • describe_table: Get detailed structure of a table
  • disconnect: Close the database connection

Auto-Connection Support

The server supports automatic connection on startup using environment variables. If all required environment variables are set, the server will connect automatically when it starts.


Access Modes and Query Safety

The server supports three access modes, controlled by the DB_MCP_MODE environment variable:

1. readonly (default)

  • Allows: SELECT, SHOW, DESCRIBE, etc.
  • Blocks: INSERT, UPDATE, DELETE, DROP, TRUNCATE, ALTER, CREATE, GRANT, REVOKE, COMMENT, SET, COPY, UNLOAD, VACUUM, ANALYZE, MERGE

2. readwrite

  • Allows: SELECT, INSERT, UPDATE, CREATE, etc.
  • Blocks: DELETE, DROP, TRUNCATE, ALTER, GRANT, REVOKE, COMMENT, SET, COPY, UNLOAD, VACUUM, ANALYZE, MERGE

3. admin

  • Allows everything (no restrictions)

If a forbidden statement is detected, the server will return a clear error message.

How to Set the Mode

  • Environment variable: DB_MCP_MODE=readonly (or readwrite, admin)
  • Claude Desktop config:
    "env": {
      "DB_MCP_MODE": "readwrite",
      ...
    }
    
  • Shell/local:
    export DB_MCP_MODE=readonly
    ./run_server.sh
    

Installation

  1. Clone or download this repository
  2. Install dependencies:
pip install -r requirements.txt

Usage

Running the Server

Run the server directly:

python src/redshift_mcp_server.py

Or use the provided scripts:

./scripts/run_server.sh
# or on Windows:
scripts\run_server.bat

By default, the server runs using STDIO transport, which is suitable for integration with MCP clients like Claude Desktop.

Configuration for Claude Desktop

To use this server with Claude Desktop, add the following configuration to your Claude Desktop config file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%/Claude/claude_desktop_config.json

Option 1: With Environment Variables (Recommended)

{
  "mcpServers": {
    "redshift": {
      "command": "/Users/anshulpatre/Desktop/DB-mcp/my-redshift-mcp/venv/bin/python",
      "args": ["/Users/anshulpatre/Desktop/DB-mcp/my-redshift-mcp/src/redshift_mcp_server.py"],
      "env": {
        "REDSHIFT_HOST": "your-cluster.region.redshift.amazonaws.com",
        "REDSHIFT_DATABASE": "mydb",
        "REDSHIFT_USER": "myuser",
        "REDSHIFT_PASSWORD": "mypassword",
        "REDSHIFT_PORT": "5439",
        "DB_MCP_MODE": "readonly"
      }
    }
  }
}

With this configuration, the server will automatically connect to your Redshift database on startup. You won't need to use the connect_db tool manually.

Option 2: Without Environment Variables

{
  "mcpServers": {
    "redshift": {
      "command": "/Users/anshulpatre/Desktop/DB-mcp/my-redshift-mcp/venv/bin/python",
      "args": ["/Users/anshulpatre/Desktop/DB-mcp/my-redshift-mcp/src/redshift_mcp_server.py"]
    }
  }
}

With this configuration, you'll need to use the connect_db tool to establish a connection.

Environment Variables

The server supports the following environment variables:

  • REDSHIFT_HOST: Redshift cluster endpoint
  • REDSHIFT_DATABASE: Database name
  • REDSHIFT_USER: Username
  • REDSHIFT_PASSWORD: Password
  • REDSHIFT_PORT: Port number (default: 5439)
  • DB_MCP_MODE: Access mode (readonly, readwrite, admin)

When these environment variables are set, the server will:

  1. Automatically connect on startup
  2. Use them as defaults for the connect_db tool if no parameters are provided
  3. Enforce query/statement restrictions based on the selected mode

Available Tools

1. connect_db

Connect to a Redshift database cluster. If environment variables are set, parameters are optional.

# With explicit parameters
{
  "tool": "connect_db",
  "arguments": {
    "host": "your-cluster.region.redshift.amazonaws.com",
    "database": "mydb",
    "user": "myuser",
    "password": "mypassword",
    "port": 5439
  }
}

# With environment variables set
{
  "tool": "connect_db",
  "arguments": {}
}

2. query

Execute SELECT queries to retrieve data.

{
  "tool": "query",
  "arguments": {
    "sql": "SELECT * FROM users WHERE created_at > %s",
    "params": ["2024-01-01"]
  }
}

3. execute

Execute data modification or DDL statements.

{
  "tool": "execute",
  "arguments": {
    "sql": "INSERT INTO users (name, email) VALUES (%s, %s)",
    "params": ["John Doe", "john@example.com"]
  }
}

4. list_schemas

List all user-created schemas.

{
  "tool": "list_schemas",
  "arguments": {}
}

5. list_tables

List tables in a specific schema.

{
  "tool": "list_tables",
  "arguments": {
    "schema": "public"
  }
}

6. describe_table

Get detailed information about a table's structure.

{
  "tool": "describe_table",
  "arguments": {
    "table": "users",
    "schema": "public"
  }
}

7. disconnect

Close the database connection.

{
  "tool": "disconnect",
  "arguments": {}
}

Security Considerations

  • Credentials: The recommended approach is to use environment variables in the MCP configuration file. This keeps credentials out of your code and tool calls.
  • Permissions: Use database users with minimal required permissions.
  • Query Safety: The server uses parameterized queries to prevent SQL injection. Query/statement type is checked and blocked according to the selected mode.
  • Network Security: Ensure your Redshift cluster is properly secured with VPC and security groups.

Development

To extend this server:

  1. Add new tools using the @mcp.tool() decorator
  2. Follow the FastMCP documentation for advanced features
  3. Test thoroughly with your Redshift cluster

Troubleshooting

Connection Issues

  • Verify your Redshift cluster endpoint and credentials
  • Check network connectivity and security group settings
  • Ensure the cluster is active and accepting connections

Import Errors

  • If redshift-connector is not available, the server falls back to psycopg2
  • Install the appropriate connector based on your needs

License

MIT

Contributing

Feel free to submit issues or pull requests to improve this MCP server.


👤 Maintainer

This Redshift MCP Server is maintained and deployed by Anshul.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选