-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
33 lines (26 loc) · 1.05 KB
/
Copy pathProgram.cs
File metadata and controls
33 lines (26 loc) · 1.05 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
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using ModelContextProtocol.Server;
using NOC.McpServer.Auth;
var builder = Host.CreateApplicationBuilder(args);
// Route all logs to stderr — stdout is reserved for the MCP protocol stream
builder.Logging.AddConsole(o => o.LogToStandardErrorThreshold = LogLevel.Trace);
builder.Services.AddTransient<NOCAuthHandler>();
// Plain client — used ONLY for the login call itself, no auth handler attached
builder.Services.AddHttpClient("NOCLoginClient", client =>
{
client.BaseAddress = new Uri("https://www.niceonecode.com/");
client.Timeout = TimeSpan.FromSeconds(30);
});
builder.Services.AddHttpClient("NOCHttpClient", client =>
{
client.BaseAddress = new Uri("https://www.niceonecode.com/");
client.Timeout = TimeSpan.FromSeconds(30);
}).AddHttpMessageHandler<NOCAuthHandler>();
builder.Services
.AddMcpServer()
.WithStdioServerTransport()
.WithToolsFromAssembly();
var app = builder.Build();
await app.RunAsync();