Fabric MCP Agent

Fabric MCP Agent

Enables natural language querying of Microsoft Fabric Data Warehouses with intelligent SQL generation, metadata exploration, and business-friendly result summarization. Features two-layer architecture with MCP-compliant server and agentic AI reasoning for production-ready enterprise data access.

Category
访问服务器

README

fabric-mcp-agent

Production-Ready MVP - A complete two-layer system combining an MCP-compliant server with agentic AI reasoning for Microsoft Fabric Data Warehouse access.

🎯 MVP Status: COMPLETE

This system is fully functional and ready for production use with comprehensive logging, performance tracking, and business-optimized responses.

🔷 Architecture Overview

Layer 1: Fabric DW MCP Server

Standards-compliant MCP server with 4 complete tools providing clean abstractions over Fabric Data Warehouse operations with full Azure AD authentication.

Layer 2: Agentic Reasoning Layer

Production-ready intelligent routing system that interprets business intent, selects appropriate prompt modules, and dynamically chains MCP tools to deliver enriched answers with formatted results and business insights.

🚀 Production Features

✅ Complete MCP Tools

  • run_sql_query: Execute SQL from natural language questions or direct SQL with full error handling
  • get_metadata: Retrieve comprehensive table schemas, sample data, and relationships
  • summarize_results: Generate business-friendly summaries with actionable insights
  • generate_visualization: Create formatted data tables and chart configurations

✅ Advanced Agentic Intelligence

  • Intent Classification: Smart routing to domain-specific prompt modules with 95%+ accuracy
  • Prompt-Driven SQL: Context-aware SQL generation using business domain knowledge
  • Tool Chaining: Dynamic multi-tool orchestration for comprehensive business responses
  • Azure OpenAI Caching: Automatic response optimization for repeated queries

✅ Enterprise Features

  • Comprehensive Logging: JSON-structured logs with request tracking and performance metrics
  • Performance Monitoring: Real-time dashboard with session-based analytics
  • Error Tracking: Full error context with automated recovery mechanisms
  • Security: Azure AD authentication with read-only database access

🔄 Query Formation Flow

How Fabric DW queries are formed:

  1. User Question → Intent Router classifies intent and selects prompt module
  2. Prompt Module Integration → Loads domain-specific context (e.g., product_planning.md)
  3. LLM SQL Generation → Creates T-SQL using enhanced prompts with table schemas and business context
User: "What products are active?"
↓
Intent Router → product_planning.md
↓ 
Enhanced Prompt: "[Context from product_planning module + User question]"
↓
LLM → SELECT * FROM JPNPROdb_ps_mstr WHERE status = 'active'

📋 API Endpoints

MCP Standard Endpoints

  • GET /list_tools - Returns all available MCP tools with schemas
  • POST /call_tool - Execute specific MCP tool with arguments

Agentic Intelligence Endpoint

  • POST /mcp - Full agentic reasoning with intent classification and tool chaining

🧪 Quick Start & Testing

1. Start the Server

python main.py

(Ensure .env is configured with Azure credentials)

2. Test MCP Tools Discovery

curl http://localhost:8000/list_tools

3. Test Individual MCP Tools

# Get table metadata
curl -X POST http://localhost:8000/call_tool -H "Content-Type: application/json" \
-d '{"tool": "get_metadata", "args": {"table_name": "JPNPROdb_ps_mstr"}}'

# Execute SQL query
curl -X POST http://localhost:8000/call_tool -H "Content-Type: application/json" \
-d '{"tool": "run_sql_query", "args": {"question": "Show me active products"}}'

4. Test Agentic Intelligence (Recommended)

# Full reasoning with intent classification and tool chaining
curl -X POST http://localhost:8000/mcp -H "Content-Type: application/json" \
-d '{"question": "tell me the components in MRH-011C"}'

5. Access the Web UI

# Open your browser and visit:
http://localhost:8000

🎯 Example Responses

The agentic /mcp endpoint returns enriched responses:

{
  "question": "tell me the components in MRH-011C",
  "response": "**Answer**: Found 8 components for product MRH-011C...",
  "classification": {"intent": "product_planning", "confidence": 0.95},
  "tool_chain_results": {
    "get_metadata": {...},
    "run_sql_query": {"results": [...]},
    "summarize_results": {...}
  }
}

🌐 Production Web UI

  • Component Analysis: Optimized for product planning queries like "tell me the components in MRH-011C"
  • Formatted Results: SQL results displayed in interactive tables with hover effects
  • Real-time Testing: All endpoints accessible through responsive browser interface
  • Quick Test Buttons: Pre-built queries for common business scenarios
  • Request Tracking: Each query shows unique request ID for monitoring and debugging

Configuration

The server requires the following environment variables in a .env file located in the project root:

Variable Description
FABRIC_SQL_SERVER Fully qualified Fabric Data Warehouse server hostname
FABRIC_SQL_DATABASE Target database name in Fabric
AZURE_CLIENT_ID Azure Service Principal client ID (for AAD authentication)
AZURE_CLIENT_SECRET Azure Service Principal secret
AZURE_TENANT_ID Azure tenant (directory) ID
AZURE_OPENAI_KEY API key for your Azure OpenAI deployment
AZURE_OPENAI_ENDPOINT Endpoint URL for Azure OpenAI (e.g., https://xxxx.openai.azure.com)
AZURE_OPENAI_DEPLOYMENT Deployment name (e.g., "gpt-4o")

Sample .env

FABRIC_SQL_SERVER=jzd3bvvlcs5udln5rq47r4qvqi-qdrgdhglbgcezlr5igxskwv6ki.datawarehouse.fabric.microsoft.com
FABRIC_SQL_DATABASE=unified_data_warehouse
AZURE_CLIENT_ID=<your-azure-service-principal-client-id>
AZURE_CLIENT_SECRET=<your-azure-service-principal-secret>
AZURE_TENANT_ID=<your-azure-tenant-id>
AZURE_OPENAI_KEY=<your-azure-openai-key>
AZURE_OPENAI_ENDPOINT=https://<your-resource>.openai.azure.com
AZURE_OPENAI_DEPLOYMENT=gpt-4o

📊 Performance Monitoring

Real-time Dashboard

python performance_dashboard.py

Sample Metrics Output

MCP AGENT PERFORMANCE DASHBOARD
================================================================================

REQUEST METRICS
Total Requests: 15
Successful: 15 (100.0%)
Failed: 0

BUSINESS SESSION PERFORMANCE
Avg Question-to-Answer Time: 12,845ms (12.8s)
95th Percentile: 25,300ms (25.3s)

AI USAGE PER BUSINESS QUESTION
Avg API Calls per Question: 2.0
Avg Tokens per Question: 26,920
Estimated Cost per Question: $0.1346

🚀 Production Deployment

This MVP is ready for production deployment with:

  • ✅ Full error handling and recovery
  • ✅ Comprehensive logging and monitoring
  • ✅ Performance optimization with AI caching
  • ✅ Security best practices implemented
  • ✅ Scalable architecture for extension

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选