Skip to main content
Glama
MCP Data Pipeline Assistant

MCP Data Pipeline Assistant

by guna-thota
README.md
# MCP Data Pipeline Assistant

> **Natural language control over Azure Data Factory pipelines and Delta Lake — powered by Claude and the Model Context Protocol.**

[![CI](https://github.com/guna-thota/mcp-data-pipeline-assistant/actions/workflows/ci.yml/badge.svg)](https://github.com/guna-thota/mcp-data-pipeline-assistant/actions/workflows/ci.yml)
[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
[![MCP](https://img.shields.io/badge/MCP-1.3.0-green.svg)](https://modelcontextprotocol.io)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/guna-thota/mcp-data-pipeline-assistant)

---

## What This Does

Instead of writing scripts or navigating cloud consoles to manage data pipelines, this project lets you talk to them directly through Claude:

```
You:    "Show me all failed pipelines from the last 24 hours"
Claude: ❌ healthcare_ingestion_pipeline — Schema mismatch on patient_id
        ❌ billing_reconciliation_pipeline — SQL Server connection timeout

You:    "What's the average failure rate per pipeline over the last 30 days?"
Claude: patient_records_etl          — 22.9% failure rate
        healthcare_ingestion_pipeline — 14.3% failure rate
        delta_lake_refresh_pipeline   — 8.6%  failure rate

You:    "Trigger the healthcare ingestion pipeline"
Claude: 🚀 Pipeline queued. Run ID: adf-run-ed368a9a. SLA: 30 minutes.
```

---

## Architecture

```
┌─────────────────────────────────────────┐
│           Claude (via MCP)              │
│   Natural language → tool selection     │
└────────────────┬────────────────────────┘
                 │ MCP Protocol (stdio)
┌────────────────▼────────────────────────┐
│         MCP Server (server.py)          │
│   5 tools exposed as MCP primitives     │
└──────┬──────────────┬───────────────────┘
       │              │
┌──────▼──────┐  ┌────▼──────────────────┐
│  ADF Layer  │  │   Delta Lake Layer     │
│             │  │                        │
│ • Pipeline  │  │ • DuckDB query engine  │
│   status    │  │ • Parquet storage      │
│ • Trigger   │  │ • 35 days of metrics   │
│   runs      │  │ • Preset SQL queries   │
│ • List all  │  │ • Custom SQL support   │
└─────────────┘  └────────────────────────┘
       │
  [Mock data]           [Production]
  JSON files    →    azure-mgmt-datafactory
  (dev/demo)         REST API calls
```

---

## MCP Tools

| Tool | Description |
|------|-------------|
| `get_pipeline_status` | Fetch ADF pipeline run history — filter by name, time window, or status |
| `trigger_pipeline` | Trigger a named ADF pipeline run with optional parameters |
| `query_delta_table` | Run SQL against Delta Lake pipeline metrics using DuckDB |
| `list_pipelines` | List all pipelines with schedules, SLA targets, and descriptions |
| `get_table_schema` | Return Delta Lake table schema for query reference |

---

## Project Structure

```
mcp-data-pipeline-assistant/
├── server.py                        # MCP server — entry point
├── demo.py                          # Run all tools without Claude
├── requirements.txt
├── .env.example                     # Environment variable template
├── .gitignore
│
├── tools/
│   ├── pipeline_status.py           # get_pipeline_status tool
│   ├── trigger_pipeline.py          # trigger_pipeline tool
│   └── query_delta.py               # query_delta_table tool
│
├── mock_data/
│   ├── pipeline_runs.json           # 10 realistic ADF run records
│   ├── pipeline_definitions.json    # 4 pipeline configs with metadata
│   ├── generate_delta_data.py       # Generates 35 days of metrics
│   └── metrics_delta/               # Delta Lake table (Parquet + _delta_log)
│       ├── pipeline_metrics.parquet
│       └── _delta_log/
│           └── 00000000000000000000.json
│
├── tests/
│   └── test_tools.py                # 23 unit tests across all tools
│
├── .devcontainer/
│   └── devcontainer.json            # GitHub Codespaces config
│
└── .github/
    └── workflows/
        └── ci.yml                   # GitHub Actions CI pipeline
```

---

## Quick Start

### Option 1: GitHub Codespaces (no installs needed)

1. Click **"Open in GitHub Codespaces"** badge above
2. Wait ~60 seconds for the environment to build
3. In the Codespaces terminal:

```bash
python demo.py
```

All 10 demo scenarios run immediately. No setup required.

### Option 2: Local Setup

```bash
# Clone the repo
git clone https://github.com/guna-thota/mcp-data-pipeline-assistant.git
cd mcp-data-pipeline-assistant

# Install dependencies
pip install -r requirements.txt

# Generate Delta Lake mock data
python mock_data/generate_delta_data.py

# Run the demo
python demo.py

# Run tests
python -m pytest tests/ -v
```

---

## Connecting to Claude Desktop

To use this as a live MCP server with Claude Desktop:

**1. Install Claude Desktop** from [claude.ai/download](https://claude.ai/download)

**2. Find your config file:**
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`

**3. Add the MCP server config:**

```json
{
  "mcpServers": {
    "data-pipeline-assistant": {
      "command": "python",
      "args": ["/absolute/path/to/mcp-data-pipeline-assistant/server.py"]
    }
  }
}
```

**4. Restart Claude Desktop.** You will see the tools available in the Claude interface.

**5. Try these prompts:**
- *"Show me all pipeline failures from the last 48 hours"*
- *"What's the failure rate for each pipeline over the last 30 days?"*
- *"Trigger the patient records ETL pipeline"*
- *"Which pipeline has the most SLA breaches?"*
- *"Show me average run duration by pipeline"*

---

## Delta Lake Preset Queries

Four preset queries are built in and accessible via Claude or directly:

```python
from tools.query_delta import get_preset_query

# Failure rate by pipeline
get_preset_query("failure_rate")

# SLA breach history
get_preset_query("sla_breaches")

# Average run duration
get_preset_query("avg_duration")

# Daily records processed
get_preset_query("daily_records")
```

Custom SQL is also fully supported:

```python
from tools.query_delta import query_delta_table

result = query_delta_table("""
    SELECT pipeline_name, SUM(records_processed) as total
    FROM pipeline_metrics
    WHERE run_date >= '2026-04-01'
    GROUP BY pipeline_name
    ORDER BY total DESC
""")
print(result["formatted_table"])
```

---

## Connecting to Real Azure Data Factory

The mock layer is a drop-in replacement for the real ADF REST API. To switch to production:

**1. Add Azure credentials to `.env`:**

```bash
cp .env.example .env
# Fill in your Azure values
```

**2. Replace the mock call in `tools/pipeline_status.py`:**

```python
# Replace this mock:
with open(DATA_PATH) as f:
    all_runs = json.load(f)

# With this real ADF call:
from azure.mgmt.datafactory import DataFactoryManagementClient
from azure.identity import DefaultAzureCredential

credential = DefaultAzureCredential()
client = DataFactoryManagementClient(credential, os.getenv("AZURE_SUBSCRIPTION_ID"))

filter_params = RunFilterParameters(
    last_updated_after=cutoff,
    last_updated_before=datetime.utcnow()
)
runs = client.pipeline_runs.query_by_factory(
    os.getenv("AZURE_RESOURCE_GROUP"),
    os.getenv("AZURE_DATA_FACTORY_NAME"),
    filter_params
)
```

**3. Replace the mock trigger in `tools/trigger_pipeline.py`:**

```python
# Replace mock return with:
run_response = client.pipelines.create_run(
    os.getenv("AZURE_RESOURCE_GROUP"),
    os.getenv("AZURE_DATA_FACTORY_NAME"),
    pipeline_name,
    parameters=parameters or {}
)
return {"success": True, "run_id": run_response.run_id, ...}
```

No other changes needed. The MCP server and tools layer stay identical.

---

## Running Tests

```bash
python -m pytest tests/ -v
```

```
23 passed in 1.50s

TestPipelineStatus   — 7 tests
TestTriggerPipeline  — 6 tests
TestQueryDelta       — 10 tests
```

---

## Tech Stack

| Layer | Technology |
|-------|-----------|
| AI / LLM | Claude (Anthropic) |
| Protocol | Model Context Protocol (MCP) 1.3.0 |
| Pipeline Orchestration | Azure Data Factory (mocked → real) |
| Data Storage | Delta Lake |
| Query Engine | DuckDB |
| Data Processing | PySpark / Pandas / PyArrow |
| Language | Python 3.11+ |
| CI | GitHub Actions |
| Dev Environment | GitHub Codespaces |

---

## Why This Project

Most data engineering teams manually check Azure Portal dashboards or write one-off scripts to debug pipeline failures. This project demonstrates how MCP can act as a structured interface between a production data stack and an AI assistant; enabling natural language pipeline observability without sacrificing accuracy, traceability, or control.

The same architecture extends to any data platform: Databricks, Airflow, dbt, Redshift, or Snowflake.

---

## Author

**Guna Durga Prashanth Thota**
Data Engineer — Azure | Databricks | PySpark | Delta Lake | MCP

[LinkedIn](https://linkedin.com/in/gthota27) · [GitHub](https://github.com/guna-thota) · [Portfolio](https://guna-thota.vercel.app)

---

## License

MIT License — see [LICENSE](LICENSE) for details.