QueryBridge
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@QueryBridge What is the average salary in Engineering?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
QueryBridge
QueryBridge is a local AI application that connects a MySQL database to an Ollama-powered language model through an MCP (Model Context Protocol) tool server. It lets you ask natural-language questions about your data while keeping database access structured, safe, and local.
What this project does
Exposes MySQL read operations through an MCP server
Uses a local Ollama LLM to generate a safe SQL query
Validates the SQL against the real table schema
Executes the query through the MCP tool layer
Passes the result back to the LLM for a human-readable answer
This app is intended for local development and experimentation with:
MySQL running in XAMPP
Ollama models running on the same machine
Python 3.12 + uv for project management
Related MCP server: MySQL MCP Server
Architecture
main.py– client entry point, asks a question and orchestrates the flowmcp_server.py– MCP server that exposes safe database toolsdb/connection.py– MySQL connection and SQL execution helpersagent.py– Ollama LLM and prompt logic.env– local environment variables for DB and model configuration
Prerequisites
Before running the application, make sure you have:
Python 3.12+
uv installed
Ollama installed and running locally
XAMPP or another local MySQL service running
A MySQL database named
mcp_dbA table named
employee_salaryin that database
Install uv
If you do not have uv installed yet:
pip install uvOr follow the official uv installation instructions for your OS.
Ollama setup
Make sure Ollama is installed and the service is running.
Pull the required models:
ollama pull llama3.1
ollama pull nomic-embed-textStart Ollama:
ollama serveIf Ollama is already running in the background, you can skip this step.
The app uses these default values:
OLLAMA_BASE_URL=http://localhost:11434
LLM_MODEL=llama3.1
EMBEDDING_MODEL=nomic-embed-textMySQL / XAMPP setup
This project is configured to work with a local MySQL instance, typically running under XAMPP.
Recommended DB values
Use the following values in your .env file:
DB_HOST=127.0.0.1
DB_NAME=mcp_db
DB_USER=root
DB_PASSWORD=root
DB_PORT=3306Important notes:
Use
127.0.0.1instead oflocalhostwhen running MySQL via XAMPP for better reliability on WindowsEnsure XAMPP MySQL is running before starting the app
The app expects the database
mcp_dbto exist
Example table
The application is designed around a table like:
CREATE TABLE employee_salary (
emp_id INT PRIMARY KEY,
emp_name VARCHAR(100),
department VARCHAR(50),
designation VARCHAR(50),
base_salary DECIMAL(10,2),
bonus DECIMAL(10,2),
total_salary DECIMAL(10,2),
joining_date DATE
);Sample rows may look like:
INSERT INTO employee_salary (emp_id, emp_name, department, designation, base_salary, bonus, total_salary, joining_date)
VALUES
(1, 'Alice Johnson', 'Engineering', 'Software Developer', 75000.00, 5000.00, 80000.00, '2021-03-15'),
(2, 'Bob Smith', 'Engineering', 'DevOps Engineer', 72000.00, 4500.00, 76500.00, '2020-07-10');Environment configuration
Create a .env file in the project root if it does not already exist.
Example:
DB_HOST=127.0.0.1
DB_NAME=mcp_db
DB_USER=root
DB_PASSWORD=root
DB_PORT=3306
OLLAMA_BASE_URL=http://localhost:11434
LLM_MODEL=llama3.1
EMBEDDING_MODEL=nomic-embed-text
TABLE_NAME=employee_salaryYou can copy the values from .env.example if present in the project.
Running the project with uv
From the project folder:
cd C:\Users\srb3365\Documents\Projects\Python\querybridgeInstall dependencies:
uv syncRun the app:
uv run python main.pyWhen prompted, ask a question such as:
what is base salary of Bob SmithThe app will:
read the schema from MySQL
ask Ollama to generate a safe SELECT query
call the MCP database tool
return a natural-language answer based on the results
Quick validation commands
Check that MySQL is reachable:
uv run python -c "from db.connection import get_engine; from sqlalchemy import text; e=get_engine(); c=e.connect(); print(c.execute(text('SELECT 1 AS ok')).scalar_one()); c.close()"Check the table exists:
uv run python -c "from db.connection import get_engine; from sqlalchemy import text; e=get_engine(); c=e.connect(); print(c.execute(text('SHOW TABLES')).fetchall()); c.close()"Troubleshooting
MySQL connection refused
Confirm XAMPP MySQL service is running
Check that port
3306is enabledUse
127.0.0.1instead oflocalhostValidate the database credentials in
.env
Ollama connection failed
Start Ollama with
ollama servePull the models:
ollama pull llama3.1andollama pull nomic-embed-textConfirm
OLLAMA_BASE_URLpoints to the correct host and port
SQL generated is wrong
This app validates SQL against the current schema and rejects invalid table names or columns. If the model hallucinates a wrong table, the app will use a safe fallback for common employee salary questions.
Notes
This is a local-first project designed to demonstrate:
local model inference with Ollama
structured database access through MCP
MySQL read-only query execution
AI + tools pattern for business data questions
License
This project is provided for local learning and experimentation.
Available Tools
3 toolsget_employee_salary_schemaA
Return the schema of the employee_salary table for AI/agent use.
Inputs: no named parameters. Returns: result
query_employee_salaryA
Run a read-only SQL query against the employee_salary table. Only SELECT statements are allowed.
Inputs: sql (required). Returns: result
read_employee_salaryA
Read the latest rows from employee_salary. Keep the result small for LLM use.
Inputs: limit. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: schema introspection, small sample reads, and arbitrary read-only SQL queries. The read and query tools could theoretically overlap, but their descriptions make the intended use obvious.
All tool names follow a consistent verb_noun pattern around the employee_salary entity. get, read, and query are different verbs but align naturally with each tool's specific action.
Three tools is well-scoped for a focused server that exposes one table with schema, sample data, and ad-hoc querying. There are no unnecessary extras and nothing feels missing.
The server fully covers its intended read-only domain: understanding the schema, seeing recent rows, and running arbitrary SELECT queries. Write operations are not needed given the explicit read-only scope.
Related MCP Connectors
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Kaiva Bridge turns your API, database or documents into a managed MCP server for Claude, ChatGPT, Cursor and VS Code. Point it at an OpenAPI or Swagger spec, an API docs link, a cURL command, a Postman collection, a GraphQL endpoint, Postgres, MySQL, MariaDB or SQL Server, spreadsheets, PDFs and other documents, or an MCP server you already run. Bridge reads the source and proposes tools, and you choose which ones your AI client sees. No code to write and nothing to run. Connect this server and your agent does the setup for you: it lists your servers, shows one, drafts a new server from an OpenAPI spec, and refreshes a server's tools when its API changes. Free plan: 10 servers and 200,000 tool calls a month, no credit card. Pricing: https://kaiv.ai/bridge/pricing Security: https://kaiv.ai/bridge/security Docs: https://kaiv.ai/bridge/docs
Query your warehouse or a CSV with Claude/ChatGPT over MCP, governed by table-level ACL + audit.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables AI models to interact with MySQL databases through natural language, supporting SQL queries, table creation, and schema exploration.3-
- AlicenseNot gradedqualityDmaintenanceA tool that connects to local MySQL databases and enables large language models (LLMs) to execute SQL queries through the Model Context Protocol (MCP).824 npm1MIT
- AlicenseNot gradedqualityDmaintenanceA secure MySQL Model Context Protocol server that enables AI agents to interact with MySQL databases through standardized operations. Features comprehensive security with SQL injection prevention, connection pooling, and configurable tool access for database operations.1MIT
- FlicenseNot gradedqualityDmaintenanceA lightweight MCP server that connects a local AI model (Ollama) with custom CRUD tools for an in-memory database, enabling natural language database management.-