Skip to main content
Glama
Wago DB2 MCP Server

Wago DB2 MCP Server

by VoxCore84
README.md
# Wago DB2 MCP Server

![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue) ![License: MIT](https://img.shields.io/github/license/VoxCore84/wago-db2) ![GitHub release](https://img.shields.io/github/v/release/VoxCore84/wago-db2)

DuckDB-powered [MCP](https://modelcontextprotocol.io/) server for querying [Wago DB2](https://wago.tools/db2) CSV tables. Gives AI coding assistants instant SQL access to all 1,097+ World of Warcraft data tables — spells, items, creatures, areas, factions, transmog, and more.

## How It Works

1. Download CSV exports from [wago.tools](https://wago.tools/db2) using the included downloader
2. Point the MCP server at the CSV directory
3. Tables are lazy-loaded into DuckDB (in-memory) on first query
4. Full SQL support: JOINs, aggregations, ILIKE, subqueries

## Quick Start

```bash
# Install
pip install -e .

# Download tables for WoW 12.x (latest build auto-detected)
wago-db2-download --major 12 --tables-file tables.txt --out csv

# Start the MCP server
WAGO_CSV_DIR=./csv/major_12/<build>/enUS wago-db2
```

### MCP Configuration

Add to your MCP client config (Claude Code, Antigravity, etc.):

```json
{
  "mcpServers": {
    "wago-db2": {
      "command": "python",
      "args": ["-m", "wago_db2_server"],
      "env": {
        "WAGO_CSV_DIR": "/path/to/csv/major_12/12.0.1.66337/enUS",
        "PYTHONUTF8": "1"
      }
    }
  }
}
```

## Tools

| Tool | Description |
|------|-------------|
| **`db2_lookup`** | Look up rows by ID (primary key). Supports batch lookups and column selection |
| **`db2_search`** | Case-insensitive text search. Auto-detects name column (`*_lang`, `Name`, first VARCHAR) |
| **`db2_validate_ids`** | Check which IDs exist vs missing. Returns `{existing: [...], missing: [...]}` |
| **`db2_query`** | Raw SELECT queries with JOINs, aggregations, etc. Non-SELECT statements are rejected |
| **`db2_tables`** | List all available tables with optional name filter |
| **`db2_describe`** | Show schema (column names + types) and sample rows |

## Downloader

The included downloader fetches CSV exports from wago.tools with parallel downloads:

```bash
# Download specific tables
wago-db2-download --major 12 --tables SpellName,ItemSparse,Creature

# Download from a list file
wago-db2-download --major 12 --tables-file tables.txt --out csv

# Force re-download, 16 threads
wago-db2-download --major 12 --tables-file tables.txt --force --threads 16

# Specific build + locale
wago-db2-download --major 12 --build 12.0.1.66337 --locale deDE --out csv
```

### Downloader Options

| Flag | Default | Description |
|------|---------|-------------|
| `--major` | (required) | Expansion major version (12 for Midnight, 11 for TWW, etc.) |
| `--build` | auto-detect | Override build string (e.g. `12.0.1.66337`) |
| `--locale` | `enUS` | Locale for CSV data |
| `--out` | `wago_csv` | Output directory |
| `--tables` | | Comma-separated table names |
| `--tables-file` | | Path to text file with table names (one per line) |
| `--threads` | 8 | Concurrent download threads |
| `--force` | false | Re-download existing files |
| `--timeout` | 60 | HTTP timeout in seconds |

## Environment Variables

| Variable | Default | Purpose |
|----------|---------|---------|
| `WAGO_CSV_DIR` | `./csv` | Directory containing DB2 CSV files |

## Enriched Tables

Place additional CSV files in an `enriched/` subdirectory next to your CSV directory. These are loaded alongside the standard DB2 tables and can be JOINed freely. Useful for pre-computed cross-references (e.g., items with appearance IDs, transmog sets with names).

## Security

- Only SELECT queries are allowed — INSERT, UPDATE, DELETE, DROP, etc. are rejected
- SQL comments are stripped before keyword validation to prevent bypass
- All ID parameters are validated as integers
- Default LIMIT 1000 is enforced on queries without an explicit LIMIT

## Requirements

- **Python 3.10+**
- **[DuckDB](https://duckdb.org/)** — in-memory analytical database
- **[FastMCP](https://github.com/jlowin/fastmcp)** — Python MCP framework
- **[Requests](https://requests.readthedocs.io/)** — for the downloader

## License

MIT