Allow JsonSerializerOptions parameters for user-defined and inputs and hardcode everything else to the source generator. (#182)
* Allow user-defined JsonSerializerOptions for user-defined and inputs and hardcode everything else to the source generator. * Add validation for user-defined JsonSerializerOptions. * Remove out of date comment. * Address feedback and add tests
This commit is contained in:
parent
4b38d3e71b
commit
f1af251c32
1 changed files with 632 additions and 372 deletions
|
|
@ -79,11 +79,11 @@ internal static class Program
|
|||
await server.SendMessageAsync(new JsonRpcNotification()
|
||||
{
|
||||
Method = NotificationMethods.LoggingMessageNotification,
|
||||
Params = new LoggingMessageNotificationParams
|
||||
Params = JsonSerializer.SerializeToNode(new LoggingMessageNotificationParams
|
||||
{
|
||||
Level = logLevel,
|
||||
Data = JsonSerializer.Deserialize<JsonElement>("\"Random log message\"")
|
||||
}
|
||||
})
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
|
|
@ -91,10 +91,10 @@ internal static class Program
|
|||
foreach (var resource in _subscribedResources)
|
||||
{
|
||||
ResourceUpdatedNotificationParams notificationParams = new() { Uri = resource.Key };
|
||||
await server.SendMessageAsync(new JsonRpcNotification()
|
||||
await server.SendMessageAsync(new JsonRpcNotification
|
||||
{
|
||||
Method = NotificationMethods.ResourceUpdatedNotification,
|
||||
Params = notificationParams
|
||||
Params = JsonSerializer.SerializeToNode(notificationParams),
|
||||
}, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
|
@ -168,7 +168,7 @@ internal static class Program
|
|||
}
|
||||
return new CallToolResponse()
|
||||
{
|
||||
Content = [new Content() { Text = "Echo: " + message?.ToString(), Type = "text" }]
|
||||
Content = [new Content() { Text = "Echo: " + message.ToString(), Type = "text" }]
|
||||
};
|
||||
}
|
||||
else if (request.Params?.Name == "sampleLLM")
|
||||
|
|
@ -179,7 +179,7 @@ internal static class Program
|
|||
{
|
||||
throw new McpServerException("Missing required arguments 'prompt' and 'maxTokens'");
|
||||
}
|
||||
var sampleResult = await request.Server.RequestSamplingAsync(CreateRequestSamplingParams(prompt?.ToString() ?? "", "sampleLLM", Convert.ToInt32(maxTokens?.ToString())),
|
||||
var sampleResult = await request.Server.RequestSamplingAsync(CreateRequestSamplingParams(prompt.ToString(), "sampleLLM", Convert.ToInt32(maxTokens.GetRawText())),
|
||||
cancellationToken);
|
||||
|
||||
return new CallToolResponse()
|
||||
|
|
|
|||
Loading…
Reference in a new issue