-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
37 lines (26 loc) · 903 Bytes
/
Program.cs
File metadata and controls
37 lines (26 loc) · 903 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
31
32
33
34
35
36
37
using DotNetEnv;
using ModelContextProtocol.AspNetCore;
using ModelContextProtocol.Server;
using System.ComponentModel;
var builder = WebApplication.CreateBuilder(args);
Env.Load();
builder.Services
.AddMcpServer()
.WithHttpTransport() // HTTP / SSE transport
// .WithTools<GreetingTools>();
.WithToolsFromAssembly(); // explicitly scan Tools assembly
// Add SignalR services
builder.Services.AddSignalR();
// Add HttpClient support
builder.Services.AddHttpClient();
var app = builder.Build();
// optional: health check or other endpoints
app.MapGet("/health", () => "Hello MCP Server"); // use /health instead of /
// map the MCP endpoints
app.MapMcp(); // this hooks up the /sse and /messages paths
// Map the SignalR hub
app.MapHub<SampleRemoteMcpServer.Hubs.ChatHub>("/chatHub");
// Serve static files
app.UseDefaultFiles();
app.UseStaticFiles();
app.Run();