Skip to content

McpToolRegistry

Namespace AgentPrism · Assembly AgentPrism.Mcp.dll

A registry that combines tools registered in code with those discovered from remote MCP servers.

public sealed class McpToolRegistry : IToolRegistry

objectMcpToolRegistry

IToolRegistry

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Code always wins. An MCP tool with the same name can never replace a tool registered in code. Otherwise, a remote server could take over a local tool’s name and silently hijack the agent’s behavior. This is a natural extension of the code-only tools rule.

MCP tools are resolved per tenant: servers are registered per tenant, and a tool coming from one tenant’s server is not visible to another tenant.

Returns the definitions of all registered tools, ordered by name.

public IReadOnlyList<ToolDescriptor> List()

IReadOnlyList<ToolDescriptor>

The tool definitions.

TryGet(string, out AIFunctionDeclaration?)

Section titled “ TryGet(string, out AIFunctionDeclaration?)”

Fetches the tool with the given name.

public bool TryGet(string name, out AIFunctionDeclaration? tool)

name string

The tool name. Comparison is case-sensitive.

tool AIFunctionDeclaration?

The tool found.

bool

true if the tool is registered.

The result is an AI.AIFunctionDeclaration, not an AI.AIFunction: a client-side tool (AddClientTool) is registered as a declaration-only AIFunctionDeclaration, which is not an AI.AIFunction and cannot be invoked. Every registered tool — server-side or client-side — is an AI.AIFunctionDeclaration, so AIFunctionDeclaration.JsonSchema is always available. Callers pass the result straight to ChatOptions.Tools, which accepts the broader AITool.