Add support for stdio-based server mode alongside HTTP service integration
This commit is contained in:
parent
309407133c
commit
85eedab29d
2 changed files with 46 additions and 41 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using cs_mic_mcp.Resources;
|
||||
using cs_mic_mcp.Tools;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
|
||||
namespace cs_mic_mcp;
|
||||
|
||||
|
|
@ -7,11 +8,28 @@ public class Program
|
|||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
if (args.Contains("--stdio", StringComparer.InvariantCultureIgnoreCase))
|
||||
{
|
||||
// stdio pipeline - local only
|
||||
var builder = Host.CreateApplicationBuilder(args);
|
||||
|
||||
builder.Services
|
||||
.AddMcpServer()
|
||||
.WithStdioServerTransport()
|
||||
.WithTools<MathTools>()
|
||||
.WithResources<DocumentationResources>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.Run();
|
||||
}
|
||||
else
|
||||
{
|
||||
// web pipeline - http service
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services
|
||||
.AddMcpServer()
|
||||
//.WithStdioServerTransport()
|
||||
.WithHttpTransport()
|
||||
.WithTools<MathTools>()
|
||||
.WithResources<DocumentationResources>();
|
||||
|
|
@ -28,28 +46,13 @@ public class Program
|
|||
});
|
||||
});
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
//builder.Services.AddControllers();
|
||||
|
||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||||
//builder.Services.AddOpenApi();
|
||||
|
||||
var app = builder.Build();
|
||||
app.UseCors();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
//app.MapOpenApi();
|
||||
}
|
||||
|
||||
//app.UseAuthorization();
|
||||
|
||||
|
||||
//app.MapControllers();
|
||||
app.MapMcp("/mcp");
|
||||
|
||||
app.Run();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -5,10 +5,12 @@
|
|||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "http://localhost:5017",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
"applicationUrl": "http://localhost:5000"
|
||||
},
|
||||
"stdio": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "--stdio",
|
||||
"dotnetRunMessages": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue