SQL MCP Server Demo
Provides read-only access to SQL Server databases via Data API Builder, with tools to describe entities, read records, and aggregate data through the Model Context Protocol.
README
SQL MCP Server Demo
This repository implements a local Model Context Protocol (MCP) server for SQL Server using Microsoft Data API Builder (DAB) 2.0. It exposes read-only data access tools (describe_entities, read_records, and aggregate_records) to a local Ollama model (qwen3:8b) via a Python MCP client and Streamlit frontend.
Repository Structure
A:\sql-mcp-demo
│ .env.example - Template environment variables
│ .gitignore - Configured git ignore rules
│ README.md - Project documentation
│ requirements.txt - Python dependencies
│ mcp_client.py - Python MCP Client and LLM function calling loop
│ app.py - Streamlit frontend UI
│ test_ollama.py - Verifies basic connection to Ollama
│ test_tools.py - Verifies tool-calling capability of qwen3:8b
│
├── .venv/ - Python virtual environment
│
├── dab/
│ └── dab-config.json - Schema-valid Data API Builder configuration
│
├── database/
│ └── verify.sql - Reference SQL database queries
│
└── scratch/ - Developer tests and verification scripts
Architecture
┌──────────────────────┐
│ Streamlit UI │
│ app.py │
└──────────┬───────────┘
│ User Query
▼
┌──────────────────────┐
│ Qwen3:8B │
│ Ollama │
└──────────▲───────────┘
│ Function Call
│ Negotiation
▼
┌──────────────────────┐
│ MCP Client │
│ mcp_client.py │
└──────────┬───────────┘
│
│ MCP HTTP (Streamable HTTP)
▼
┌──────────────────────┐
│ Data API Builder │
│ SQL MCP Server │
│ localhost:5000/mcp │
└──────────┬───────────┘
│
│ SQL Connection
▼
┌──────────────────────┐
│ SQL Server LocalDB │
│ EmployeeDB │
│ └── dbo.Employee │
└──────────────────────┘
Running the Project
Follow these steps to start and run the application:
Step 1: Start Services
Ensure your local SQL Server instance and Ollama are running:
sqllocaldb start MSSQLLocalDB
ollama run qwen3:8b
Step 2: Start the DAB MCP Server
Open a terminal, activate your virtual environment, and run the DAB server:
# Navigate to workspace
cd A:\sql-mcp-demo
# Activate environment
.venv\Scripts\activate
# Start DAB MCP Server
C:\Users\kamal\.dotnet\tools\dab.exe start --config .\dab\dab-config.json
The server will start listening at http://localhost:5000/mcp.
Step 3: Run the Streamlit Application
Open a second terminal window and launch the frontend dashboard:
# Navigate to workspace
cd A:\sql-mcp-demo
# Activate environment
.venv\Scripts\activate
# Launch Streamlit
streamlit run app.py
This will open the dashboard in your web browser at http://localhost:8501.
Verification & Tests
Dynamic Schema & Client test
To test the tool negotiation loop directly via the command-line client:
python mcp_client.py
Verification Scripts
- [test_ollama.py](file:///a:/sql-mcp-demo/test_ollama.py): Verifies connection to Ollama.
- [test_tools.py](file:///a:/sql-mcp-demo/test_tools.py): Verifies basic tool selection capability.
- [scratch/test_all_queries.py](file:///a:/sql-mcp-demo/scratch/test_all_queries.py): Runs a batch of 7 validation queries testing counts, filters, averages, group-bys, and sort conditions.
Schema Validation Bug Fixed
A critical schema validation issue in Microsoft's Data API Builder v2.0.9 was addressed:
- The standard DAB schema validator contains a bug where defining
"mcp"at the entity level fortabletypes incorrectly triggers a stored-procedure constraint (requiringsource.typeto bestored-procedure). - This was resolved by removing the redundant entity-level
"mcp"block since MCP capability is already configured globally at the runtime level.
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.
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.
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.
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.