Agentic-Power-BI-MCP-Server

nabilraddaoui/Agentic-Power-BI-MCP-Server

3.2

If you are the rightful owner of Agentic-Power-BI-MCP-Server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

Agentic-Power-BI-MCP-Server is a specialized server designed to facilitate seamless integration and communication between Power BI and various data sources using the Model Context Protocol (MCP).

Agentic Power BI MCP Server

A Model Context Protocol (MCP) server that enables Claude to autonomously create and manage Power BI reports through PBIP (Power BI Project), TMDL (Tabular Model Definition Language), and PBIR (Power BI Report) formats.

Features

🗂️ TMDL Manipulation

  • Create and manage tables with columns and data types
  • Create, update, and delete DAX measures
  • Define relationships between tables
  • Full semantic model management

📊 PBIR Report Generation

  • Create report structures
  • Add and configure pages
  • Add visuals with positioning and data bindings
  • Support for all major visual types (charts, tables, cards, maps, slicers)

🎨 Intelligent Recommendations

  • Analyze layout mockups to suggest visual placements
  • Recommend appropriate visual types based on data and goals
  • Suggest DAX measures based on business context
  • Context-aware best practice suggestions

✅ Auto-Validation

  • DAX syntax validation with error detection
  • TMDL structure validation
  • PBIR report validation
  • Best practices checker for performance and design

📚 Knowledge Base

  • Comprehensive Power BI and DAX best practices
  • PBIP structure guidelines
  • Performance optimization tips
  • Visual design principles

Installation

npm install
npm run build

Usage

As an MCP Server

Configure your MCP client (like Claude Desktop) to use this server:

{
  "mcpServers": {
    "powerbi": {
      "command": "node",
      "args": ["/path/to/agentic-power-bi-mcp-server/dist/index.js"]
    }
  }
}

Available Tools

TMDL Tools

create_table - Create a new table in the semantic model

{
  projectPath: string,
  tableName: string,
  columns: Array<{
    name: string,
    dataType: string,
    sourceColumn?: string
  }>,
  partitions?: Array<{...}>
}

create_measure - Add a DAX measure to a table

{
  projectPath: string,
  tableName: string,
  measureName: string,
  expression: string,
  formatString?: string,
  description?: string
}

create_relationship - Define relationships between tables

{
  projectPath: string,
  fromTable: string,
  fromColumn: string,
  toTable: string,
  toColumn: string,
  crossFilterDirection?: "OneDirection" | "BothDirections",
  cardinality?: "OneToMany" | "ManyToOne" | "OneToOne"
}

list_tables - List all tables in the model

list_measures - List all measures (optionally filtered by table)

update_table - Update table definition

update_measure - Update measure expression or formatting

delete_measure - Remove a measure from a table

PBIR Tools

create_report - Initialize report structure

{
  projectPath: string,
  reportName: string
}

add_page - Add a page to the report

{
  projectPath: string,
  pageName: string,
  displayName?: string,
  width?: number,  // default: 1280
  height?: number  // default: 720
}

add_visual - Add a visual to a page

{
  projectPath: string,
  pageName: string,
  visualType: string,  // e.g., "card", "barChart", "lineChart"
  x: number,
  y: number,
  width: number,
  height: number,
  dataFields?: {
    axis?: string[],
    values?: string[],
    legend?: string[]
  },
  title?: string
}

list_pages - List all pages in the report

update_visual - Update visual properties

get_report_structure - Get complete report structure

Recommendation Tools

analyze_layout_from_image - Analyze mockup images for layout extraction

{
  imagePath?: string,
  imageData?: string  // base64 encoded
}

recommend_visuals - Get visual type recommendations

{
  dataDescription: string,
  analysisGoal: string,  // e.g., "trend over time", "comparison"
  dataTypes?: {
    numerical?: string[],
    categorical?: string[],
    temporal?: string[],
    geographical?: string[]
  }
}

recommend_measures - Get DAX measure suggestions

{
  projectPath?: string,
  businessContext: string,  // e.g., "sales analysis"
  existingTables?: string[]
}
Validation Tools

validate_dax - Validate DAX expression syntax

{
  expression: string,
  context?: object
}

validate_tmdl - Validate semantic model structure

{
  projectPath: string
}

validate_pbir - Validate report structure

{
  projectPath: string
}

check_best_practices - Check against best practices

{
  projectPath: string,
  checkTypes?: ["dax" | "model" | "performance" | "visual" | "all"]
}

Resources

powerbi://kb/best-practices - Access the comprehensive Power BI and DAX knowledge base

Project Structure

When working with this server, it expects/creates the following PBIP structure:

YourProject/
├── .SemanticModel/
│   └── definition/
│       ├── tables/
│       │   ├── Sales.tmdl
│       │   ├── Products.tmdl
│       │   └── Calendar.tmdl
│       └── relationships/
│           └── Sales_Products.tmdl
└── .Report/
    ├── report.json
    └── definition/
        ├── report.tmdl
        └── pages/
            ├── Overview.json
            └── Details.json

Example Workflow

// 1. Create tables for semantic model
await createTable({
  projectPath: "./MyReport",
  tableName: "Sales",
  columns: [
    { name: "OrderID", dataType: "Int64" },
    { name: "OrderDate", dataType: "DateTime" },
    { name: "Amount", dataType: "Decimal" }
  ]
});

// 2. Add measures
await createMeasure({
  projectPath: "./MyReport",
  tableName: "Sales",
  measureName: "Total Sales",
  expression: "SUM(Sales[Amount])",
  formatString: "$#,0.00"
});

// 3. Create report
await createReport({
  projectPath: "./MyReport",
  reportName: "Sales Report"
});

// 4. Add page
await addPage({
  projectPath: "./MyReport",
  pageName: "Overview",
  displayName: "Sales Overview"
});

// 5. Add visuals
await addVisual({
  projectPath: "./MyReport",
  pageName: "Overview",
  visualType: "card",
  x: 10,
  y: 10,
  width: 200,
  height: 100,
  dataFields: {
    values: ["Total Sales"]
  },
  title: "Total Sales"
});

// 6. Validate
await validateTMDL({ projectPath: "./MyReport" });
await checkBestPractices({ 
  projectPath: "./MyReport",
  checkTypes: ["all"]
});

Best Practices

Data Modeling

  • Use star schema with fact and dimension tables
  • Create a dedicated date table for time intelligence
  • Define proper relationships (prefer one-to-many)
  • Choose appropriate data types to minimize model size

DAX Measures

  • Use VAR for readability and performance
  • Use DIVIDE() instead of "/" for division
  • Add format strings and descriptions
  • Test with edge cases (empty filters, division by zero)

Report Design

  • 5-7 visuals per page for optimal performance
  • Place KPIs at the top of the page
  • Use consistent colors and formatting
  • Add meaningful titles to all visuals

Performance

  • Remove unused columns and tables
  • Use Import mode instead of DirectQuery when possible
  • Avoid calculated columns for simple aggregations
  • Limit high-cardinality text columns

Inspiration

This project is inspired by RuiRomano/pbip-demo-agentic, demonstrating the power of combining Power BI's file-based format with AI-driven development workflows.

Knowledge Base

The included kb-pbip.md file contains comprehensive documentation on:

  • PBIP structure and benefits
  • TMDL syntax and patterns
  • PBIR JSON structure
  • DAX best practices and common patterns
  • Data modeling principles
  • Performance optimization techniques
  • Visual design guidelines
  • Testing and validation approaches

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

License

MIT