new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

MCP · Building servers and clients · all subjects

client: c#

2 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

C# MCP client: McpClient.CreateAsync with StdioClientTransport

In C#, add packages `ModelContextProtocol --prerelease`, `Anthropic.SDK`, `Microsoft.Extensions.Hosting`, `Microsoft.Extensions.AI`. Create `new StdioClientTransport(new(){ Name = "Demo Server", Command = command, Arguments = arguments })` and then `await using var mcpClient = await McpClient.CreateAsync(clientTransport);`. Tools come from `await mcpClient.ListToolsAsync()` and can be passed straight into `ChatOptions.Tools`; `.UseFunctionInvocation()` on the IChatClient enables automatic tool invocation. Requires .NET 8.0 or higher.

C# MCP server: AddMcpServer().WithStdioServerTransport().WithToolsFromAssembly()

In C# (.NET 8+, NuGet packages `ModelContextProtocol --prerelease` and `Microsoft.Extensions.Hosting`), configure the host with `builder.Services.AddMcpServer().WithStdioServerTransport().WithToolsFromAssembly();` and run with `await app.RunAsync();`. Tools live in a static class marked `[McpServerToolType]` with methods marked `[McpServerTool, Description("...")]`, and parameters annotated with `[Description("...")]`; injected services such as HttpClient can be taken as method parameters.

Give your agent this brain