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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。