Fix the docs and make the more readable (#281)

This commit is contained in:
Mike Alhayek 2025-04-12 05:41:41 -07:00 • committed by GitHub
commit f2fd2046f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -31,7 +31,7 @@ To get started writing a client, the `McpClientFactory.CreateAsync` method is us
to a server. Once you have an `IMcpClient`, you can interact with it, such as to enumerate all available tools and invoke tools. to a server. Once you have an `IMcpClient`, you can interact with it, such as to enumerate all available tools and invoke tools.
```csharp ```csharp
var clientTransport = new StdioClientTransport(new() var clientTransport = new StdioClientTransport(new StdioClientTransportOptions
{ {
Name = "Everything", Name = "Everything",
Command = "npx", Command = "npx",
@ -163,10 +163,10 @@ using System.Text.Json;
McpServerOptions options = new() McpServerOptions options = new()
{ {
ServerInfo = new() { Name = "MyServer", Version = "1.0.0" }, ServerInfo = new Implementation() { Name = "MyServer", Version = "1.0.0" },
Capabilities = new() Capabilities = new ServerCapabilities()
{ {
Tools = new() Tools = new ToolsCapability()
{ {
ListToolsHandler = (request, cancellationToken) => ListToolsHandler = (request, cancellationToken) =>
Task.FromResult(new ListToolsResult() Task.FromResult(new ListToolsResult()
@ -199,7 +199,7 @@ McpServerOptions options = new()
{ {
if (request.Params.Arguments?.TryGetValue("message", out var message) is not true) if (request.Params.Arguments?.TryGetValue("message", out var message) is not true)
{ {
throw new McpServerException("Missing required argument 'message'"); throw new McpException("Missing required argument 'message'");
} }
return Task.FromResult(new CallToolResponse() return Task.FromResult(new CallToolResponse()
@ -208,7 +208,7 @@ McpServerOptions options = new()
}); });
} }
throw new McpServerException($"Unknown tool: '{request.Params?.Name}'"); throw new McpException($"Unknown tool: '{request.Params?.Name}'");
}, },
} }
}, },