- Explore MCP Servers
- Fabric-SQL-Assistant
Fabric Sql Assistant
What is Fabric Sql Assistant
Fabric-SQL-Assistant is a Model Context Protocol (MCP) server designed to facilitate natural language interactions between Claude Desktop and Microsoft Fabric SQL databases.
Use cases
Use cases include generating SQL queries from natural language requests, automating data retrieval processes, and enhancing user experience in data-driven applications.
How to use
To use Fabric-SQL-Assistant, set up the required software and credentials, download the project files, create a Python virtual environment, install necessary packages, and configure your environment file with Azure and OpenAI credentials.
Key features
Key features include natural language processing for SQL queries, integration with Microsoft Fabric SQL databases, and support for Azure Active Directory authentication.
Where to use
Fabric-SQL-Assistant can be used in data analysis, business intelligence, and any application requiring seamless interaction with SQL databases through natural language.
Overview
What is Fabric Sql Assistant
Fabric-SQL-Assistant is a Model Context Protocol (MCP) server designed to facilitate natural language interactions between Claude Desktop and Microsoft Fabric SQL databases.
Use cases
Use cases include generating SQL queries from natural language requests, automating data retrieval processes, and enhancing user experience in data-driven applications.
How to use
To use Fabric-SQL-Assistant, set up the required software and credentials, download the project files, create a Python virtual environment, install necessary packages, and configure your environment file with Azure and OpenAI credentials.
Key features
Key features include natural language processing for SQL queries, integration with Microsoft Fabric SQL databases, and support for Azure Active Directory authentication.
Where to use
Fabric-SQL-Assistant can be used in data analysis, business intelligence, and any application requiring seamless interaction with SQL databases through natural language.
Content
Fabric SQL MCP Server Setup Guide for Claude Desktop
π― Overview
This guide will help you set up a Model Context Protocol (MCP) server that allows Claude Desktop to interact with Microsoft Fabric SQL databases using natural language.
π Prerequisites
Required Software
- Python 3.8+ installed on your system
- Claude Desktop application
- Microsoft Fabric workspace with SQL endpoint
- Azure Active Directory app registration
- OpenAI API account
Required Credentials
- Azure Client ID and Tenant ID
- OpenAI API key
- Fabric SQL server address and database name
π Step-by-Step Setup
Step 1: Download the Project Files
- Clone or download the repository
- Ensure you have these Python files in your project directory:
mcp_server.py
db.py
auth.py
llm.py
llm_dynamic.py
prompt.py
Step 2: Set Up Python Environment
# Navigate to your project directory
cd /path/to/your/fabric-sql-mcp
# Create virtual environment
python -m venv .venv
# Activate virtual environment
# On Windows:
.venv\Scripts\activate
# On macOS/Linux:
source .venv/bin/activate
# Install required packages
pip install mcp pyodbc msal python-dotenv openai
Step 3: Create Environment File
Create a .env
file in your project directory:
# Azure AD - Get these from Azure Portal > App Registrations
AZURE_CLIENT_ID=your_azure_client_id_here
AZURE_TENANT_ID=your_azure_tenant_id_here
# OpenAI - Get from https://platform.openai.com/api-keys
OPENAI_API_KEY=your_openai_api_key_here
# Fabric SQL - Get from your Fabric workspace
FABRIC_SQL_SERVER=your-server.datawarehouse.fabric.microsoft.com
FABRIC_DATABASE=your_database_name_here
Step 4: Get Your Azure Credentials
Create Azure App Registration:
- Go to Azure Portal > Azure Active Directory > App Registrations
- Click New Registration
- Name: βFabric SQL MCPβ
- Account types: βAccounts in this organizational directory onlyβ
- Redirect URI: Leave blank for now
- Click Register
Configure Authentication:
- In your new app, go to Authentication
- Click Add a platform > Mobile and desktop applications
- Check https://login.microsoftonline.com/common/oauth2/nativeclient
- Click Configure
Grant Permissions:
- Go to API Permissions
- Click Add a permission
- Select Azure Service Management
- Check user_impersonation
- Click Grant admin consent
Get Your IDs:
- Application (client) ID - Copy this as your
AZURE_CLIENT_ID
- Directory (tenant) ID - Copy this as your
AZURE_TENANT_ID
Step 5: Get Fabric SQL Details
- Go to your Microsoft Fabric workspace
- Navigate to your SQL Database or Data Warehouse
- Click on Settings or Connection strings
- Copy the SQL connection endpoint (looks like:
your-server.datawarehouse.fabric.microsoft.com
) - Note your database name
Step 6: Configure Claude Desktop
Find Claude Desktop Config:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Create/Edit Configuration:
{
"mcpServers": {
"fabric-sql-assistant": {
"command": "C:/path/to/your/project/.venv/Scripts/python.exe",
"args": [
"C:/path/to/your/project/mcp_server.py"
],
"env": {
"FABRIC_SQL_SERVER": "your-server.datawarehouse.fabric.microsoft.com",
"FABRIC_DATABASE": "your_database_name",
"AZURE_CLIENT_ID": "your_azure_client_id",
"AZURE_TENANT_ID": "your_azure_tenant_id",
"OPENAI_API_KEY": "your_openai_api_key"
}
}
}
}
Important Notes:
- Use full absolute paths for both
command
andargs
- On Windows, use forward slashes
/
or escape backslashes\\
- On macOS/Linux, the command would be
/path/to/your/project/.venv/bin/python
Step 7: Test the Setup
Test MCP Server Standalone:
# Activate your virtual environment
.venv\Scripts\activate # Windows
# or
source .venv/bin/activate # macOS/Linux
# Run the server
python mcp_server.py
You should see the server start without errors.
Test in Claude Desktop:
- Restart Claude Desktop completely
- Open a new conversation
- Look for the π§ (tools) icon in the interface
- Try asking: βWhat tables are available in my database?β
π§ Available Commands in Claude
Once set up, you can use these commands:
Database Configuration
Configure my database connection: Server: your-server.datawarehouse.fabric.microsoft.com Database: your_database_name
Schema Discovery
Discover my database schema
Natural Language Queries
What are the total sales by product category? Which customers have made the most purchases? Show me monthly revenue trends for this year
Direct SQL Execution
Execute this SQL query: SELECT TOP 10 * FROM Sales
Table Inspection
Show me details about the Sales table
π Troubleshooting
Common Issues
1. βTool not foundβ in Claude Desktop
- Solution: Restart Claude Desktop completely after config changes
- Check that file paths in config are absolute and correct
- Verify Python virtual environment path
2. Authentication Failures
- Solution: Ensure Azure app has correct permissions
- Check that youβve granted admin consent for API permissions
- Verify Client ID and Tenant ID are correct
3. Database Connection Issues
- Solution: Test connection to Fabric SQL from another tool first
- Ensure your account has access to the Fabric workspace
- Check that the SQL endpoint is active
4. Python Import Errors
- Solution: Ensure all required packages are installed in the virtual environment
- Check that all Python files are in the same directory
5. OpenAI API Errors
- Solution: Verify your OpenAI API key is valid and has credits
- Check that the key has access to the GPT-4 models
Debug Steps
1. Test Python Environment:
.venv\Scripts\activate
python -c "import mcp, pyodbc, msal, openai; print('All imports successful')"
2. Test Database Connection:
python -c "from db import test_connection; print(test_connection())"
3. Check Claude Desktop Logs:
- Windows:
%APPDATA%\Claude\logs\
- macOS:
~/Library/Logs/Claude/
π Security Best Practices
- Never commit
.env
orclaude_desktop_config.json
to version control - Use principle of least privilege for Azure app permissions
- Rotate credentials regularly
- Monitor usage of your OpenAI API key
- Use environment variables rather than hardcoding secrets
π Getting Help
If you encounter issues:
- Check Claude Desktop logs for error messages
- Test each component separately (auth, database, MCP server)
- Verify all credentials are correct and active
- Ensure all dependencies are installed in the virtual environment
π Additional Resources
- Microsoft Fabric Documentation
- Azure Active Directory App Registration
- OpenAI API Documentation
- Model Context Protocol Specification
Happy querying! π