Improve tool handling (#28)
* Improve tool handling * Rework stuff with new hosting options * Update readme * Fix build * Try run client tests * Fix build * Fix issues on linux * Try to run testserver on linux * Fix test issue * Fix code smells
This commit is contained in:
parent
7d69499ad5
commit
ec9bdfcf5d
1 changed files with 1036 additions and 235 deletions
29
README.MD
29
README.MD
|
|
@ -106,7 +106,33 @@ Remember you can connect to any MCP server, not just ones created using mcpdotne
|
|||
|
||||
## Getting Started (Server)
|
||||
|
||||
Here is an example of how to create an MCP server with a single tool. You can also refer to the TestServer in the tests folder, which implements a wider range of capabilities.
|
||||
Here is an example of how to create an MCP server and register all tools from the current application.
|
||||
|
||||
```csharp
|
||||
var builder = Host.CreateApplicationBuilder(args);
|
||||
builder.Services.AddMcpServer()
|
||||
.WithStdioServerTransport()
|
||||
.WithTools()
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
await app.RunAsync();
|
||||
```
|
||||
|
||||
The `EchoTool` class is a simple example of a tool implementation:
|
||||
```csharp
|
||||
[McpToolType]
|
||||
public static class EchoTool
|
||||
{
|
||||
[McpTool(Description = "Echoes the input back to the client.")]
|
||||
public static string Echo([McpParameter(true)] string message)
|
||||
{
|
||||
return "hello " + message;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Here is an example of how to create an MCP server manually with a single tool. You can also refer to the TestServer in the tests folder, which implements a wider range of capabilities.
|
||||
|
||||
```csharp
|
||||
McpServerOptions options = new McpServerOptions()
|
||||
|
|
@ -171,6 +197,7 @@ while (true)
|
|||
}
|
||||
```
|
||||
|
||||
|
||||
## Roadmap
|
||||
|
||||
- Expand documentation with detailed guides for:
|
||||
|
|
|
|||
Loading…
Reference in a new issue