Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/ModelContextProtocol.Core/McpJsonUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ internal static bool IsValidToolOutputSchema(JsonElement element) =>
// Other MCP Types
[JsonSerializable(typeof(IDictionary<string, object>))]
[JsonSerializable(typeof(IReadOnlyDictionary<string, object>))]
[JsonSerializable(typeof(List<object>))]
[JsonSerializable(typeof(ProgressToken))]
[JsonSerializable(typeof(JsonElement))]
[JsonSerializable(typeof(Implementation))]
Expand Down
21 changes: 21 additions & 0 deletions tests/ModelContextProtocol.AotCompatibility.TestApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@
throw new Exception($"Unexpected result: {result}");
}

var join = tools.FirstOrDefault(t => t.Name == "Join");
if (join is null)
{
throw new Exception("Expected the Join tool.");
}

result = await join.InvokeAsync(new() { ["items"] = new List<object> { "one", "two" } });
if (result is null || !result.ToString()!.Contains("Joined: one,two"))
{
throw new Exception($"Unexpected populated array result: {result}");
}

result = await join.InvokeAsync(new() { ["items"] = new List<object>() });
if (result is null || !result.ToString()!.Contains("Joined: "))
{
throw new Exception($"Unexpected empty array result: {result}");
}

Console.WriteLine("Success!");

[McpServerToolType]
Expand All @@ -49,4 +67,7 @@ internal sealed class AotTools
[McpServerTool(Name = "Echo")]
[McpAppUi(ResourceUri = "ui://aot/echo")]
public static string Echo(string arg) => $"Echo: {arg}";

[McpServerTool(Name = "Join")]
public static string Join(string[] items) => $"Joined: {string.Join(',', items)}";
}