Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3f97416
Add entity-level MCP configuration support
souvikghosh04 Dec 4, 2025
8bde11e
Address PR review comments
souvikghosh04 Dec 4, 2025
c186dc2
Validate MCP options if provided
souvikghosh04 Dec 5, 2025
aebe80e
Merge branch 'main' into Usr/sogh/entity-level-mcp-config
souvikghosh04 Dec 5, 2025
0514f58
Copilot review fixes
souvikghosh04 Dec 5, 2025
4446274
Merge branch 'Usr/sogh/entity-level-mcp-config' of https://github.com…
souvikghosh04 Dec 5, 2025
ac12ece
Added tests for Entity MCP config
souvikghosh04 Dec 8, 2025
271f896
Merge branch 'main' into Usr/sogh/entity-level-mcp-config
souvikghosh04 Dec 8, 2025
f30ef6f
Added additional tests and fixes
souvikghosh04 Dec 8, 2025
372595b
Merge branch 'Usr/sogh/entity-level-mcp-config' of https://github.com…
souvikghosh04 Dec 8, 2025
f032963
Fix formattings
souvikghosh04 Dec 8, 2025
78d76d6
POC for custom tool
souvikghosh04 Dec 11, 2025
b56e748
Merge latest changes from main branch - MCP dml-tools support and rel…
souvikghosh04 Dec 18, 2025
a3e3dc1
POC tests and artifacts
souvikghosh04 Dec 19, 2025
c78d102
Merge remote-tracking branch 'origin/main' into Usr/sogh/customtoolpo…
souvikghosh04 Jan 7, 2026
7f7b431
Refactorings
souvikghosh04 Jan 12, 2026
c2c90e7
Remove temp test artifacts
souvikghosh04 Jan 12, 2026
7dc5c65
Remove temp/duplicate test snapshot files
souvikghosh04 Jan 12, 2026
b9fb4d0
Revert temp changes from dab config
souvikghosh04 Jan 12, 2026
6304421
Formatting
souvikghosh04 Jan 12, 2026
0b2e517
Added GHCP review changes
souvikghosh04 Jan 13, 2026
d4e6549
Fix formatting
souvikghosh04 Jan 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions src/Azure.DataApiBuilder.Mcp/Core/CustomMcpToolFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Azure.DataApiBuilder.Config.ObjectModel;
using Azure.DataApiBuilder.Mcp.Model;
using Microsoft.Extensions.Logging;

namespace Azure.DataApiBuilder.Mcp.Core
{
/// <summary>
/// Factory for creating custom MCP tools from stored procedure entity configurations.
/// Scans runtime configuration and generates dynamic tools for entities marked with custom-tool enabled.
/// </summary>
public class CustomMcpToolFactory
{
/// <summary>
/// Creates custom MCP tools from entities configured with "mcp": { "custom-tool": true }.
/// </summary>
/// <param name="config">The runtime configuration containing entity definitions.</param>
/// <param name="logger">Optional logger for diagnostic information.</param>
/// <returns>Enumerable of custom tools generated from configuration.</returns>
public static IEnumerable<IMcpTool> CreateCustomTools(RuntimeConfig config, ILogger? logger = null)
{
if (config?.Entities == null)
{
logger?.LogWarning("No entities found in runtime configuration for custom tool generation.");
return Enumerable.Empty<IMcpTool>();
}

List<IMcpTool> customTools = new();

foreach ((string entityName, Entity entity) in config.Entities)
{
// Filter: Only stored procedures with custom-tool enabled
if (entity.Source.Type == EntitySourceType.StoredProcedure &&
entity.Mcp?.CustomToolEnabled == true)
{
try
{
DynamicCustomTool tool = new(entityName, entity);

logger?.LogInformation(
"Created custom MCP tool '{ToolName}' for stored procedure entity '{EntityName}'",
tool.GetToolMetadata().Name,
entityName);

customTools.Add(tool);
}
catch (Exception ex)
{
logger?.LogError(
ex,
"Failed to create custom tool for entity '{EntityName}'. Skipping.",
entityName);
}
}
}

logger?.LogInformation("Custom MCP tool generation complete. Created {Count} custom tools.", customTools.Count);
return customTools;
}
}
}
Loading
Loading