Skip to content

AgentPrismMcpServerBuilderExtensions

Namespace AgentPrism · Assembly AgentPrism.AspNetCore.dll

Extensions that register the services needed to publish AgentPrism agents as MCP tools.

public static class AgentPrismMcpServerBuilderExtensions

objectAgentPrismMcpServerBuilderExtensions

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

UseMcpServer(IAgentPrismBuilder, Action<AgentPrismMcpServerOptions>?)

Section titled “ UseMcpServer(IAgentPrismBuilder, Action<AgentPrismMcpServerOptions>?)”

Registers the MCP server services. The HTTP endpoint must still be connected separately with app.MapAgentPrismMcpServer(...).

public static IAgentPrismBuilder UseMcpServer(this IAgentPrismBuilder builder, Action<AgentPrismMcpServerOptions>? configure = null)

builder IAgentPrismBuilder

The AgentPrism configuration chain.

configure Action<AgentPrismMcpServerOptions>?

Options mutator.

IAgentPrismBuilder

The chain, for further configuration.

Registration happens HERE, not in MapAgentPrismMcpServer: the MCP SDK’s AddMcpServer call operates on IServiceCollection and must happen BEFORE the application is Build-ed. The Map... extensions only connect already-built services to HTTP.

By default no agent is exposed. Exposing one requires an explicit choice via AgentPrismMcpServerOptions.ExposedAgents or AgentPrismMcpServerOptions.ExposeAllAgents.

builder.AddAgentPrism()
.UseOpenAI(apiKey)
.UsePostgreSql(connectionString)
.UseMcpServer(o => o.ExposedAgents.Add("asistan"));
// ...
app.MapAgentPrism("/agentprism");
app.MapAgentPrismMcpServer();

ArgumentNullException

builder is null.