Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
themeEmacs
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

var builder = Host.CreateApplicationBuilder(args);
builder.Logging.AddConsole(consoleLogOptions =>
{
    // Configure all logs to go to stderr
    consoleLogOptions.LogToStandardErrorThreshold = LogLevel.Trace;
});

builder.Services
    .AddMcpServer()
    .WithStdioServerTransport()
    .WithToolsFromAssembly();

await builder.Build().RunAsync();
  • StdIO모드로 Local LLM Agent툴과 상호작용하는듯
  • 특정 Port가 Listen되어 Remote로 서비스를 제공하는 일반적인 Server 개념과는 다른것으로 보입니다.
    • 처음 MCP Server 구동할때 서버는  Port는 도대체 뭐지? 제공 포트  혼란스러운 부분
  • LLM Agent가 필요하면 필요한 타이밍 툴을 실행하고 종료되는 짧은 사이클을 가진듯
    • 어플리케이션이 툴로서의 기능을 하기때문에 아주 짧은 사이클을 가졌으며~ 한번작동하면 내려갈때까지 사용할수 있는 싱글톤 주입은 의미가 없습니다. 왜 객체가 유지안되지? 두번째 혼란스러울수 있는 부분입니다.
  • 계속 지속 작동하는 Server로 인식하기보다 LLM Agent가 필요하면 잠깐 작동하는 Execute Tool이다라고 생각해야 여러모로 헛갈리지 않을듯

MCP 코드

Code Block
themeEmacs
using System.ComponentModel;
using ModelContextProtocol.Server;

namespace McpServer.Tools;

[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) => new string(message.Reverse().ToArray());
}
  • McpServerToolType을 인식해 MCP코드를 작동시켜주며~ Tools디렉토리하위에 Tool단위로 구성파일을 추가



Description은 이것을 이용하는 LLM에게 툴의 설명을 주며 , LLM과 상호작용해 해당기능을 수행합니다.

...