McpToolsClient

Overview

The McpToolsClient component enables Wisej.AI to access and utilize tools provided by an MCP (Model Context Protocol) server.

By acting as a communication bridge between Wisej.AI and the MCP server, McpToolsClient allows your applications to leverage advanced server-side functionalities defined by the Model Context Protocol.

You can find some public servers here: https://mcpservers.org/, https://mcp.so/.

Using McpToolsClient

To integrate the tools from an MCP server with your Wisej.AI objects, simply add an instance of the McpToolsClient class, similar to how you would add any other tool container.

this.smartPrompt1
    .UseTools(new McpToolsClient("https://remote.mcpservers.org/fetch"));

Unlike local tool containers, however, when using McpToolsClient, you do not create the tools yourself, nor does the code execute on your machine. Instead, McpToolsClient automatically discovers the tools available on the MCP server and registers them with the application model.

Create MCP Servers

Creating MCP servers is beyond the scope of Wisej.AI. However, there are many public MCP servers available, implemented in a variety of programming languages. If you prefer to develop your own MCP server using C# and ASP.NET, you can use the C# SDK, which is available at https://github.com/modelcontextprotocol/csharp-sdk. This SDK provides the necessary tools and libraries to implement an MCP server in a .NET environment.

This is a simple example on how to start the server:

var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
	Args = args,
        WebRootPath = "./"
});

builder.Services
	.AddMcpServer()
	.WithHttpTransport()
	.WithToolsFromAssembly();

var app = builder.Build();
app.MapMcp();

And this is a very simple MCP tool:

[McpServerToolType]
public class McpToolsServer
{
	[McpServerTool, Description("Echoes the message back to the client.")]
	public static string Echo(string message)
		=> $"hello {message}";
}

Last updated