This commit is contained in:
h z
2025-05-04 19:11:12 +01:00
parent fc4ef3b0f8
commit 58d9c333e0
10 changed files with 332 additions and 178 deletions

View File

@@ -1,29 +1,19 @@
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);
const int BIND_PORT = 5050;
builder.Services
.AddMcpServer()
.WithHttpTransport()
.WithToolsFromAssembly();
builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(5050));
builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(BIND_PORT));
//builder.Services.AddHttpLogging(o => { });
var app = builder.Build();
// var logger = app.Logger;
//app.UseHttpLogging();
app.UseRequestBodyLogging();
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}";
}