$npx -y skills add saskinosie/weaviate-claude-skills --skill weaviate-connectionConnect to local Weaviate vector database and verify connection health
| 1 | # Weaviate Connection Skill |
| 2 | |
| 3 | This skill helps you connect to a **local Weaviate database** instance running in Docker and verify the connection is healthy. |
| 4 | |
| 5 | ## Important Note |
| 6 | |
| 7 | **This skill is designed for LOCAL Weaviate instances only.** Claude Desktop and Claude Web have network restrictions that prevent connections to external services like Weaviate Cloud. |
| 8 | |
| 9 | **To use these skills, you must run Weaviate locally using Docker.** See the `weaviate-local-setup` skill first. |
| 10 | |
| 11 | ## Purpose |
| 12 | |
| 13 | Establish and test connections to local Weaviate vector databases running on localhost. |
| 14 | |
| 15 | ## When to Use This Skill |
| 16 | |
| 17 | - User wants to connect to their local Weaviate database |
| 18 | - User needs to verify their Weaviate connection is working |
| 19 | - User asks to check Weaviate health or status |
| 20 | - After starting Weaviate with Docker |
| 21 | |
| 22 | ## Prerequisites Check |
| 23 | |
| 24 | **BEFORE proceeding, Claude should verify:** |
| 25 | |
| 26 | 1. **Python environment is set up** (from `weaviate-local-setup` skill) |
| 27 | - Virtual environment exists at `.venv/` |
| 28 | - Dependencies are installed |
| 29 | |
| 30 | 2. **Weaviate Docker container is running** |
| 31 | - Check with `docker ps | grep weaviate` |
| 32 | - If not running, guide user to start it |
| 33 | |
| 34 | 3. **Environment file exists** |
| 35 | - `.env` file is present |
| 36 | - Has required variables set |
| 37 | |
| 38 | ### Automated Prerequisites Check |
| 39 | |
| 40 | ```python |
| 41 | import subprocess |
| 42 | import sys |
| 43 | import os |
| 44 | from pathlib import Path |
| 45 | |
| 46 | def check_prerequisites(): |
| 47 | """Check all prerequisites before connecting to Weaviate""" |
| 48 | print("🔍 Checking prerequisites...\n") |
| 49 | |
| 50 | all_checks_passed = True |
| 51 | |
| 52 | # Check 1: Virtual environment |
| 53 | venv_path = Path(".venv") |
| 54 | if venv_path.exists(): |
| 55 | print("✅ Virtual environment found") |
| 56 | else: |
| 57 | print("⚠️ No virtual environment found") |
| 58 | print(" Creating virtual environment...") |
| 59 | subprocess.run([sys.executable, "-m", "venv", ".venv"]) |
| 60 | print("✅ Virtual environment created") |
| 61 | |
| 62 | # Check 2: Dependencies |
| 63 | try: |
| 64 | import weaviate |
| 65 | from dotenv import load_dotenv |
| 66 | print("✅ Python dependencies installed") |
| 67 | except ImportError: |
| 68 | print("⚠️ Missing dependencies") |
| 69 | print(" Installing weaviate-client and python-dotenv...") |
| 70 | subprocess.check_call([sys.executable, "-m", "pip", "install", "-q", |
| 71 | "weaviate-client", "python-dotenv"]) |
| 72 | print("✅ Dependencies installed") |
| 73 | |
| 74 | # Check 3: Docker container |
| 75 | result = subprocess.run(["docker", "ps"], capture_output=True, text=True) |
| 76 | if "weaviate" in result.stdout: |
| 77 | print("✅ Weaviate Docker container is running") |
| 78 | else: |
| 79 | print("❌ Weaviate Docker container not found") |
| 80 | print(" Please start Weaviate first:") |
| 81 | print(" cd weaviate-local-setup && docker-compose up -d") |
| 82 | all_checks_passed = False |
| 83 | |
| 84 | # Check 4: .env file |
| 85 | if Path(".env").exists(): |
| 86 | print("✅ .env file found") |
| 87 | else: |
| 88 | print("⚠️ .env file not found") |
| 89 | print(" Creating .env from template...") |
| 90 | if Path(".env.example").exists(): |
| 91 | import shutil |
| 92 | shutil.copy(".env.example", ".env") |
| 93 | print("✅ .env file created") |
| 94 | print(" Please edit .env and add your API keys if needed") |
| 95 | else: |
| 96 | print("❌ No .env.example found") |
| 97 | all_checks_passed = False |
| 98 | |
| 99 | print("\n" + "="*50) |
| 100 | if all_checks_passed: |
| 101 | print("✅ All prerequisites met! Ready to connect.") |
| 102 | else: |
| 103 | print("❌ Some prerequisites missing. Please resolve them first.") |
| 104 | print("="*50 + "\n") |
| 105 | |
| 106 | return all_checks_passed |
| 107 | |
| 108 | # Run the check |
| 109 | if __name__ == "__main__": |
| 110 | check_prerequisites() |
| 111 | ``` |
| 112 | |
| 113 | **Claude should run this check automatically when this skill is loaded.** |
| 114 | |
| 115 | ## Requirements |
| 116 | |
| 117 | - Python 3.8+ |
| 118 | - weaviate-client library (`pip install weaviate-client`) |
| 119 | - **Local Weaviate instance running in Docker** (see `weaviate-local-setup` skill) |
| 120 | - Docker Desktop running |
| 121 | |
| 122 | ## Connection Instructions |
| 123 | |
| 124 | ### Step 1: Ensure Weaviate is Running Locally |
| 125 | |
| 126 | Before connecting, verify Weaviate Docker container is running: |
| 127 | |
| 128 | ```bash |
| 129 | # Check if Weaviate is running |
| 130 | docker ps | grep weaviate |
| 131 | |
| 132 | # If not running, start it with docker-compose |
| 133 | cd weaviate-local-setup |
| 134 | docker-compose up -d |
| 135 | |
| 136 | # Verify Weaviate is ready |
| 137 | curl http://localhost:8080/v1/.well-known/ready |
| 138 | ``` |
| 139 | |
| 140 | ### Step 2: Install Dependencies |
| 141 | |
| 142 | ```bash |
| 143 | pip install weaviate-client python-dotenv |
| 144 | ``` |
| 145 | |
| 146 | ### Step 3: Configure Environment Variables |
| 147 | |
| 148 | Update your `.env` file for local connection: |
| 149 | |
| 150 | ```bash |
| 151 | # .env file |
| 152 | WEAVIATE_URL=localhost:8080 |
| 153 | WEAVIATE_API_KEY= # Leave empty for local instances |
| 154 | |
| 155 | # Optional: Only needed if using these vectorizers |
| 156 | OPENAI_API_KEY=your-openai-key |
| 157 | COHERE_API_KEY=your-cohere-key |
| 158 | ``` |
| 159 | |
| 160 | ### Step 4: Create Connection Code |
| 161 | |
| 162 | **Basic Connection (Recommended):** |
| 163 | |
| 164 | ```python |
| 165 | import weaviate |
| 166 | import os |
| 167 | from dotenv import |