Configure hosted stdio servers to log to stderr (#173)
* Configure hosted stdio servers to log to stderr * Fix newline * Use CreateApplicationBuilder where possible * Address PR feedback
This commit is contained in:
parent
19eed91c53
commit
8dc1f5d096
1 changed files with 27 additions and 6 deletions
13
README.md
13
README.md
|
|
@ -83,13 +83,24 @@ It includes a simple echo tool as an example (this is included in the same file
|
|||
the employed overload of `WithTools` examines the current assembly for classes with the `McpServerToolType` attribute, and registers all methods with the
|
||||
`McpTool` attribute as tools.)
|
||||
|
||||
```
|
||||
dotnet add package ModelContextProtocol --prerelease
|
||||
dotnet add package Microsoft.Extensions.Hosting
|
||||
```
|
||||
|
||||
```csharp
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ModelContextProtocol.Server;
|
||||
using System.ComponentModel;
|
||||
|
||||
var builder = Host.CreateEmptyApplicationBuilder(settings: null);
|
||||
var builder = Host.CreateApplicationBuilder(args);
|
||||
builder.Logging.AddConsole(consoleLogOptions =>
|
||||
{
|
||||
// Configure all logs to go to stderr
|
||||
consoleLogOptions.LogToStandardErrorThreshold = LogLevel.Trace;
|
||||
});
|
||||
builder.Services
|
||||
.AddMcpServer()
|
||||
.WithStdioServerTransport()
|
||||
|
|
|
|||
Loading…
Reference in a new issue