# McpToolsClient

## Overview

The `McpToolsClient` component enables Wisej.AI to access and utilize tools provided by an [MCP](https://modelcontextprotocol.io/introduction) (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.

```csharp
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:

```csharp
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:

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/ai/components/built-in-smarttools/mcptoolsclient.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
