McpEndpointRouteBuilderExtensions Class
Assembly: CodeEffects.Rule.Mcp.dll
Namespace: CodeEffects.Rule.Mcp
Summary
Maps the MCP endpoint of the Code Effects server into the routing of an ASP.NET Core application. It holds the extension method MapCodeEffectsMcp(..).
Syntax
public static class McpEndpointRouteBuilderExtensions
Map the endpoint after the services were registered with AddCodeEffectsMcp(..), and put your authentication on it. The server never signs a caller in and never stores a credential; a request that your authentication did not verify is refused.
Methods
MapCodeEffectsMcp(..)
Returns: Microsoft.AspNetCore.Builder.IEndpointConventionBuilder - The convention builder of the endpoint, to which you add the authorization of your application.
public static IEndpointConventionBuilder MapCodeEffectsMcp(this IEndpointRouteBuilder endpoints, string pattern = "/mcp")
An extension method of Microsoft.AspNetCore.Routing.IEndpointRouteBuilder, which WebApplication implements. Maps the MCP endpoint at pattern. Add .RequireAuthorization(), or a policy of your own, to the returned builder.
Parameters
- endpoints (
Microsoft.AspNetCore.Routing.IEndpointRouteBuilder) - The endpoint route builder, usually the WebApplication.
- pattern (
System.String) - The route pattern of the endpoint. The default is "/mcp".
Exceptions
System.ArgumentNullException - endpoints is null.
Example
using CodeEffects.Rule.Mcp;
using Microsoft.AspNetCore.Builder;
var app = builder.Build();
app.UseAuthentication();
app.UseAuthorization();
app.MapCodeEffectsMcp("/mcp").RequireAuthorization();
app.Run();