Skip to content

Commit d77e983

Browse files
Working on the stack extension to ensure it has the correct thread
1 parent 8391835 commit d77e983

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

mcp_nexus/Extensions/ExtensionExecutor.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,23 @@ private string BuildPowerShellParameterArguments(object parameters)
385385
if (parameters is JsonElement jsonElement)
386386
{
387387
m_Logger.LogDebug("Parameters is a JsonElement, type: {Type}", jsonElement.ValueKind);
388-
json = jsonElement.GetRawText();
388+
389+
// If JsonElement is a string, it's a JSON string that needs to be unwrapped
390+
if (jsonElement.ValueKind == JsonValueKind.String)
391+
{
392+
json = jsonElement.GetString() ?? "{}";
393+
m_Logger.LogDebug("Unwrapped JSON string from JsonElement: {Json}", json);
394+
}
395+
else if (jsonElement.ValueKind == JsonValueKind.Object)
396+
{
397+
json = jsonElement.GetRawText();
398+
m_Logger.LogDebug("Got JSON object from JsonElement: {Json}", json);
399+
}
400+
else
401+
{
402+
m_Logger.LogWarning("JsonElement is not an object or string, type: {Type}", jsonElement.ValueKind);
403+
return string.Empty;
404+
}
389405
}
390406
else if (parameters is string jsonString)
391407
{

0 commit comments

Comments
 (0)