Summary
Toolset/MCP JSON schema marks FString/FName/FText parameters with an empty default (= TEXT(“”)) as required
Area: Editor → JsonUtilitiesEditor / ToolsetRegistry (MCP)
Engine version: 5.8.4 (source build; found via the UnrealEngine-Angelscript fork at 5.8.4, the affected file is unchanged Epic code)
What Type of Bug are you experiencing?
AI
Steps to Reproduce
1 Add an AICallable function to any toolset class, for example:
UFUNCTION(meta = (AICallable))
static FString Echo(int32 Count = 1, const FString& Text = TEXT(“”));
2 Build, start the editor with the ModelContextProtocol plugin, and call describe_toolset for that toolset.
3 Call the tool with only {“count”: 2}.
Expected Result
text is optional in the input schema (“default”: “”), like count (“default”: 1); the call succeeds with Text == “”.
Observed Result
“text” is listed in “required” and has no “default” in the input schema. Calling the tool with only {“count”: 2} fails with:
Function “Echo”, input param “text” is required by the function input schema Json, but is missing from the incoming function input params Json.
“count” (default 1) works as expected; only empty-string defaults of FString/FName/FText are affected.
Affects Versions
5.8
Platform(s)
Windows
Additional Notes
Cause: UHT writes CPP_Default_Text=“” for an empty-string default. UEdGraphSchema_K2::FindFunctionParameterDefaultValue returns false for an empty metadata value, and SetFunctionPropertyDefaultInPropertyMetadata (Engine/Source/Editor/JsonUtilitiesEditor/Private/JsonSchema/JsonSchemaGeneratorEditor.cpp) only writes “default” when the default string is not empty, so FJsonSchemaGenerator adds the parameter to “required”.
Suggested fix (right after FindFunctionParameterDefaultValue in SetFunctionPropertyDefaultInPropertyMetadata):
if (ParameterDefaultString.IsEmpty()
&& (Property->IsA() || Property->IsA() || Property->IsA())
&& PropertyOwnerFunction->HasMetaData(*(FString(TEXT(“CPP_Default_”)) + Property->GetName())))
{
OutPropertyMetadata->SetStringField(TEXT(“default”), FString());
return;
}
FObjectFunctionToolCall already fills missing parameters from the schema “default”, so nothing else is needed. Found on 5.8.4 (source build, UnrealEngine-Angelscript fork; the file is unchanged Epic code).
Impact: any toolset with optional string parameters forces MCP clients to pass empty strings, and adding such a parameter to an existing tool breaks existing clients.