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
Visit Server

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

Recommended Servers

playwright-mcp

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured