Vanna AI MCP Server

Vanna AI MCP Server

An MCP server that allows AI assistants to query databases using natural language by leveraging Vanna AI. It supports secure SSH tunneling, model training on database schemas, and persistent storage of SQL patterns via ChromaDB.

Category
Visit Server

README

Vanna AI MCP Server

MCP (Model Context Protocol) server that enables AI assistants to query databases using natural language via Vanna AI.

Features

  • šŸ—£ļø Natural Language SQL: Ask questions in plain English, get SQL queries automatically
  • šŸ” Secure SSH Tunneling: Connects to remote databases via SSH with key or password auth
  • šŸ¤– AI Training: Train Vanna on your database schema and sample queries
  • šŸ”Œ MCP Compatible: Works with Claude Desktop, Gemini CLI, and other MCP clients
  • šŸ“Š ChromaDB Vector Store: Persistent storage for trained SQL patterns

Quick Start

Using Docker (Recommended)

# Create .env file (see .env.sample)
cp .env.sample .env
# Edit .env with your credentials

# Run with Docker Compose
docker-compose up -d

Server runs on http://localhost:8000

Local Installation

# Install with uv
uv pip install vanna chromadb sshtunnel python-dotenv mcp starlette uvicorn

# Run the server
uv run python main.py

Configuration

Create a .env file with these variables:

# SSH Tunnel Configuration
SSH_HOST=your-server.com
SSH_PORT=22
SSH_USERNAME=your-user
SSH_PASSWORD=your-password          # OR use key-based auth
SSH_KEY_PATH=/path/to/private/key   # Optional
SSH_KEY_PASSPHRASE=key-passphrase   # Optional

# MySQL Database (on remote server)
MYSQL_REMOTE_HOST=localhost  # Usually localhost when using tunnel
MYSQL_REMOTE_PORT=3306
MYSQL_DATABASE=your_database
MYSQL_USER=db_user
MYSQL_PASSWORD=db_password

# Vanna AI
VANNA_MODEL=chinook            # Your model name
VANNA_API_KEY=your-api-key     # Get from vanna.ai

Available MCP Tools

  • generate_sql - Generate SQL from natural language question
  • run_sql - Execute SQL query and return results
  • train_question_sql - Train Vanna with example question/SQL pairs
  • train_ddl - Train Vanna on database schema (DDL statements)
  • get_training_data - View all trained examples

Usage Examples

With Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "vanna-ai": {
      "command": "uv",
      "args": ["run", "python", "/absolute/path/to/fastmcp/main.py"]
    }
  }
}

Example Queries

You: Show me the top 5 customers by total sales
Claude: [generates and runs SQL query]

You: What tables are in the database?
Claude: [calls get_training_data to see schema]

You: Train this: "show active users" -> SELECT * FROM users WHERE active=1
Claude: [calls train_question_sql]

Project Structure

fastmcp/
ā”œā”€ā”€ main.py              # MCP server with Vanna integration
ā”œā”€ā”€ docker-compose.yml   # Docker deployment
ā”œā”€ā”€ Dockerfile
ā”œā”€ā”€ pyproject.toml       # uv dependencies
ā”œā”€ā”€ .env.sample          # Configuration template
└── chroma_data/         # ChromaDB vector storage (persistent)

Tech Stack

  • Vanna AI: Natural language to SQL conversion
  • ChromaDB: Vector database for training data storage
  • MCP: Model Context Protocol for AI tool integration
  • SSH Tunnel: Secure remote database access
  • FastAPI/Starlette: HTTP server framework

Security Notes

  • Never commit .env file to version control
  • Use SSH key authentication when possible
  • Database credentials are transmitted only through SSH tunnel
  • ChromaDB data is persisted in chroma_data/ directory

License

Personal use. Database access and credentials remain private.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured