Table of Contents

Class McpPromptRegistry

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

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

public class McpPromptRegistry : RegistryBase
Inheritance
McpPromptRegistry
Inherited Members
Extension Methods

Constructors

McpPromptRegistry()

public McpPromptRegistry()

Methods

DiscoverPrompts(Type[])

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

public static void DiscoverPrompts(Type[] typesWithPrompts)

Parameters

typesWithPrompts Type[]

An array of types to scan for MCP prompts.

GetPromptDescription(string)

Gets the description of a registered MCP prompt by its name.

public static string GetPromptDescription(string promptName)

Parameters

promptName string

The name of the prompt to invoke.

Returns

string

A string containing the description of the prompt.

Exceptions

Exception

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

GetPromptMetadataJson()

Gets the metadata of all registered MCP prompts in JSON format. This method should be called after DiscoverPrompts(Type[]) to retrieve the prompt metadata.

public static string GetPromptMetadataJson()

Returns

string

A JSON string containing the metadata of all registered prompts.

Exceptions

Exception

Thrown if there is an error building the prompts list.

InvokePrompt(string, Hashtable)

Invokes a registered MCP prompt by name and returns the serialized result.

public static string InvokePrompt(string promptName, Hashtable arguments)

Parameters

promptName string

The name of the prompt to invoke.

arguments Hashtable

The arguments to pass to the tool.

Returns

string

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

Exceptions

Exception

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