Skip to main content
Glama
MCP Snowflake Server

MCP Snowflake Server

README.md
# 🚀 Enhanced MCP Snowflake Server v2.0

A powerful Model Context Protocol (MCP) server that provides Claude with comprehensive Snowflake database access capabilities.

![GitHub Stars](https://img.shields.io/github/stars/muthuramanathanm/mcp-snowflake-service?style=social)
![Docker](https://img.shields.io/badge/Docker-Ready-blue?logo=docker)
![Tools](https://img.shields.io/badge/Tools-7-green)

## ✨ Enhanced Features

This server provides **7 powerful tools** for comprehensive Snowflake exploration:

### 🔍 **Discovery Tools**
- **`list_databases`** - Show all available databases
- **`list_schemas`** - List schemas in databases  
- **`list_tables`** - Show tables in schemas
- **`search_tables`** - Find tables by pattern

### 📊 **Analysis Tools**
- **`describe_table`** - Show detailed table structure
- **`get_table_sample`** - Retrieve sample data
- **`execute_query`** - Run custom SQL queries

### 🐳 **Production Ready**
- **Docker containerization** with health checks
- **Comprehensive documentation** (3 reference formats)
- **Production-grade deployment** setup
- **50+ ready-to-use prompts**

## 🚀 Quick Start

### Option 1: Docker Deployment (Recommended)

1. **Clone the repository**
```bash
git clone https://github.com/muthuramanathanm/mcp-snowflake-service.git
cd mcp-snowflake-service
```

2. **Configure credentials**
```bash
# Create .env file with your Snowflake credentials
cp .env.example .env
# Edit .env with your actual credentials
```

3. **Build and run with Docker**
```bash
docker build -t mcp-snowflake-server .
# The Docker wrapper script handles everything automatically
```

### Option 2: Local Installation

1. **Clone and install dependencies**
```bash
git clone https://github.com/muthuramanathanm/mcp-snowflake-service.git
cd mcp-snowflake-service
pip install -r requirements.txt
```

## ⚙️ Configuration

### Cursor IDE MCP Configuration

Add the following to your Cursor MCP configuration file (`~/.cursor/mcp.json`):

#### Docker Deployment (Recommended)
```json
{
  "mcpServers": {
    "snowflake": {
      "mode": "stdio",
      "command": "/path/to/mcp-snowflake-service/docker-mcp-wrapper.sh",
      "cwd": "/path/to/mcp-snowflake-service"
    }
  }
}
```

#### Local Python Deployment
```json
{
  "mcpServers": {
    "snowflake": {
      "mode": "stdio", 
      "command": "python",
      "args": ["server.py"],
      "cwd": "/path/to/mcp-snowflake-service"
    }
  }
}
```

**Configuration Notes:**
- **Docker approach**: Uses the included wrapper script for containerized deployment
- **Local approach**: Runs Python directly (requires local Python environment)
- **Update paths**: Replace `/path/to/mcp-snowflake-service` with your actual installation path

### Snowflake Credentials

Create a `.env` file in the project root directory:

```env
SNOWFLAKE_USER=your_username
SNOWFLAKE_PASSWORD=your_password  
SNOWFLAKE_ACCOUNT=your_account.region    # Example: autodesk-stg.us-east-1
SNOWFLAKE_DATABASE=your_database
SNOWFLAKE_WAREHOUSE=your_warehouse
```

**Security Note:** Never commit the `.env` file to version control. Add it to your `.gitignore`.

## 🔄 Connection Management

The server provides robust automatic connection management:

- **Automatic initialization**
  - Creates connection when first query is received
  - Validates connection parameters and credentials
  - Handles authentication and session setup

- **Connection maintenance** 
  - Tracks connection state and health
  - Handles connection timeouts gracefully
  - Automatically reconnects if connection is lost
  - Implements retry logic with exponential backoff

- **Resource management**
  - Properly closes connections when server stops
  - Releases database resources appropriately
  - Prevents connection leaks and orphaned sessions

## 📚 Usage & Examples

### Natural Language Prompts

The server supports intuitive natural language queries. Here are some examples:

#### **Discovery Commands**
- *"What databases are available?"*
- *"What schemas are in EDH_PUBLISH database?"*  
- *"Find tables with 'subscription' in the name"*
- *"What tables are in the PARTNER_WEB_SERVICES_PRIVATE schema?"*

#### **Analysis Commands**  
- *"Show me the structure of the ACCOUNT table"*
- *"Give me 5 sample rows from the SUBSCRIPTION table"*
- *"Describe the CONTRACTLINEITEM_INT table"*

#### **Custom SQL**
- *"Execute: SELECT COUNT(*) FROM EDH_PUBLISH.EDH_SHARED.SUBSCRIPTION"*
- *"Run: SELECT * FROM ACCOUNT WHERE ID IS NOT NULL LIMIT 3"*

### Manual Testing

For development and testing, you can run the server standalone:

```bash
# Local testing
python server.py

# Docker testing  
./test-docker-mcp.sh
```

## 🌟 Key Features

- **🔍 7 Powerful Tools** - Complete Snowflake exploration toolkit
- **🐳 Docker Ready** - Production-grade containerized deployment
- **📖 Rich Documentation** - 3 comprehensive reference formats
- **🚀 Natural Language** - Intuitive prompts for immediate productivity
- **🔒 Secure** - Robust error handling and credential management
- **⚡ High Performance** - Optimized connection pooling and caching

## 📁 Documentation

This repository includes comprehensive documentation:

- **`MCP_PROMPTS_REFERENCE.md`** - Complete guide with 50+ examples and workflows
- **`QUICK_PROMPTS.txt`** - Copy-paste ready prompts for immediate use  
- **`PROMPTS_REFERENCE.json`** - Structured reference for automation
- **`README_DOCKER.md`** - Detailed Docker deployment guide

## 🛠️ Development

To contribute or report issues:

1. Fork this repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)  
5. Open a Pull Request

## 🔐 Security Notes

- **Access Control**: Snowflake access is controlled through database user permissions
- **Read-Only Use**: For read-only access, use a Snowflake user with read-only permissions
- **Credential Security**: Never commit `.env` files or credentials to version control
- **Network Security**: Use appropriate firewall rules and VPN access as needed

## 📄 License

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

This project is licensed under the [MIT License](LICENSE).

---

**Built with ❤️ for the developer community. Star ⭐ this repo if you find it useful!**