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.
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 questionrun_sql- Execute SQL query and return resultstrain_question_sql- Train Vanna with example question/SQL pairstrain_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
.envfile 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
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.