Table of Contents

Class McpToolRegistry

Namespace
nanoFramework.WebServer.Mcp
Assembly
nanoFramework.WebServer.Mcp.dll

Registry for Model Context Protocol (MCP) tools, allowing discovery and invocation of tools defined with the McpServerToolAttribute.

public class McpToolRegistry : RegistryBase
Inheritance
McpToolRegistry
Inherited Members
Extension Methods

Constructors

McpToolRegistry()

public McpToolRegistry()

Methods

DiscoverTools(Type[])

Discovers MCP tools by scanning the provided types for methods decorated with the McpServerToolAttribute. This method should be called once to populate the tool registry.

public static void DiscoverTools(Type[] mcpTools)

Parameters

mcpTools Type[]

An array of types to scan for MCP tools.

GetToolMetadataJson()

Gets the metadata of all registered MCP tools in JSON format. This method should be called after DiscoverTools to retrieve the tool metadata.

public static string GetToolMetadataJson()

Returns

string

A JSON string containing the metadata of all registered tools.

Exceptions

Exception

Thrown if there is an error building the tools list.

InvokeTool(string, Hashtable)

Invokes a registered MCP tool by name with the specified parameters and returns the serialized result.

public static string InvokeTool(string toolName, Hashtable parameter)

Parameters

toolName string

The name of the tool to invoke.

parameter Hashtable

The parameters to pass to the tool as a Hashtable.

Returns

string

A JSON string containing the serialized result of the tool invocation.

Exceptions

Exception

Thrown when the specified tool is not found in the registry.