Compare commits
4 Commits
main
...
3afa62b42c
| Author | SHA1 | Date | |
|---|---|---|---|
| 3afa62b42c | |||
| 49c5266424 | |||
| e290e7e500 | |||
| fbe46072b2 |
@@ -1,5 +0,0 @@
|
|||||||
root = true
|
|
||||||
|
|
||||||
[*]
|
|
||||||
end_of_line = lf
|
|
||||||
charset = utf-8-bom
|
|
||||||
47
Program.cs
47
Program.cs
@@ -1,40 +1,7 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
internal class Program
|
||||||
using Microsoft.Extensions.Hosting;
|
{
|
||||||
using Microsoft.Extensions.Logging;
|
private static void Main(string[] args)
|
||||||
using ModelContextProtocol.Server;
|
{
|
||||||
using System.ComponentModel;
|
Console.WriteLine("Hello, World!");
|
||||||
|
}
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user