Skip to main content
Glama

Fabric MCP Agent

by yingkiat

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"}}'
# 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:

VariableDescription
FABRIC_SQL_SERVERFully qualified Fabric Data Warehouse server hostname
FABRIC_SQL_DATABASETarget database name in Fabric
AZURE_CLIENT_IDAzure Service Principal client ID (for AAD authentication)
AZURE_CLIENT_SECRETAzure Service Principal secret
AZURE_TENANT_IDAzure tenant (directory) ID
AZURE_OPENAI_KEYAPI key for your Azure OpenAI deployment
AZURE_OPENAI_ENDPOINTEndpoint URL for Azure OpenAI (e.g., https://xxxx.openai.azure.com)
AZURE_OPENAI_DEPLOYMENTDeployment 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
-
security - not tested
F
license - not found
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

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.

  1. 🎯 MVP Status: COMPLETE ✅
    1. 🔷 Architecture Overview
      1. Layer 1: Fabric DW MCP Server
      2. Layer 2: Agentic Reasoning Layer
    2. 🚀 Production Features
      1. ✅ Complete MCP Tools
      2. ✅ Advanced Agentic Intelligence
      3. ✅ Enterprise Features
    3. 🔄 Query Formation Flow
      1. 📋 API Endpoints
        1. MCP Standard Endpoints
        2. Agentic Intelligence Endpoint
      2. 🧪 Quick Start & Testing
        1. 1. Start the Server
        2. 2. Test MCP Tools Discovery
        3. 3. Test Individual MCP Tools
        4. 4. Test Agentic Intelligence (Recommended)
        5. 5. Access the Web UI
      3. 🎯 Example Responses
        1. 🌐 Production Web UI
          1. Configuration
            1. Sample .env
          2. 📊 Performance Monitoring
            1. Real-time Dashboard
            2. Sample Metrics Output
          3. 🚀 Production Deployment

            Related MCP Servers

            • A
              security
              F
              license
              A
              quality
              Enables interaction with the Metal Framework by providing documentation search and code generation capabilities using natural language queries.
              Last updated -
              2
              2
              TypeScript
            • -
              security
              A
              license
              -
              quality
              Facilitates interaction with Microsoft SQL Server Express, supporting database operations such as querying, table management, and schema inspection via natural language MCP commands.
              Last updated -
              4
              Python
              MIT License
            • -
              security
              F
              license
              -
              quality
              A FastMCP server that provides natural language interaction with MS SQL databases, enabling users to query data, list tables, describe structures, and execute database operations through a conversational AI interface.
              Last updated -
              Python
            • -
              security
              A
              license
              -
              quality
              An MCP server that allows AI assistants to interact with Foundry datasets, ontology objects, and functions through natural language queries and commands.
              Last updated -
              8
              Python
              MIT License

            View all related MCP servers

            MCP directory API

            We provide all the information about MCP servers via our MCP API.

            curl -X GET 'https://glama.ai/api/mcp/v1/servers/yingkiat/mcp_fabric_server'

            If you have feedback or need assistance with the MCP directory API, please join our Discord server