-
Notifications
You must be signed in to change notification settings - Fork 282
Adding MCP capability in DAB #2868
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
Merged
Changes from all commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
2898076
Just before logging
17e9728
Rearrange
6e1abe5
git should be ignored
26b40c1
Testing GQL Schema
a017772
broken but nice
e81dbeb
basic working
a1f3d75
Just before we format the schema
b4a4447
Working with LIST
123f5ca
PRE
ad64ad0
Working again
8d015c0
Updated health
db72d87
JSON based Dynamic tools configuration based
souvikghosh04 3948822
Tweaking tooling adding tests
04b19f9
Updated mege
66bba27
Revert "Updated mege"
souvikghosh04 ba6909f
Revert "Merge branch 'jerry-mcp-core' of https://github.com/Azure/dat…
souvikghosh04 ddca78b
DAB MCP Runtime (#2866)
souvikghosh04 5e06a6e
Delete dab_aci_deploy.ps1
souvikghosh04 6ef8a3a
Delete dab_aca_deploy.ps1
souvikghosh04 55e3e61
Backmerge
souvikghosh04 4cb06b0
Merge branch 'main' into jerry-mcp-core
RubenCerna2079 d63d999
Added mechanism to implement tools and configure them in generic way
souvikghosh04 deac452
Merge branch 'jerry-mcp-core' of https://github.com/Azure/data-api-bu…
souvikghosh04 046d04a
Auto registration of tools and refactoring
souvikghosh04 0796e32
Refactored unwanted files and logic
souvikghosh04 78baf4a
Refactoring and removed gitignore, installcredprovider.ps1
souvikghosh04 2362084
Refactoring file structures
souvikghosh04 c212bdd
Refactoring- files structures, unwanted changes
souvikghosh04 540a025
Fix test formatting errors
RubenCerna2079 07e5945
Fix formatting for tests part 2
RubenCerna2079 00916ed
Fix ConfigValidationUnitTests
RubenCerna2079 ae99b9a
Fix RuntimeConfigValidator tests
RubenCerna2079 78809e4
Backmerge, removed health check and schema logic due to errors
souvikghosh04 f093688
Merge branch 'jerry-mcp-core' of https://github.com/Azure/data-api-bu…
souvikghosh04 be77230
Add MCP Runtime serialization/deserialization and fix tests related t…
RubenCerna2079 9a70ac3
Fix MCP runtime config
souvikghosh04 68a7119
Revert "Add MCP Runtime serialization/deserialization and fix tests r…
souvikghosh04 89777bf
Fixed MCP runtime configs
souvikghosh04 6f3b494
Backmerge and fixes on MCP runtime config
souvikghosh04 590ddd9
Merge branch 'main' into jerry-mcp-core
souvikghosh04 c757d8e
PR reviews and fixes
souvikghosh04 416b5e4
Merge branch 'jerry-mcp-core' of https://github.com/Azure/data-api-bu…
souvikghosh04 9c7c95b
Fix CLI commands
RubenCerna2079 8985d5e
Fix formatting error
RubenCerna2079 395f765
[MCP] Clean up for Cli and Cli.Tests packages (#2879)
anushakolan fd5926f
rename -record to -entity
souvikghosh04 54ef980
Addressed some review comments
souvikghosh04 b139945
Update execute-entity and rest to -record
souvikghosh04 b71c382
set default true for all and write to JSON if user modified
souvikghosh04 2423646
rename execute-record to execute-entity
souvikghosh04 3f0cdd7
review comments- nits, null checks
souvikghosh04 4f18f6e
Update src/Azure.DataApiBuilder.Mcp/Core/McpServerConfiguration.cs
souvikghosh04 f71232a
use DEFAULT_PATH constant for mcp endpoint
souvikghosh04 95ff107
Merge branch 'jerry-mcp-core' of https://github.com/Azure/data-api-bu…
souvikghosh04 629d3fb
Fixed unit tests
souvikghosh04 b3040ad
fix formatting
souvikghosh04 b623589
Fix the incorrectly changed log messages
Aniruddh25 64b1371
Remove nullable Path property
Aniruddh25 f0e6e85
Apply suggestions from code review
Aniruddh25 3b893c8
Keeping the parameters UpperCases to align with other RuntimeOptions …
Aniruddh25 2eacd64
Draft PR: Service Tests Fix (#2884)
RubenCerna2079 a29485c
Fix mssql snapshot
RubenCerna2079 8080c83
Addressed review comments. mostly nits
souvikghosh04 b4d7bd6
Fix failing test by reverting to original version
souvikghosh04 fd9d163
Fix formatting errors
souvikghosh04 44a59f5
fixed the summary
souvikghosh04 96d8f8f
fix formatting
souvikghosh04 7c483c0
Fix comments from copilot
RubenCerna2079 354522f
Address comments
RubenCerna2079 973afab
Delete dead code
RubenCerna2079 e585c0c
Delete more dead code
RubenCerna2079 06201d8
Use IsMcpEnabled to determine whether to add mcp server or not
Aniruddh25 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
22 changes: 22 additions & 0 deletions
22
src/Azure.DataApiBuilder.Mcp/Azure.DataApiBuilder.Mcp.csproj
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,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="ModelContextProtocol" /> | ||
<PackageReference Include="ModelContextProtocol.AspNetCore" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Core\Azure.DataApiBuilder.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="CustomTools\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
87 changes: 87 additions & 0 deletions
87
src/Azure.DataApiBuilder.Mcp/BuiltInTools/CreateRecordTool.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,87 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Text.Json; | ||
using Azure.DataApiBuilder.Mcp.Model; | ||
using ModelContextProtocol.Protocol; | ||
using static Azure.DataApiBuilder.Mcp.Model.McpEnums; | ||
|
||
namespace Azure.DataApiBuilder.Mcp.BuiltInTools | ||
{ | ||
public class CreateRecordTool : IMcpTool | ||
{ | ||
public ToolType ToolType { get; } = ToolType.BuiltIn; | ||
|
||
public Tool GetToolMetadata() | ||
{ | ||
return new Tool | ||
{ | ||
Name = "create-record", | ||
Description = "Creates a new record in the specified entity.", | ||
InputSchema = JsonSerializer.Deserialize<JsonElement>( | ||
@"{ | ||
""type"": ""object"", | ||
""properties"": { | ||
""entity"": { | ||
""type"": ""string"", | ||
""description"": ""The name of the entity"" | ||
}, | ||
""data"": { | ||
""type"": ""object"", | ||
""description"": ""The data for the new record"" | ||
} | ||
}, | ||
""required"": [""entity"", ""data""] | ||
}" | ||
) | ||
}; | ||
} | ||
|
||
public Task<CallToolResult> ExecuteAsync( | ||
JsonDocument? arguments, | ||
IServiceProvider serviceProvider, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
if (arguments == null) | ||
{ | ||
return Task.FromResult(new CallToolResult | ||
{ | ||
Content = [new TextContentBlock { Type = "text", Text = "Error: No arguments provided" }] | ||
}); | ||
} | ||
|
||
try | ||
{ | ||
// Extract arguments | ||
JsonElement root = arguments.RootElement; | ||
|
||
if (!root.TryGetProperty("entity", out JsonElement entityElement) || | ||
!root.TryGetProperty("data", out JsonElement dataElement)) | ||
{ | ||
return Task.FromResult(new CallToolResult | ||
{ | ||
Content = [new TextContentBlock { Type = "text", Text = "Error: Missing required arguments 'entity' or 'data'" }] | ||
}); | ||
} | ||
|
||
string entityName = entityElement.GetString() ?? string.Empty; | ||
|
||
// TODO: Implement actual create logic using DAB's internal services | ||
// For now, return a placeholder response | ||
string result = $"Would create record in entity '{entityName}' with data: {dataElement.GetRawText()}"; | ||
|
||
return Task.FromResult(new CallToolResult | ||
{ | ||
Content = [new TextContentBlock { Type = "text", Text = result }] | ||
}); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return Task.FromResult(new CallToolResult | ||
{ | ||
Content = [new TextContentBlock { Type = "text", Text = $"Error: {ex.Message}" }] | ||
}); | ||
} | ||
} | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
src/Azure.DataApiBuilder.Mcp/BuiltInTools/DescribeEntitiesTool.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,83 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Text.Json; | ||
using Azure.DataApiBuilder.Config.ObjectModel; | ||
using Azure.DataApiBuilder.Core.Configurations; | ||
using Azure.DataApiBuilder.Mcp.Model; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using ModelContextProtocol.Protocol; | ||
using static Azure.DataApiBuilder.Mcp.Model.McpEnums; | ||
|
||
namespace Azure.DataApiBuilder.Mcp.BuiltInTools | ||
{ | ||
public class DescribeEntitiesTool : IMcpTool | ||
{ | ||
public ToolType ToolType { get; } = ToolType.BuiltIn; | ||
|
||
public Tool GetToolMetadata() | ||
{ | ||
return new Tool | ||
{ | ||
Name = "describe-entities", | ||
Description = "Lists and describes all entities in the database." | ||
}; | ||
} | ||
|
||
public Task<CallToolResult> ExecuteAsync( | ||
JsonDocument? arguments, | ||
IServiceProvider serviceProvider, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
try | ||
{ | ||
// Get the runtime config provider | ||
RuntimeConfigProvider? runtimeConfigProvider = serviceProvider.GetService<RuntimeConfigProvider>(); | ||
if (runtimeConfigProvider == null || !runtimeConfigProvider.TryGetConfig(out RuntimeConfig? runtimeConfig)) | ||
{ | ||
return Task.FromResult(new CallToolResult | ||
{ | ||
Content = [new TextContentBlock { Type = "text", Text = "Error: Runtime configuration not available." }] | ||
}); | ||
} | ||
|
||
// Extract entity information from the runtime config | ||
Dictionary<string, object> entities = new(); | ||
|
||
if (runtimeConfig.Entities != null) | ||
{ | ||
foreach (KeyValuePair<string, Entity> entity in runtimeConfig.Entities) | ||
{ | ||
entities[entity.Key] = new | ||
{ | ||
source = entity.Value.Source, | ||
permissions = entity.Value.Permissions?.Select(p => new | ||
{ | ||
role = p.Role, | ||
actions = p.Actions | ||
}) | ||
}; | ||
} | ||
} | ||
|
||
string entitiesJson = JsonSerializer.Serialize(entities, new JsonSerializerOptions | ||
{ | ||
WriteIndented = true, | ||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase | ||
}); | ||
|
||
return Task.FromResult(new CallToolResult | ||
{ | ||
Content = [new TextContentBlock { Type = "application/json", Text = entitiesJson }] | ||
}); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return Task.FromResult(new CallToolResult | ||
{ | ||
Content = [new TextContentBlock { Type = "text", Text = $"Error: {ex.Message}" }] | ||
}); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
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.