Skip to content

Commit 5c5134c

Browse files
committed
Ensure action has a description when being exposed via MCP
1 parent fc8fd79 commit 5c5134c

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/Dibix.Sdk.CodeGeneration/Validation/EndpointModelValidator.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ private bool ValidateAmbiguousActionNames(IEnumerable<ActionRegistration> action
128128

129129
private bool ValidateAction(ActionDefinition action)
130130
{
131-
bool isValid = ValidateReservedPathSegments(action) && ValidateParameters(action) && ValidateBodyAllowedForMethod(action);
131+
bool isValid = ValidateReservedPathSegments(action) && ValidateParameters(action) && ValidateBodyAllowedForMethod(action) && ValidateMcpDescription(action);
132132
return isValid;
133133
}
134134

@@ -194,6 +194,19 @@ private bool ValidateBodyAllowedForMethod(ActionDefinition action)
194194
return isValid;
195195
}
196196

197+
// [warning] Tool GetTemplateDefinition does not have a description. Tools must be accurately described to be called
198+
private bool ValidateMcpDescription(ActionDefinition actionDefinition)
199+
{
200+
if (actionDefinition.ModelContextProtocolType == ModelContextProtocolType.None)
201+
return true;
202+
203+
if (actionDefinition.Description != null)
204+
return true;
205+
206+
_logger.LogError($"A description for action '{actionDefinition.OperationId}' must be provided, when being exposed via MCP", actionDefinition.Location);
207+
return false;
208+
}
209+
197210
// When using the BODY.$RAW property source, the raw body will be passed to as a stream to an SqlParameter.
198211
// The stream will be only accessed asynchronously if one of the async ADO.NET methods is used.
199212
// Otherwise, it will cause this exception in the ASP.NET core host:

0 commit comments

Comments
 (0)