Compare commits
6 Commits
3afa62b42c
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| c8f39f11fb | |||
| b90820172a | |||
| 31691113b5 | |||
| 53a671a845 | |||
| dcc3b72bee | |||
| 967aa128a1 |
5
.editorconfig
Normal file
5
.editorconfig
Normal file
@@ -0,0 +1,5 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
charset = utf-8-bom
|
||||
47
Program.cs
47
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user