Mark samples as AOT compatible (#184)
* Revert changes to remove APIs * Apply suggestions from code review Co-authored-by: Stephen Toub <stoub@microsoft.com> --------- Co-authored-by: Stephen Toub <stoub@microsoft.com>
This commit is contained in:
parent
c452dc8e26
commit
f652b1a03d
4 changed files with 51 additions and 10 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Serilog;
|
||||
using TestServerWithHosting.Tools;
|
||||
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.MinimumLevel.Verbose() // Capture all log levels
|
||||
|
|
@ -19,7 +20,8 @@ try
|
|||
builder.Services.AddSerilog();
|
||||
builder.Services.AddMcpServer()
|
||||
.WithStdioServerTransport()
|
||||
.WithToolsFromAssembly();
|
||||
.WithTools<EchoTool>()
|
||||
.WithTools<SampleLlmTool>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@
|
|||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<!--
|
||||
Serilog AOT support regressed
|
||||
<PublishAot>true</PublishAot>
|
||||
-->
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
@ -13,6 +17,9 @@
|
|||
<PackageReference Include="Serilog.Sinks.Console" />
|
||||
<PackageReference Include="Serilog.Sinks.Debug" />
|
||||
<PackageReference Include="Serilog.Sinks.File" />
|
||||
<RuntimeHostConfigurationOption
|
||||
Include="Serilog.IsCompilerGeneratedCodeSupported"
|
||||
Value="false" Trim="true" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using System.ComponentModel;
|
|||
namespace TestServerWithHosting.Tools;
|
||||
|
||||
[McpServerToolType]
|
||||
public static class EchoTool
|
||||
public sealed class EchoTool
|
||||
{
|
||||
[McpServerTool, Description("Echoes the input back to the client.")]
|
||||
public static string Echo(string message)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace TestServerWithHosting.Tools;
|
|||
/// This tool uses depenency injection and async method
|
||||
/// </summary>
|
||||
[McpServerToolType]
|
||||
public static class SampleLlmTool
|
||||
public sealed class SampleLlmTool
|
||||
{
|
||||
[McpServerTool(Name = "sampleLLM"), Description("Samples from an LLM using MCP's sampling feature")]
|
||||
public static async Task<string> SampleLLM(
|
||||
|
|
|
|||
Loading…
Reference in a new issue