How to integrate Microsoft Power Bi MCP with CrewAI

This guide walks you through connecting Microsoft Power Bi to CrewAI using the Composio tool router. By the end, you'll have a working Microsoft Power Bi agent that can list dashboards in your workspace, refresh the sales performance dataset, summarize quarterly revenue report insights through natural language commands. This guide will help you understand how to give your CrewAI agent real control over a Microsoft Power Bi account through Composio's Microsoft Power Bi MCP server. Before we dive in, let's take a quick look at the key ideas and tools involved.

Microsoft Power Bi logoMicrosoft Power Bi
Oauth2

Microsoft Power BI is Microsoft's business analytics service for dashboards, reports, datasets, and interactive data visualizations. Use it to turn business data into clear insights that teams can explore, share, and act on.

116 Tools

Introduction

This guide walks you through connecting Microsoft Power Bi to CrewAI using the Composio tool router. By the end, you'll have a working Microsoft Power Bi agent that can list dashboards in your workspace, refresh the sales performance dataset, summarize quarterly revenue report insights through natural language commands.

This guide will help you understand how to give your CrewAI agent real control over a Microsoft Power Bi account through Composio's Microsoft Power Bi MCP server.

Before we dive in, let's take a quick look at the key ideas and tools involved.

Also integrate Microsoft Power Bi with

TL;DR

Here's what you'll learn:
  • Get a Composio API key and configure your Microsoft Power Bi connection
  • Set up CrewAI with an MCP enabled agent
  • Create a Tool Router session or standalone MCP server for Microsoft Power Bi
  • Build a conversational loop where your agent can execute Microsoft Power Bi operations

What is CrewAI?

CrewAI is a powerful framework for building multi-agent AI systems. It provides primitives for defining agents with specific roles, creating tasks, and orchestrating workflows through crews.

Key features include:

  • Agent Roles: Define specialized agents with specific goals and backstories
  • Task Management: Create tasks with clear descriptions and expected outputs
  • Crew Orchestration: Combine agents and tasks into collaborative workflows
  • MCP Integration: Connect to external tools through Model Context Protocol

What is the Microsoft Power Bi MCP server, and what's possible with it?

The Microsoft Power Bi MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Microsoft Power Bi account. It provides structured and secure access to your workspaces, dashboards, reports, datasets, dataflows, and scorecards, so your agent can create analytics resources, retrieve business insights, run DAX queries, manage reports, and prepare content for embedding on your behalf.

  • Workspace and dashboard management: Have your agent create or delete workspaces, add dashboards, and list the dashboards available in a workspace.
  • Report and dataset operations: Let the agent retrieve datasets, list reports from an app, clone reports, delete reports, and create push datasets.
  • Business data analysis: Direct your agent to run DAX queries against Power BI datasets and return the results for analysis or summaries.
  • Scorecard and goal tracking: Instruct your agent to create scorecards, record goal value check-ins, and remove goals, notes, or status rules when needed.
  • Embedded analytics access: Have your agent generate viewing or editing tokens for dashboards, reports, and datasets that you want to embed in an application.

What is the Composio tool router, and how does it fit here?

What is Composio SDK?

Composio's Composio SDK helps agents find the right tools for a task at runtime. You can plug in multiple toolkits (like Gmail, HubSpot, and GitHub), and the agent will identify the relevant app and action to complete multi-step workflows. This can reduce token usage and improve the reliability of tool calls. Read more here: Getting started with Composio SDK

The tool router generates a secure MCP URL that your agents can access to perform actions.

How the Composio SDK works

The Composio SDK follows a three-phase workflow:

  1. Discovery: Searches for tools matching your task and returns relevant toolkits with their details.
  2. Authentication: Checks for active connections. If missing, creates an auth config and returns a connection URL via Auth Link.
  3. Execution: Executes the action using the authenticated connection.

Step-by-step Guide

Step by step08 STEPS
1

Prerequisites

Before starting, make sure you have:
  • Python 3.9 or higher
  • A Composio account and API key
  • A Microsoft Power Bi connection authorized in Composio
  • An OpenAI API key for the CrewAI LLM
  • Basic familiarity with Python
2

Getting API Keys for OpenAI and Composio

OpenAI API Key
  • Go to the OpenAI dashboard and create an API key. You'll need credits to use the models, or you can connect to another model provider.
  • Keep the API key safe.
Composio API Key
  • Log in to the Composio dashboard.
  • Navigate to your API settings and generate a new API key.
  • Store this key securely as you'll need it for authentication.
3

Install dependencies

bash
pip install composio crewai crewai-tools[mcp] python-dotenv
What's happening:
  • composio connects your agent to Microsoft Power Bi via MCP
  • crewai provides Agent, Task, Crew, and LLM primitives
  • crewai-tools[mcp] includes MCP helpers
  • python-dotenv loads environment variables from .env
4

Set up environment variables

bash
COMPOSIO_API_KEY=your_composio_api_key_here
USER_ID=your_user_id_here
OPENAI_API_KEY=your_openai_api_key_here

Create a .env file in your project root.

What's happening:

  • COMPOSIO_API_KEY authenticates with Composio
  • USER_ID scopes the session to your account
  • OPENAI_API_KEY lets CrewAI use your chosen OpenAI model
5

Import dependencies

python
import os
from composio import Composio
from crewai import Agent, Task, Crew
from crewai_tools import MCPServerAdapter
import dotenv

dotenv.load_dotenv()

COMPOSIO_API_KEY = os.getenv("COMPOSIO_API_KEY")
COMPOSIO_USER_ID = os.getenv("COMPOSIO_USER_ID")

if not COMPOSIO_API_KEY:
    raise ValueError("COMPOSIO_API_KEY is not set")
if not COMPOSIO_USER_ID:
    raise ValueError("COMPOSIO_USER_ID is not set")
What's happening:
  • CrewAI classes define agents and tasks, and run the workflow
  • MCPServerHTTP connects the agent to an MCP endpoint
  • Composio will give you a short lived Microsoft Power Bi MCP URL
6

Create a Composio Tool Router session for Microsoft Power Bi

python
composio_client = Composio(api_key=COMPOSIO_API_KEY)
session = composio_client.create(user_id=COMPOSIO_USER_ID, toolkits=["microsoft_power_bi"])

url = session.mcp.url
What's happening:
  • You create a Microsoft Power Bi only session through Composio
  • Composio returns an MCP HTTP URL that exposes Microsoft Power Bi tools
7

Initialize the MCP Server

python
server_params = {
    "url": url,
    "transport": "streamable-http",
    "headers": {"x-api-key": COMPOSIO_API_KEY},
}

with MCPServerAdapter(server_params) as tools:
    agent = Agent(
        role="Search Assistant",
        goal="Help users search the internet effectively",
        backstory="You are a helpful assistant with access to search tools.",
        tools=tools,
        verbose=False,
        max_iter=10,
    )
What's Happening:
  • Server Configuration: The code sets up connection parameters including the MCP server URL, streamable HTTP transport, and Composio API key authentication.
  • MCP Adapter Bridge: MCPServerAdapter acts as a context manager that converts Composio MCP tools into a CrewAI-compatible format.
  • Agent Setup: Creates a CrewAI Agent with a defined role (Search Assistant), goal (help with internet searches), and access to the MCP tools.
  • Configuration Options: The agent includes settings like verbose=False for clean output and max_iter=10 to prevent infinite loops.
  • Dynamic Tool Usage: Once created, the agent automatically accesses all Composio Search tools and decides when to use them based on user queries.
8

Create a CLI Chatloop and define the Crew

python
print("Chat started! Type 'exit' or 'quit' to end.\n")

conversation_context = ""

while True:
    user_input = input("You: ").strip()

    if user_input.lower() in ["exit", "quit", "bye"]:
        print("\nGoodbye!")
        break

    if not user_input:
        continue

    conversation_context += f"\nUser: {user_input}\n"
    print("\nAgent is thinking...\n")

    task = Task(
        description=(
            f"Conversation history:\n{conversation_context}\n\n"
            f"Current request: {user_input}"
        ),
        expected_output="A helpful response addressing the user's request",
        agent=agent,
    )

    crew = Crew(agents=[agent], tasks=[task], verbose=False)
    result = crew.kickoff()
    response = str(result)

    conversation_context += f"Agent: {response}\n"
    print(f"Agent: {response}\n")
What's Happening:
  • Interactive CLI Setup: The code creates an infinite loop that continuously prompts for user input and maintains the entire conversation history in a string variable.
  • Input Validation: Empty inputs are ignored to prevent processing blank messages and keep the conversation clean.
  • Context Building: Each user message is appended to the conversation context, which preserves the full dialogue history for better agent responses.
  • Dynamic Task Creation: For every user input, a new Task is created that includes both the full conversation history and the current request as context.
  • Crew Execution: A Crew is instantiated with the agent and task, then kicked off to process the request and generate a response.
  • Response Management: The agent's response is converted to a string, added to the conversation context, and displayed to the user, maintaining conversational continuity.

Complete Code

Here's the complete code to get you started with Microsoft Power Bi and CrewAI:

python
from crewai import Agent, Task, Crew, LLM
from crewai_tools import MCPServerAdapter
from composio import Composio
from dotenv import load_dotenv
import os

load_dotenv()

GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
COMPOSIO_API_KEY = os.getenv("COMPOSIO_API_KEY")
COMPOSIO_USER_ID = os.getenv("COMPOSIO_USER_ID")

if not GOOGLE_API_KEY:
    raise ValueError("GOOGLE_API_KEY is not set in the environment.")
if not COMPOSIO_API_KEY:
    raise ValueError("COMPOSIO_API_KEY is not set in the environment.")
if not COMPOSIO_USER_ID:
    raise ValueError("COMPOSIO_USER_ID is not set in the environment.")

# Initialize Composio and create a session
composio = Composio(api_key=COMPOSIO_API_KEY)
session = composio.create(
    user_id=COMPOSIO_USER_ID,
    toolkits=["microsoft_power_bi"],
)
url = session.mcp.url

# Configure LLM
llm = LLM(
    model="gpt-5",
    api_key=os.getenv("OPENAI_API_KEY"),
)

server_params = {
    "url": url,
    "transport": "streamable-http",
    "headers": {"x-api-key": COMPOSIO_API_KEY},
}

with MCPServerAdapter(server_params) as tools:
    agent = Agent(
        role="Search Assistant",
        goal="Help users with internet searches",
        backstory="You are an expert assistant with access to Composio Search tools.",
        tools=tools,
        llm=llm,
        verbose=False,
        max_iter=10,
    )

    print("Chat started! Type 'exit' or 'quit' to end.\n")

    conversation_context = ""

    while True:
        user_input = input("You: ").strip()

        if user_input.lower() in ["exit", "quit", "bye"]:
            print("\nGoodbye!")
            break

        if not user_input:
            continue

        conversation_context += f"\nUser: {user_input}\n"
        print("\nAgent is thinking...\n")

        task = Task(
            description=(
                f"Conversation history:\n{conversation_context}\n\n"
                f"Current request: {user_input}"
            ),
            expected_output="A helpful response addressing the user's request",
            agent=agent,
        )

        crew = Crew(agents=[agent], tasks=[task], verbose=False)
        result = crew.kickoff()
        response = str(result)

        conversation_context += f"Agent: {response}\n"
        print(f"Agent: {response}\n")

Conclusion

You now have a CrewAI agent connected to Microsoft Power Bi through Composio's Tool Router. The agent can perform Microsoft Power Bi operations through natural language commands.

Next steps:

  • Add role-specific instructions to customize agent behavior
  • Plug in more toolkits for multi-app workflows
  • Chain tasks for complex multi-step operations
TOOLS

Supported Tools

Every Microsoft Power Bi action and event your agent gets out of the box.

Add Dashboard to Workspace

Creates a new empty dashboard in the specified workspace.

Get Reports From App

Returns a list of reports from the specified app.

Assign Workspace to Capacity

Assigns the specified workspace to the specified capacity.

Cancel Dataset Refresh in Workspace

Cancels the specified refresh operation for the specified dataset from the specified workspace.

Clone Report

Clones the specified report from My workspace.

Clone Report in Workspace

Clones the specified report from the specified workspace.

Create Goal Value Check-in

Creates a new goal value check-in for a Power BI scorecard goal.

Create Workspace

Creates a new workspace in Power BI.

Create Push Dataset

Creates a new dataset on My workspace in Power BI.

Create Scorecard

Creates a new scorecard in the specified Power BI workspace.

Create Temporary Upload Location

Creates a temporary blob storage upload location for importing large Power BI .

Create Temporary Upload Location

Creates a temporary blob storage upload location for importing large Power BI .

Delete Dashboard

Deletes the specified dashboard from My workspace.

Delete Dataflow

Deletes the specified dataflow from Power BI data prep storage, including its definition file and model.

Delete Dataset

Deletes the specified dataset from My workspace.

Delete Dataset from Workspace

Deletes the specified dataset from the specified workspace.

Delete Goal

Deletes a goal from a scorecard by goal ID.

Delete Goal Note by ID

Deletes a goal value check-in note by its unique identifier.

Delete Goal Status Rules

Removes status rule definitions from a goal.

Delete Pipeline User

Removes user permissions from the specified deployment pipeline.

Delete Report from Workspace

Deletes the specified report from the specified workspace.

Delete Rows from Dataset Table

Deletes all rows from the specified table within the specified dataset from My workspace.

Delete Rows from Dataset Table in Workspace

Deletes all rows from the specified table within the specified dataset from the specified workspace.

Delete Scorecard By ID

Deletes a scorecard by its ID from the specified workspace.

Delete Workspace

Deletes the specified workspace.

Discover Gateways for Dataset

Returns a list of gateways that the specified dataset from the specified workspace can be bound to.

Execute DAX Queries

Executes Data Analysis Expressions (DAX) queries against the provided dataset in My workspace.

Execute DAX Queries on Dataset

Executes Data Analysis Expressions (DAX) queries against the specified Power BI dataset.

Execute Subscription

Executes the Subscription specified by the Id.

Generate Dashboard Embed Token

Generates an embed token to view or edit the specified dashboard from the specified workspace.

Generate Embed Token for Power BI

Generates an embed token for multiple reports, datasets, and target workspaces.

Generate Report Embed Token in Group

Generates an embed token to view or edit the specified report from the specified workspace.

Generate Dataset Embed Token in Group

Generates an embed token based on the specified dataset from the specified workspace.

Get Available Feature By Name

Returns the specified available feature for the user by name.

Get Capacities

Returns a list of Power BI capacities that the authenticated user has access to.

Get Dashboard from My Workspace

Returns the specified dashboard from My workspace.

Get Dashboards

Returns a list of dashboards from the specified workspace.

Get Dataflows

Returns a list of all dataflows from the specified workspace.

Get Dataset

Returns the specified dataset from My workspace.

Get Dataset in Workspace

Returns the specified dataset from the specified workspace.

Get DataSet Data

Gets the query results for the specified DataSet.

Get Datasets from My Workspace

Returns a list of datasets from My workspace.

Get DataSets from Power BI

Gets an array of DataSet CatalogItems from Power BI.

Get Dataset to Dataflows Links

Returns a list of upstream dataflows for datasets from the specified workspace.

Get Dataset Users

Returns a list of principals that have access to the specified dataset.

Get Dataset Users In Group

Returns a list of principals that have access to the specified dataset within a workspace.

Get Datasources for Dataset

Returns a list of data sources for the specified dataset from My workspace.

Get Datasources for Dataset in Workspace

Returns a list of data sources for the specified dataset from the specified workspace.

Get Gateway

Returns the specified gateway.

Get Gateway Datasources in Group

Returns a list of gateway data sources for the specified dataset from the specified workspace.

Get Gateways

Returns a list of gateways for which the user is an admin.

Get Goals from Scorecard

Returns a list of goals from a scorecard.

Get Goals Refresh History

Reads refresh history of a connected goal.

Get Goals Status Rules

Returns status rules of a goal.

Get Goal Value By ID

Reads a goal value check-in by a UTC date timestamp.

Get Groups

Returns a list of workspaces the user has access to.

Get Groups Capacity Assignment Status

Gets the status of the assignment-to-capacity operation for the specified workspace.

Get Group Users

Returns a list of users that have access to the specified workspace.

Get Import

Returns the specified import from My workspace.

Get Imports from My Workspace

Returns a list of imports from My workspace.

Get Imports in Workspace

Returns a list of imports from the specified workspace.

Get Linked Report History Snapshot

Gets requested HistorySnapshot item specified by HistoryId of the LinkedReport specified by Id.

Get Report Page

Returns the specified page within the specified report from the specified workspace.

Get Pages from Report

Returns a list of pages within the specified report from the specified workspace.

Get Pages from Report in My Workspace

Returns a list of pages within the specified report from My workspace.

Get Dataset Parameters

Returns a list of parameters for the specified dataset from **My workspace**.

Get Dataset Parameters in Workspace

Returns a list of parameters for the specified dataset from the specified workspace.

Get Query Scale Out Sync Status

Returns the query scale-out sync status for the specified dataset from the specified workspace.

Get Refreshable For Capacity

Returns the specified refreshable for the specified capacity that the user has access to.

Get refreshables for all capacities

Returns a list of refreshables for all capacities that the user has access to.

Get Refresh Execution Details In Group

Returns execution details of a refresh operation for the specified dataset from the specified workspace.

Get Refresh History for Dataset

Returns the refresh history for the specified dataset from My workspace.

Get Dataset Refresh Schedule

Returns the refresh schedule for the specified dataset from My workspace.

Get Refresh Schedule In Group 2

Returns the refresh schedule for the specified dataset from the specified workspace.

Get Report from My Workspace

Returns the specified report from My workspace.

Get Report Page From My Workspace

Returns the specified page within the specified report from My workspace.

Get Reports

Gets an array of Report CatalogItems from Power BI.

Get Reports From My Workspace

Returns a list of reports from My workspace.

Get Resources

Gets an array of Resource catalog items.

Get Scorecard By ID

Returns a scorecard with the specified ID.

Get Scorecards

Returns a list of scorecards from a workspace.

Get Tables in Dataset

Returns a list of tables within the specified dataset from My workspace.

Get Tables in Dataset within Workspace

Returns a list of tables within the specified dataset from the specified workspace.

Get Tiles from My Workspace Dashboard

Returns a list of tiles within the specified dashboard from My workspace.

Get Tiles from Workspace Dashboard

Returns a list of tiles within the specified dashboard from the specified workspace.

Get Workspace

Returns a specified workspace (group).

Trigger Query Scale Out Sync in Workspace

Triggers a query scale-out sync of read-only replicas for the specified dataset from the specified workspace.

Move Power BI Scorecard Goals

Moves goals within the scorecard.

Patch Goal Note

Updates a goal value check-in note by ID.

Patch Goal Value By ID

Updates a goal value check-in by a UTC date timestamp.

Patch Scorecard By ID

Updates a scorecard by its ID.

Create Push Dataset in Workspace

Creates a new push dataset in the specified Power BI workspace.

Grant Dataset User Permissions

Grants the specified user's permissions to the specified dataset.

Grant Dataset User Permissions In Group

Grants the specified user's permissions to the specified dataset in a workspace.

Post Goal

Adds a new goal to a Power BI scorecard.

Post Goal Note

Adds a new note to a goal value check-in for a Power BI scorecard goal.

Add Rows to Dataset Table in Workspace

Adds new data rows to the specified table within the specified dataset from the specified workspace.

Post Goal Status Rules

Creates or updates status rules of a goal in Power BI.

Update Table Schema

Updates the metadata and schema for the specified table within the specified dataset from My workspace.

Update Table Schema in Workspace

Updates the metadata and schema for the specified table within the specified dataset from the specified workspace.

Rebind Report to Dataset

Rebinds the specified report from the specified workspace to the specified dataset.

Trigger Dataset Refresh in Workspace

Triggers a refresh for the specified dataset from the specified workspace.

Generate Report Embed Token for Create in Group

Generates an embed token to allow report creation in the specified workspace based on the specified dataset.

Set Linked Report Cache Options

Replaces the CacheOption's content for a given LinkedReport using the provided definition.

Take Over Dataset

Transfers ownership over the specified dataset to the current authorized user.

Take Over Paginated Report Ownership

Transfers ownership of the data sources for the specified paginated report (RDL) to the current authorized user.

Trigger Query Scale Out Sync

Triggers a query scale-out sync of read-only replicas for the specified dataset from My workspace.

Update Dataset

Updates the properties for the specified dataset from My workspace.

Update Dataset In Workspace

Updates the properties for the specified dataset from the specified workspace.

Update Paginated Report Data Sources

Updates the data sources of the specified paginated report (RDL) from the specified workspace.

Patch Goal By ID

Updates a goal by its ID within a Power BI scorecard.

Update Dataset Parameters in Workspace

Updates the parameters values for the specified dataset from the specified workspace.

Update Refresh Schedule

Updates the refresh schedule for the specified dataset from My workspace.

Update Refresh Schedule In Group

Updates the refresh schedule for the specified dataset from the specified workspace.

Update Report Content

Updates the content of the specified report from **My workspace** with the content of a specified source report.

Update Workspace

Updates the properties for the specified workspace.

FAQ

Frequently asked questions

With a standalone Microsoft Power Bi MCP server, the agents and LLMs can only access a fixed set of Microsoft Power Bi tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Microsoft Power Bi and many other apps based on the task at hand, all through a single MCP endpoint.

Yes, you can. CrewAI fully supports MCP integration. You get structured tool calling, message history handling, and model orchestration while Tool Router takes care of discovering and serving the right Microsoft Power Bi tools.

Yes, absolutely. You can configure which Microsoft Power Bi scopes and actions are allowed when connecting your account to Composio. You can also bring your own OAuth credentials or API configuration so you keep full control over what the agent can do.

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Microsoft Power Bi data and credentials are handled as safely as possible.

Start with Microsoft Power Bi.It takes 30 seconds.

Managed auth, hosted MCP servers, and every Microsoft Power Bi tool your agent needs.Free to start.

Start building