MCP Server for Amazon Redshift
by snahmod
This is a Model Context Protocol (MCP) server implementation designed for Amazon Redshift. It enables AI models to interact with Redshift databases through a standardized interface.
Last updated: N/A
MCP Server for Amazon Redshift
A Model Context Protocol (MCP) server implementation for Amazon Redshift, allowing AI models to interact with Redshift databases through a standardized interface.
Features
- Connect to Amazon Redshift databases
- List tables, views, and materialized views
- Retrieve schema information for database objects
- Execute read-only SQL queries
- Environment variable configuration
- Schema filtering support
Prerequisites
- Node.js 18.x or higher
- npm 9.x or higher
- Access to an Amazon Redshift cluster
Installation
-
Clone the repository:
git clone https://github.com/snahmod/mcp-server-redshift.git cd mcp-server-redshift
-
Install dependencies:
npm install
-
Create a
.env
file based on the example:cp .env.example .env
-
Edit the
.env
file with your Redshift connection details:REDSHIFT_HOST=your-cluster.region.redshift.amazonaws.com REDSHIFT_PORT=5439 REDSHIFT_DATABASE=your_database REDSHIFT_USER=your_username REDSHIFT_PASSWORD=your_password REDSHIFT_SCHEMAS=public,schema1,schema2 # Transport configuration (optional) TRANSPORT_TYPE=stdio # or 'sse' PORT=3000 # Only used with SSE transport
Usage
Starting the Server
The server supports two transport types:
-
stdio (default):
npm start # or explicitly TRANSPORT_TYPE=stdio npm start
-
SSE (Server-Sent Events):
TRANSPORT_TYPE=sse PORT=3000 npm start
When using SSE transport, the server exposes two endpoints:
GET /sse
- Establishes an SSE connectionPOST /messages
- Handles MCP messages
Testing
Run the test client to verify the server functionality:
npm test
The test client will:
- Start the MCP server
- List all tables, views, and materialized views
- Get schema information for a table
- Get schema information for a view (if available)
- Execute a count query on a table
- Execute a simple query
Building
Build the TypeScript code:
npm run build
Using with MCP
This server can be used with any MCP-compatible client, including AI assistants like Claude. To use it:
-
Build the server:
npm run build
-
Set up your environment variables in
.env
-
Start the server:
npm start
-
Connect to the server using an MCP client. The server will provide access to database resources and the query tool.
Example MCP Interactions
-
List all tables and views:
{ "type": "list_resources", "params": {} }
-
Get table schema:
{ "type": "read_resource", "params": { "uri": "redshift://your-cluster/schema/table" } }
-
Execute a query:
{ "type": "call_tool", "params": { "name": "query", "arguments": { "sql": "SELECT * FROM schema.table LIMIT 5" } } }
Development
Project Structure
src/
- Source codeindex.ts
- Main server implementationtypes.ts
- TypeScript type definitions
test/
- Test filesclient.ts
- Test client for verifying server functionality
dist/
- Compiled JavaScript code (generated)
Adding New Features
- Implement new functionality in
src/index.ts
- Add appropriate tests in
test/client.ts
- Update documentation in
README.md
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Acknowledgments
This project is based on the PostgreSQL MCP server from the Model Context Protocol project. Special thanks to the original authors for their work.