Vanna AI MCP Server

Vanna AI MCP Server

An MCP server that uses Vanna AI and Azure OpenAI to translate natural language questions into SQL queries and execute them against a SQLite financial database, with detailed logging and cost tracking.

Category
Visit Server

README

Vanna AI MCP Server

This project implements a Model Context Protocol (MCP) server using Vanna AI for natural language to SQL translation and SQL execution over a financial database. It features:

  • Natural language to SQL generation using Vanna AI and Azure OpenAI
  • SQL execution against a SQLite database
  • Full schema and documentation context provided to the LLM for accurate SQL
  • Excel logging of all queries, prompts, LLM token usage, cost, timing, and results
  • Hot reload workflow for rapid development
  • Graceful shutdown and robust error handling

Features

  • ask_sql: Converts a natural language question to a SQL query using the LLM, logs all details to query_log.xlsx.
  • run_sql: Executes a SQL query and logs execution time and results to Excel.
  • LLM token/cost tracking: Logs input/output tokens and estimated cost for each LLM call.
  • Signal handling: Clean shutdown on Ctrl+C or kill.
  • Hot reload: Easily restart both server and Inspector for rapid iteration.

Setup

1. Clone the repository

git clone <your-repo-url>
cd <your-repo-directory>

2. Install Python dependencies

pip install -r requirements.txt

3. Install Node.js Inspector (optional, for UI)

npm install -g @modelcontextprotocol/inspector

4. Set up environment variables

Create a .env file with your credentials:

OPENAI_API_KEY=your-openai-key
AZURE_OPENAI_ENDPOINT=your-azure-endpoint
WEAVIATE_URL=your-weaviate-url
WEAVIATE_API_KEY=your-weaviate-key

5. Prepare the SQLite database

Place your financial.sqlite database in the project root.

6. (Optional) Train Vanna AI

Run your training script (e.g., train.py) once to populate the vector store.

Usage

Start the MCP server (with hot reload)

pip install watchfiles
watchfiles "uv run mcp dev app.py" .

Start the MCP Inspector (UI)

mcp-inspector

(Optional) Open the Inspector in your browser

open http://localhost:6277  # macOS
# or
xdg-open http://localhost:6277  # Linux

Logging

  • All queries, prompts, LLM token usage, cost, timing, and results are logged to query_log.xlsx.
  • Each new query appends a row; SQL execution updates the last row with fetch time and result.

Graceful Shutdown

  • The server handles SIGINT/SIGTERM for clean shutdown and port release.

Customization

  • Adjust LLM cost calculation in calculate_cost() as needed.
  • Update schema, documentation, and training data in app.py as your database evolves.

Troubleshooting

  • If you see "Not connected" errors in the Inspector, restart both the server and Inspector.
  • Ensure all environment variables are set and the database is present.

License

MIT

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
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
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
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
Qdrant Server

Qdrant Server

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

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