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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。