SQL Server Table Assistant - Modal Context Protocol
About
SQL Server Table Assistant - Modal Context Protocol is an application that lets you interact with a specific SQL Server table using natural language. It uses the Modal Context Protocol as a communication layer between LLMs and your data source, and is based on the original…
Details
- License
- MIT
Explore
Talk to Your Table: Chat with a specific SQL Server table using plain English
SQL Query Iteration: Provide feedback to refine SQL queries until they meet your needs
Beautiful Tabular Results: View query results in well-formatted tables for better readability
Query History Logging: Automatically save queries, iterations, and results for future reference
No-Code Table Operations: Query, insert, update, and delete data through natural conversations
Secure, Limited Access: Connect to only one table with restricted credentials for enhanced security
MCP-Enhanced Accuracy: Achieve precise table interactions through Modal Context Protocol
Context-Aware Conversations: Maintain context across multiple queries
Natural Language Explanations: Get plain English explanations of query results
Token Optimization: Smart caching and context management to minimize API usage
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
SQL Server Table Assistant - Modal Context ProtocolCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
Before you get started, make sure you have the following:
- Python 3.12+ installed on your machine
- A valid Azure OpenAI deployment with API access
- SQL Server with a table that you want to interact with
- Limited user credentials with access to only that table
pip install -r requirements.txt
Create a .env file in the root of the project and add the following:
AZURE_OPENAI_API_KEY=your_azure_openai_api_key
AZURE_OPENAI_ENDPOINT=https://your-resource-name.openai.azure.com
AZURE_OPENAI_API_VERSION=2023-05-15
AZURE_OPENAI_DEPLOYMENT_ID=your-deployment-name
MSSQL_SERVER=localhost
MSSQL_DATABASE=your_database_name
MSSQL_USERNAME=your_username
MSSQL_PASSWORD=your_password
MSSQL_DRIVER={ODBC Driver 18 for SQL Server}
MSSQL_TABLE_SCHEMA=dbo
MSSQL_TABLE_NAME=your_table_name
Once you've set up your environment and dependencies, you're ready to interact with the Table Assistant.
If you encounter rate limit errors with Azure OpenAI:
1. Wait before retrying: Rate limits are usually time-based, so waiting 60 seconds may resolve the issue
2. Increase your quota: Visit https://aka.ms/oai/quotaincrease to request a higher rate limit
3. Upgrade your tier: Free accounts may need to upgrade to Pay-as-you-Go
4. Use the /refresh_schema command: This regenerates the schema summary which might reduce token usage
5. Check your prompt length: Very complex questions might trigger more token usage
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"sql server table assistant - modal context protocol": {
"sql-server-table-assistant": {
"command": "python",
"args": [
"mcp-ssms-client.py"
]
}
}
}
}
McpServers
{
"sql-server-table-assistant": {
"command": "python",
"args": [
"mcp-ssms-client.py"
]
}
}
This application lets you interact with a specific SQL Server table using natural language, leveraging the Modal Context Protocol as a communication layer between LLMs and your data source.
This project is based on the mcp-sql-server-natural-lang repository by Aman Pachori, with modifications to focus on single table access.
Key Features:
Talk to Your Table: Chat with a specific SQL Server table using plain English
SQL Query Iteration: Provide feedback to refine SQL queries until they meet your needs
Beautiful Tabular Results: View query results in well-formatted tables for better readability
Query History Logging: Automatically save queries, iterations, and results for future reference
No-Code Table Operations: Query, insert, update, and delete data through natural conversations
Secure, Limited Access: Connect to only one table with restricted credentials for enhanced security
MCP-Enhanced Accuracy: Achieve precise table interactions through Modal Context Protocol
Context-Aware Conversations: Maintain context across multiple queries
Natural Language Explanations: Get plain English explanations of query results
Token Optimization: Smart caching and context management to minimize API usage
What is MCP?
MCP (Modal Context Protocol) is a methodology that standardizes how context is bound to LLMs, providing a standard way to connect AI models to different data sources and tools.Single Table Mode
This application runs in "Single Table Mode" which provides several advantages:
1. Enhanced Security: Access is limited to a single table rather than the entire database
2. Simpler Permissions: Users need minimal permissions (just for the specific table)
3. Focused Experience: The assistant is specialized for working with just one table
4. Reduced Risk: Prevents accidental access to sensitive data in other tables
Token Optimization
This application implements several strategies to minimize token usage and prevent rate limiting:
1. Smart Schema Summarization: Instead of sending the entire table schema to the model, a concise summary is created
2. Response Caching: Similar queries and explanations are cached to avoid redundant API calls
3. Minimal Prompt Design: System prompts and user instructions are optimized for brevity
4. Conversation Management: Only recent and relevant messages are included in the context
5. Dedicated System Prompts: Different prompts for different tasks (schema, query generation, explanations)
6. Selective Result Transmission: Large result sets are trimmed before being sent to the model
7. Token Parameter Tuning: Request parameters like max_tokens are set conservatively
These optimizations allow the application to function smoothly even with large tables and complex queries, while staying within API rate limits.
Prerequisites
Before you get started, make sure you have the following:- Python 3.12+ installed on your machine
- A valid Azure OpenAI deployment with API access
- SQL Server with a table that you want to interact with
- Limited user credentials with access to only that table
Getting Started
Follow these steps to get the project up and running:1. Clone the Repository
git clone https://github.com/yourusername/sql-server-table-assistant.git
cd sql-server-table-assistant
2. Install Dependencies
pip install -r requirements.txt
3. Setup Environment Variables
Create a .env file in the root of the project and add the following:
```dotenv
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



