Custom Fabric MCP
An MCP server that provides AI-powered, governed access to Microsoft Fabric data assets with 16 tools for querying, schema discovery, knowledge retrieval, and export.
README
Custom Fabric MCP
An MCP (Model Context Protocol) server for AI-powered, governed access to Microsoft Fabric data assets. Enables AI agents to query Fabric Warehouses and Lakehouses with full governance, validation, and explainability.
Features
- 16 MCP tools — query, schema discovery, knowledge retrieval, export, admin
- Governance-first — RBAC/ABAC, PII masking, rate limiting, SQL deny patterns
- Validated SQL — schema-aware validation, query optimization (NOLOCK, TOP), cost estimation
- Grounded responses — citations, confidence scoring, natural-language explanations
- Knowledge retrieval — business glossary, KPI dictionary, knowledge graph, query history
- Caching — Redis-backed query and result cache with semantic hashing
- Export services — charts (matplotlib), Excel (openpyxl), PDF/Word, email with confirmation gate
Quick Start
# Install dependencies
uv sync
# Install with dev tools (ruff, pytest, pyright)
uv sync --group dev
# Install with optional services (matplotlib, openpyxl)
uv sync --extra services
# Run in development mode (MCP Inspector)
uv run mcp dev src/server/main.py
# Run with MCP inspector
uv run mcp inspector src/server/main.py
# Run directly (stdio transport)
uv run python -m src.server.main
# Lint and format
uv run ruff check src/
uv run ruff format src/
# Run tests
uv run pytest tests/ -x --timeout=30
# Seed sample schema for local dev
uv run python scripts/seed-schema.py
Configuration
Copy .env.example to .env and fill in your values:
cp .env.example .env
Required Configuration
| Variable | Description |
|---|---|
FABRIC_SQL_ENDPOINT |
Fabric workspace SQL endpoint URL |
FABRIC_DATABASE_NAME |
Database name in Fabric |
AZURE_TENANT_ID |
Azure AD tenant ID |
AZURE_CLIENT_ID |
App registration client ID |
AZURE_CLIENT_SECRET |
App registration client secret |
Optional Configuration
| Variable | Default | Description |
|---|---|---|
SERVER_TRANSPORT |
stdio |
Transport: stdio or sse |
SERVER_PORT |
8080 |
Port for SSE transport |
LOG_LEVEL |
INFO |
Log level |
LOG_FORMAT |
json |
Log format: json or console |
REDIS_URL |
redis://localhost:6379 |
Redis for caching |
REDIS_CACHE_TTL_SECONDS |
3600 |
Cache TTL (1 hour) |
GOVERNANCE_MAX_ROWS_DEFAULT |
1000 |
Default row limit |
GOVERNANCE_RATE_LIMIT_PER_MINUTE |
20 |
Queries per minute |
GOVERNANCE_TOKEN_BUDGET |
4000 |
CU-second budget |
See .env.example for all available options.
Architecture
User → LLM → AgentPlanner → [Retrieval → Governance → Validation → Execution → Masking → Response]
↓ ↓ ↓ ↓ ↓ ↓
Glossary RBAC/PII Optimizer Fabric PiiMasker Assembler
KG/RAG RateLimit CostEstimate pyodbc (HMAC salt) Citations
History DenyPatterns Schema Pool(5) HideColumn Confidence
Pipeline (9 steps in AgentPlanner)
- Retrieve context — glossary, KG, history, RAG, session memory
- Governance pre-check — RBAC, rate limits, deny patterns
- Schema discovery — INFORMATION_SCHEMA (cached with TTL)
- Validate + optimize — table/column existence, NOLOCK, TOP injection, cost estimate
- Execute — parameterized query against Fabric SQL Endpoint
- Post-query masking — PII redaction/partial mask/tokenize based on role × sensitivity
- Assemble response — citations, confidence (weighted), explanation, warnings
- Audit log — structured entry with user, tables, governance decisions, latency
- Store — query history + session memory for future reuse
Deployment
Docker
docker build -t custom-fabric-mcp .
docker run -p 8080:8080 --env-file .env custom-fabric-mcp
Azure Container Apps (Bicep)
# Deploy to dev environment
./scripts/deploy.sh dev latest
# Or use az CLI directly
az deployment group create \
--resource-group rg-fabric-mcp-dev \
--template-file infra/main.bicep \
--parameters infra/parameters.dev.json
Infrastructure includes: VNET, Key Vault, Container Registry, Redis Cache, Container App with auto-scaling (1-3 replicas).
Project Structure
src/
├── common/ # Config, errors (6 types), logging (structlog)
├── server/ # MCP entry point (app factory pattern)
├── fabric/ # Auth, connection pool, query executor, schema
├── governance/ # RBAC, PII masking, policy engine, audit
├── validation/ # SQL validator, optimizer, cost estimator
├── retrieval/ # RAG, knowledge graph, glossary, history, memory
├── cache/ # Redis client, query cache, result cache
├── response/ # Citations, confidence, explainer, assembler
├── agents/ # Planner (pipeline), model router, workflow engine
├── tools/ # 16 MCP tools (the API surface)
└── services/ # Charts, Excel, documents, email, confirmation
MCP Tools
| Tool | Description |
|---|---|
health_check |
Server health and configuration status |
get_available_tools |
Discover all available tools |
query_data |
Execute validated SQL against Fabric |
query_revenue |
Query revenue by year/region/grouping |
query_kpi |
Query specific KPI (total_revenue, customer_count, etc.) |
get_schema |
Get complete database schema |
get_tables |
List available tables |
get_columns |
Get column details for a table |
search_glossary |
Search business term definitions |
get_kpi_definition |
Get KPI calculation logic |
search_docs |
Search business documentation (RAG) |
export_excel |
Export results to .xlsx |
generate_chart |
Generate bar/line/pie chart (PNG) |
get_query_history |
Search past queries for reuse |
check_access |
Verify user access to tables |
get_data_freshness |
Check data refresh status |
License
MIT
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.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
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.