-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
39 lines (38 loc) · 1.13 KB
/
Program.cs
File metadata and controls
39 lines (38 loc) · 1.13 KB
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
31
32
33
34
35
36
37
38
39
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Serilog;
namespace RR.MCP
{
public class Program
{
public static async Task Main(string[] args)
{
var baseDir = AppContext.BaseDirectory;
var logFilePath = Path.Combine(baseDir, "mcp_errors.log");
Log.Logger = new LoggerConfiguration()
.WriteTo.File(logFilePath, rollingInterval: RollingInterval.Day)
.CreateLogger();
try
{
var builder = Host.CreateEmptyApplicationBuilder(settings: null);
builder.Services
.AddMcpServer()
.WithStdioServerTransport()
.WithToolsFromAssembly();
await builder.Build().RunAsync();
}
catch (Exception ex)
{
Log.Fatal(ex, "Fatal error in MCP server");
throw;
}
finally
{
await Log.CloseAndFlushAsync();
}
}
}
}