-
Notifications
You must be signed in to change notification settings - Fork 682
Expand file tree
/
Copy pathProgram.cs
More file actions
executable file
·30 lines (24 loc) · 881 Bytes
/
Program.cs
File metadata and controls
executable file
·30 lines (24 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env -S dotnet run --
#:package Microsoft.Extensions.Hosting
#:project ../../src/ModelContextProtocol/ModelContextProtocol.csproj
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using ModelContextProtocol.Server;
using System.ComponentModel;
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddMcpServer()
.WithStdioServerTransport()
.WithTools<EchoTool>();
builder.Logging.AddConsole(options =>
{
options.LogToStandardErrorThreshold = LogLevel.Trace;
});
await builder.Build().RunAsync();
// File-scoped tool class
[McpServerToolType]
file class EchoTool
{
[McpServerTool(Name = "echo"), Description("Echoes the message back to the client.")]
public static string Echo([Description("The message to echo back.")] string message) => $"Echo: {message}";
}