diff --git a/McpStudy.McpServerSSE/Index.html b/McpStudy.McpServerSSE/Index.html new file mode 100644 index 0000000..d85c0e9 --- /dev/null +++ b/McpStudy.McpServerSSE/Index.html @@ -0,0 +1,33 @@ + + + + + + McpStudy.McpServerSSE + + +
+

McpStudy.McpServerSSE 启动成功!

+

WebAPI参阅:Swagger 文档

+

MCP服务测试:MCP服务页

+
+ + + \ No newline at end of file diff --git a/McpStudy.McpServerSSE/McpStudy.McpServerSSE.csproj b/McpStudy.McpServerSSE/McpStudy.McpServerSSE.csproj index 3efdcb9..933f213 100644 --- a/McpStudy.McpServerSSE/McpStudy.McpServerSSE.csproj +++ b/McpStudy.McpServerSSE/McpStudy.McpServerSSE.csproj @@ -16,4 +16,10 @@ + + + PreserveNewest + + + diff --git a/McpStudy.McpServerSSE/Program.cs b/McpStudy.McpServerSSE/Program.cs index 26828ff..ebef631 100644 --- a/McpStudy.McpServerSSE/Program.cs +++ b/McpStudy.McpServerSSE/Program.cs @@ -23,21 +23,33 @@ public class Program var app = builder.Build(); // Configure the HTTP request pipeline. - if (app.Environment.IsDevelopment()) - { - app.MapOpenApi(); + app.MapOpenApi(); - app.UseSwaggerUI(options => - { - options.SwaggerEndpoint("/openapi/v1.json", "v1"); - }); - } + app.UseSwaggerUI(options => + { + options.SwaggerEndpoint("/openapi/v1.json", "v1"); + }); app.UseAuthorization(); app.MapControllers(); + //ַ(֧վ):Զм+ض + //ֻм·(app.Map): / "" ȱapp.MapMcp + app.Use(async (context, next) => + { + if (context.Request.Path == "/" || context.Request.Path == "") + { + context.Response.ContentType = "text/html"; + await context.Response.SendFileAsync(Path.Combine(app.Environment.ContentRootPath, "index.html")); + } + else + { + await next(); + } + }); + app.MapMcp(); app.Run();