From c8f39f11fb3aac053deabf15eb9757fde1ca3e96 Mon Sep 17 00:00:00 2001 From: tymmkang Date: Thu, 29 May 2025 23:00:05 +0900 Subject: [PATCH] =?UTF-8?q?ms=EC=97=90=20=EC=98=88=EC=A0=9C=20=EB=94=B0?= =?UTF-8?q?=EB=9D=BC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Program.cs | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/Program.cs b/Program.cs index 615e0e9..f96ea9f 100644 --- a/Program.cs +++ b/Program.cs @@ -1,7 +1,40 @@ -internal class Program -{ - private static void Main(string[] args) - { - Console.WriteLine("Hello, World!"); - } -} +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using ModelContextProtocol.Server; +using System.ComponentModel; + +internal class Program +{ + private static async Task Main(string[] args) + { + var builder = Host.CreateApplicationBuilder(args); + builder.Logging.AddConsole(consoleLoggerOptions => + { + consoleLoggerOptions.LogToStandardErrorThreshold = LogLevel.Trace; + }); + + builder.Services. + AddMcpServer(). + WithStdioServerTransport(). + WithToolsFromAssembly(); + + await builder.Build().RunAsync(); + } +} + +[McpServerToolType] +public static class EchoTool +{ + [McpServerTool, Description("Echoes the message back to the client.")] + public static string Echo(string message) => $"Hello from C#: {message}"; + + [McpServerTool, Description("Echoes in reverse the message sent by the client.")] + public static string ReverseEcho(string message) + { + char[] charArray = message.ToCharArray(); + Array.Reverse(charArray); + var reversed = new string(charArray); + return reversed; + } +}