-
Notifications
You must be signed in to change notification settings - Fork 515
Add Data Factory tools to Fabric MCP Server #2584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AmosHersch
merged 21 commits into
microsoft:main
from
Ebram-Tawfik:integrate-datafactory-mcp
May 11, 2026
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
20655d2
Add DataFactory.MCP.Core as submodule reference in Fabric.Mcp.Server
64ed49e
Update DataFactory submodule ref after Core→Fabric.Mcp.Tools.DataFact…
d84da2c
Rename submodule folder from DataFactory.MCP to Fabric.Mcp.Tools.Data…
c3e349f
Update DataFactory submodule to include Fabric adapter project
a9cc7e0
Remove redundant wrapper; use DataFactory.MCP.Fabric adapter from sub…
53b45a3
Move DataFactory.MCP.Fabric to tools/Fabric.Mcp.Tools.DataFactory
36b2455
Update DataFactory commands to use domain handlers
7dd454a
Switch DataFactory.MCP.Core from project reference to NuGet package
2f56ce8
Remove DataFactory.MCP submodule
2373c1a
Remove .gitmodules and CONTRIBUTING.md
77fdd40
Restore CONTRIBUTING.md from main
a534e07
Replace placeholder command IDs with proper GUIDs
4267ed2
Add execute-query command and update NuGet to 0.19.1-beta
6b79eb0
chore: bump Microsoft.DataFactory.MCP.Core to 0.20.0-beta
d2c5e42
Use DataFactory.MCP.Core 0.19.1-beta (available on DevOps feed)
7ad4416
Bump DataFactory.MCP.Core to 0.20.0-beta
fd459b9
Fix smoke test: redirect console logs to stderr
216f729
Fix analyze: update solution files and import ordering
d721b92
Add unit tests for DataFactory tools
cf30cfa
docs: add DataFactory README, update CHANGELOG and server README
0737bd5
docs: fix broken relative link, remove PR refs from CHANGELOG
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| # Fabric.Mcp.Tools.DataFactory | ||
|
|
||
| Microsoft Fabric Data Factory MCP (Model Context Protocol) Tools — Manage pipelines and dataflows through AI agents and MCP clients. | ||
|
|
||
| ## Overview | ||
|
|
||
| Data Factory is Microsoft Fabric's cloud-scale data integration service for creating, scheduling, and orchestrating ETL/ELT workflows. This MCP tool provides operations for working with Data Factory resources, enabling AI agents to: | ||
|
|
||
| - List, create, and get pipeline details | ||
| - Run pipelines on demand | ||
| - List and create Dataflow Gen2 items | ||
| - Execute M (Power Query) queries against dataflows | ||
|
|
||
| **Features:** | ||
| - 7 Data Factory commands with full MCP integration | ||
| - Pipeline management: list, create, get, run | ||
| - Dataflow Gen2 management: list, create | ||
| - Dataflow query execution with M/Power Query support | ||
| - Robust error handling via `ToolResult<T>` pattern | ||
| - Unit tested with 45 tests covering metadata, constructors, and options | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Microsoft Fabric workspace with Data Factory capabilities | ||
| - Azure authentication (Azure CLI or managed identity) | ||
| - Access to the target Fabric workspace | ||
|
|
||
| ## Authentication | ||
|
|
||
| The tool uses Azure authentication via the Fabric MCP Server's authentication infrastructure. Ensure you're logged in: | ||
|
|
||
| ```bash | ||
| az login | ||
| ``` | ||
|
|
||
| ## Available Commands | ||
|
|
||
| ### Pipeline Commands | ||
|
|
||
| | Command | Description | Read Only | | ||
| |---------|-------------|-----------| | ||
| | `datafactory_list-pipelines` | Lists all pipelines in a workspace | ✓ | | ||
| | `datafactory_create-pipeline` | Creates a new pipeline | ✗ | | ||
| | `datafactory_get-pipeline` | Gets details of a specific pipeline | ✓ | | ||
| | `datafactory_run-pipeline` | Runs a pipeline on demand | ✗ | | ||
|
|
||
| ### Dataflow Commands | ||
|
|
||
| | Command | Description | Read Only | | ||
| |---------|-------------|-----------| | ||
| | `datafactory_list-dataflows` | Lists all Dataflow Gen2 items in a workspace | ✓ | | ||
| | `datafactory_create-dataflow` | Creates a new Dataflow Gen2 item | ✗ | | ||
| | `datafactory_execute-query` | Executes an M query against a dataflow | ✓ | | ||
|
|
||
| ## Example Prompts | ||
|
|
||
| - "List all pipelines in my workspace" | ||
| - "Create a new pipeline called 'Daily ETL'" | ||
| - "Run the pipeline with ID abc-123 in workspace xyz" | ||
| - "List all dataflows in my workspace" | ||
| - "Execute this M query against my dataflow: `let Source = Sql.Database(\"server\", \"db\") in Source`" | ||
|
|
||
| ## Architecture | ||
|
|
||
| The DataFactory tools are built on the [Microsoft.DataFactory.MCP.Core](https://www.nuget.org/packages/Microsoft.DataFactory.MCP.Core) NuGet package, which provides: | ||
|
|
||
| - **Handlers**: `PipelineHandler`, `DataflowHandler`, `DataflowQueryHandler` — business logic with comprehensive error handling | ||
| - **Services**: HTTP clients for Fabric REST API communication | ||
| - **Models**: Strongly-typed DTOs for API request/response | ||
|
|
||
| Commands follow the MCP framework pattern: | ||
| ``` | ||
| Command (MCP schema + validation) → Handler (business logic + error handling) → Service (HTTP API call) | ||
| ``` | ||
|
|
||
| ## Development | ||
|
|
||
| ### Building | ||
|
|
||
| ```bash | ||
| cd tools/Fabric.Mcp.Tools.DataFactory | ||
| dotnet build src/Fabric.Mcp.Tools.DataFactory.csproj | ||
| ``` | ||
|
|
||
| ### Testing | ||
|
|
||
| ```bash | ||
| dotnet test tests/Fabric.Mcp.Tools.DataFactory.UnitTests/Fabric.Mcp.Tools.DataFactory.UnitTests.csproj | ||
| ``` | ||
|
|
||
| ### Project Structure | ||
|
|
||
| ``` | ||
| tools/Fabric.Mcp.Tools.DataFactory/ | ||
| ├── src/ | ||
| │ ├── Commands/ | ||
| │ │ ├── Pipeline/ # Pipeline CRUD + run commands | ||
| │ │ └── Dataflow/ # Dataflow CRUD + query commands | ||
| │ ├── Models/ # Result DTOs and JSON context | ||
| │ ├── Options/ # Command option definitions | ||
| │ └── DataFactoryAreaSetup.cs # DI registration | ||
| └── tests/ | ||
| └── Fabric.Mcp.Tools.DataFactory.UnitTests/ | ||
| ├── DataFactoryAreaSetupTests.cs | ||
| └── Commands/ # Per-command unit tests | ||
| ``` | ||
|
|
||
| ## Related | ||
|
|
||
| - [Microsoft Fabric Data Factory documentation](https://learn.microsoft.com/fabric/data-factory/) | ||
| - [DataFactory.MCP.Core NuGet package](https://www.nuget.org/packages/Microsoft.DataFactory.MCP.Core) | ||
| - [Fabric MCP Server](https://github.com/microsoft/mcp/tree/main/servers/Fabric.Mcp.Server) |
88 changes: 88 additions & 0 deletions
88
tools/Fabric.Mcp.Tools.DataFactory/src/Commands/Dataflow/CreateDataflowCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using Fabric.Mcp.Tools.DataFactory.Models; | ||
| using Fabric.Mcp.Tools.DataFactory.Options; | ||
| using Fabric.Mcp.Tools.DataFactory.Options.Dataflow; | ||
| using global::DataFactory.MCP.Handlers.Dataflow; | ||
| using Microsoft.Extensions.Logging; | ||
| using Microsoft.Mcp.Core.Commands; | ||
| using Microsoft.Mcp.Core.Extensions; | ||
| using Microsoft.Mcp.Core.Models.Command; | ||
| using Microsoft.Mcp.Core.Models.Option; | ||
| using Microsoft.Mcp.Core.Options; | ||
|
|
||
| namespace Fabric.Mcp.Tools.DataFactory.Commands.Dataflow; | ||
|
|
||
| [CommandMetadata( | ||
| Id = "98c74b3b-1813-40db-9abe-30ad90beb236", | ||
| Name = "create-dataflow", | ||
| Title = "Create Dataflow", | ||
| Description = "Creates a new dataflow in a specified Microsoft Fabric workspace.", | ||
| Destructive = false, | ||
| Idempotent = false, | ||
| ReadOnly = false, | ||
| OpenWorld = false)] | ||
| public sealed class CreateDataflowCommand( | ||
| ILogger<CreateDataflowCommand> logger, | ||
| DataflowHandler handler) : GlobalCommand<CreateDataflowOptions>() | ||
| { | ||
| private readonly ILogger<CreateDataflowCommand> _logger = logger ?? throw new ArgumentNullException(nameof(logger)); | ||
| private readonly DataflowHandler _handler = handler ?? throw new ArgumentNullException(nameof(handler)); | ||
|
|
||
| protected override void RegisterOptions(Command command) | ||
| { | ||
| base.RegisterOptions(command); | ||
| command.Options.Add(DataFactoryOptionDefinitions.WorkspaceId.AsRequired()); | ||
| command.Options.Add(DataFactoryOptionDefinitions.DisplayName.AsRequired()); | ||
| command.Options.Add(DataFactoryOptionDefinitions.Description.AsOptional()); | ||
| } | ||
|
|
||
| protected override CreateDataflowOptions BindOptions(ParseResult parseResult) | ||
| { | ||
| var options = base.BindOptions(parseResult); | ||
| options.WorkspaceId = parseResult.GetValueOrDefault<string>(DataFactoryOptionDefinitions.WorkspaceIdName) ?? string.Empty; | ||
| options.DisplayName = parseResult.GetValueOrDefault<string>(DataFactoryOptionDefinitions.DisplayNameName) ?? string.Empty; | ||
| options.Description = parseResult.GetValueOrDefault<string>(DataFactoryOptionDefinitions.DescriptionName); | ||
| return options; | ||
| } | ||
|
|
||
| public override async Task<CommandResponse> ExecuteAsync(CommandContext context, ParseResult parseResult, CancellationToken cancellationToken) | ||
| { | ||
| if (!Validate(parseResult.CommandResult, context.Response).IsValid) | ||
| { | ||
| return context.Response; | ||
| } | ||
|
|
||
| var options = BindOptions(parseResult); | ||
| var result = await _handler.CreateAsync(options.WorkspaceId, options.DisplayName, options.Description); | ||
| if (result.IsSuccess) | ||
| { | ||
| _logger.LogInformation("Successfully created dataflow '{DisplayName}' in workspace {WorkspaceId}", | ||
| options.DisplayName, options.WorkspaceId); | ||
|
|
||
| // Map CreateDataflowResponse to Dataflow for the result | ||
| var response = result.Value!.Dataflow; | ||
| var dataflow = new global::DataFactory.MCP.Models.Dataflow.Dataflow | ||
| { | ||
| Id = response.Id, | ||
| DisplayName = response.DisplayName, | ||
| Description = response.Description, | ||
| Type = response.Type, | ||
| WorkspaceId = response.WorkspaceId, | ||
| FolderId = response.FolderId | ||
| }; | ||
|
|
||
| var commandResult = new CreateDataflowCommandResult(dataflow); | ||
| context.Response.Results = ResponseResult.Create(commandResult, DataFactoryJsonContext.Default.CreateDataflowCommandResult); | ||
| } | ||
| else | ||
| { | ||
| _logger.LogError("Error creating dataflow '{DisplayName}' in workspace {WorkspaceId}: {Error}", | ||
| options.DisplayName, options.WorkspaceId, result.Error); | ||
| HandleException(context, new Exception(result.Error)); | ||
|
Ebram-Tawfik marked this conversation as resolved.
|
||
| } | ||
|
|
||
| return context.Response; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.