30 lines
709 B
C#
30 lines
709 B
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using ModelContextProtocol.Server;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using Alchegos.MCP.Tools;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services
|
|
.AddMcpServer()
|
|
.WithHttpTransport()
|
|
.WithToolsFromAssembly();
|
|
builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(5050));
|
|
var app = builder.Build();
|
|
|
|
|
|
app.MapMcp();
|
|
|
|
app.Run();
|
|
|
|
[McpServerToolType]
|
|
public static class EchoTool
|
|
{
|
|
[McpServerTool, Description("Echoes the message back to the client.")]
|
|
public static string Echo(string message) => $"hello {message}";
|
|
}
|
|
|