data-api-builder
data-api-builder copied to clipboard
Align successful response for built-in mcp tools to all use the mcp utility function
in read we are calling a private BuildSuccessfulResult which is hard coding the response dictionary to use "status", and "result" as keys.
private static CallToolResult BuildSuccessResult(
string entityName,
JsonElement engineRootElement,
ILogger? logger)
{
// Build normalized response
Dictionary<string, object?> normalized = new()
{
["status"] = "success",
["result"] = engineRootElement // only requested values
};
Then in delete we are using the built in helper from the mcp response builder and using "entity", "keyDetails", and "message"
Dictionary<string, object?> responseData = new()
{
["entity"] = entityName,
["keyDetails"] = McpJsonHelper.FormatKeyDetails(keys),
["message"] = "Record deleted successfully"
};
Update is using a private function like read is, create is aligned with delete, using the utility with "entity", and "message".
we should have all these use the mcp response helper and try to use the same keys in the response data.
Logs, error messages should also be standardized and refactored.