< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.Mcp.KestrunRouteSummary
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Mcp/KestrunMcpModels.cs
Tag: Kestrun/Kestrun@fd20e9dbe5c2c9fa4dfb9f27bd0a5c4b911dd8bd
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 240
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 04/23/2026 - 14:35:41 Line coverage: 100% (10/10) Total lines: 240 Tag: Kestrun/Kestrun@2fdbb120ca2faaa9acf2b8d2a34a7d64b067edbe

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Pattern()100%11100%
get_Verbs()100%11100%
get_Tags()100%11100%
get_Summary()100%11100%
get_Description()100%11100%
get_RequestContentTypes()100%11100%
get_ResponseContentTypes()100%11100%
get_HandlerName()100%11100%
get_HandlerLanguage()100%11100%
get_OperationId()100%11100%

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Mcp/KestrunMcpModels.cs

#LineLine coverage
 1using System.Text.Json.Nodes;
 2using Kestrun.Hosting;
 3namespace Kestrun.Mcp;
 4
 5/// <summary>
 6/// Structured error information returned by Kestrun MCP services.
 7/// </summary>
 8/// <param name="Code">Stable error code.</param>
 9/// <param name="Message">Human-readable explanation.</param>
 10/// <param name="Details">Optional machine-readable details.</param>
 11public sealed record KestrunMcpError(
 12    string Code,
 13    string Message,
 14    IReadOnlyDictionary<string, object?>? Details = null);
 15
 16/// <summary>
 17/// Summarized route metadata for MCP discovery operations.
 18/// </summary>
 19public sealed record KestrunRouteSummary
 20{
 21    /// <summary>Route pattern.</summary>
 1322    public required string Pattern { get; init; }
 23    /// <summary>HTTP methods.</summary>
 724    public required IReadOnlyList<string> Verbs { get; init; }
 25    /// <summary>OpenAPI tags.</summary>
 626    public required IReadOnlyList<string> Tags { get; init; }
 27    /// <summary>OpenAPI summary.</summary>
 528    public string? Summary { get; init; }
 29    /// <summary>OpenAPI description.</summary>
 530    public string? Description { get; init; }
 31    /// <summary>Supported request content types.</summary>
 632    public required IReadOnlyList<string> RequestContentTypes { get; init; }
 33    /// <summary>Supported response content types.</summary>
 634    public required IReadOnlyList<string> ResponseContentTypes { get; init; }
 35    /// <summary>Bound handler name when available.</summary>
 636    public string? HandlerName { get; init; }
 37    /// <summary>Best-effort script/runtime language.</summary>
 638    public string? HandlerLanguage { get; init; }
 39    /// <summary>OpenAPI operation identifier when available.</summary>
 640    public string? OperationId { get; init; }
 41}
 42
 43/// <summary>
 44/// Detailed route metadata for a single route selection.
 45/// </summary>
 46public sealed record KestrunRouteDetail
 47{
 48    /// <summary>Route summary payload.</summary>
 49    public required KestrunRouteSummary Route { get; init; }
 50    /// <summary>Request schema keyed by content type when available.</summary>
 51    public required IReadOnlyDictionary<string, JsonNode?> RequestSchemas { get; init; }
 52    /// <summary>Response metadata keyed by status code.</summary>
 53    public required IReadOnlyDictionary<string, KestrunRouteResponseSchema> Responses { get; init; }
 54    /// <summary>Route lookup error when selection fails.</summary>
 55    public KestrunMcpError? Error { get; init; }
 56}
 57
 58/// <summary>
 59/// Response metadata extracted from OpenAPI.
 60/// </summary>
 61public sealed record KestrunRouteResponseSchema
 62{
 63    /// <summary>Response description.</summary>
 64    public string? Description { get; init; }
 65    /// <summary>Response schemas keyed by content type.</summary>
 66    public required IReadOnlyDictionary<string, JsonNode?> Content { get; init; }
 67}
 68
 69/// <summary>
 70/// Structured OpenAPI document payload.
 71/// </summary>
 72public sealed record KestrunOpenApiDocumentResult
 73{
 74    /// <summary>Requested document id.</summary>
 75    public required string DocumentId { get; init; }
 76    /// <summary>Resolved OpenAPI version string.</summary>
 77    public required string Version { get; init; }
 78    /// <summary>Structured document payload.</summary>
 79    public JsonNode? Document { get; init; }
 80    /// <summary>Lookup error when retrieval fails.</summary>
 81    public KestrunMcpError? Error { get; init; }
 82}
 83
 84/// <summary>
 85/// Listener metadata exposed through runtime inspection.
 86/// </summary>
 87public sealed record KestrunRuntimeListener
 88{
 89    /// <summary>Listener URL.</summary>
 90    public required string Url { get; init; }
 91    /// <summary>Transport protocols.</summary>
 92    public required string Protocols { get; init; }
 93    /// <summary>Whether HTTPS is enabled.</summary>
 94    public bool UseHttps { get; init; }
 95}
 96
 97/// <summary>
 98/// Safe runtime inspection payload.
 99/// </summary>
 100public sealed record KestrunRuntimeInspectionResult
 101{
 102    /// <summary>Application name.</summary>
 103    public required string ApplicationName { get; init; }
 104    /// <summary>Host status.</summary>
 105    public required string Status { get; init; }
 106    /// <summary>Environment name.</summary>
 107    public required string Environment { get; init; }
 108    /// <summary>Start timestamp in UTC.</summary>
 109    public DateTime? StartTimeUtc { get; init; }
 110    /// <summary>Stop timestamp in UTC.</summary>
 111    public DateTime? StopTimeUtc { get; init; }
 112    /// <summary>Current uptime when available.</summary>
 113    public TimeSpan? Uptime { get; init; }
 114    /// <summary>Known listeners.</summary>
 115    public required IReadOnlyList<KestrunRuntimeListener> Listeners { get; init; }
 116    /// <summary>Known route count.</summary>
 117    public int RouteCount { get; init; }
 118    /// <summary>Selected safe configuration values.</summary>
 119    public required IReadOnlyDictionary<string, object?> Configuration { get; init; }
 120}
 121
 122/// <summary>
 123/// Proposed request payload used by validation and invocation tools.
 124/// </summary>
 125public sealed record KestrunRequestInput
 126{
 127    /// <summary>HTTP method.</summary>
 128    public string Method { get; init; } = "GET";
 129    /// <summary>Request path.</summary>
 130    public string Path { get; init; } = "/";
 131    /// <summary>Request headers.</summary>
 132    public IDictionary<string, string>? Headers { get; init; }
 133    /// <summary>Request query values.</summary>
 134    public IDictionary<string, string>? Query { get; init; }
 135    /// <summary>Request body.</summary>
 136    public object? Body { get; init; }
 137}
 138
 139/// <summary>
 140/// Request validation result.
 141/// </summary>
 142public sealed record KestrunRequestValidationResult
 143{
 144    /// <summary>Whether the request would likely succeed.</summary>
 145    public bool IsValid { get; init; }
 146    /// <summary>Likely resulting status code.</summary>
 147    public int StatusCode { get; init; }
 148    /// <summary>Best-effort explanation.</summary>
 149    public required string Message { get; init; }
 150    /// <summary>Matched route summary when available.</summary>
 151    public KestrunRouteSummary? Route { get; init; }
 152    /// <summary>Validation error details.</summary>
 153    public KestrunMcpError? Error { get; init; }
 154}
 155
 156/// <summary>
 157/// Route invocation result returned by the safe invoker.
 158/// </summary>
 159public sealed record KestrunRouteInvokeResult
 160{
 161    /// <summary>Response status code.</summary>
 162    public int StatusCode { get; init; }
 163    /// <summary>Response content type.</summary>
 164    public string? ContentType { get; init; }
 165    /// <summary>Response headers.</summary>
 166    public required IReadOnlyDictionary<string, string> Headers { get; init; }
 167    /// <summary>Response body text.</summary>
 168    public string? Body { get; init; }
 169    /// <summary>Invocation error details.</summary>
 170    public KestrunMcpError? Error { get; init; }
 171}
 172
 173/// <summary>
 174/// Configures safety boundaries for the MCP request invoker.
 175/// </summary>
 176public sealed record KestrunRequestInvokerOptions
 177{
 178    /// <summary>Whether route invocation is enabled.</summary>
 179    public bool EnableInvocation { get; init; }
 180    /// <summary>Allowlisted route patterns for invocation.</summary>
 181    public IReadOnlyList<string> AllowedPathPatterns { get; init; } = [];
 182    /// <summary>Headers to redact in tool output.</summary>
 183    public IReadOnlySet<string> RedactedHeaders { get; init; } =
 184        new HashSet<string>(StringComparer.OrdinalIgnoreCase)
 185        {
 186            "Authorization",
 187            "Cookie",
 188            "Set-Cookie",
 189            "Proxy-Authorization",
 190            "X-Api-Key",
 191            "Api-Key"
 192        };
 193}
 194
 195/// <summary>
 196/// Route inspection contract used by MCP tool handlers.
 197/// </summary>
 198public interface IKestrunRouteInspector
 199{
 200    /// <summary>Returns all registered routes.</summary>
 201    IReadOnlyList<KestrunRouteSummary> ListRoutes(KestrunHost host);
 202    /// <summary>Returns one selected route.</summary>
 203    KestrunRouteDetail GetRoute(KestrunHost host, string? pattern = null, string? operationId = null);
 204}
 205
 206/// <summary>
 207/// OpenAPI retrieval contract used by MCP tool handlers.
 208/// </summary>
 209public interface IKestrunOpenApiProvider
 210{
 211    /// <summary>Returns the requested OpenAPI document.</summary>
 212    KestrunOpenApiDocumentResult GetOpenApi(KestrunHost host, string? documentId = null, string? version = null);
 213}
 214
 215/// <summary>
 216/// Runtime inspection contract used by MCP tool handlers.
 217/// </summary>
 218public interface IKestrunRuntimeInspector
 219{
 220    /// <summary>Returns a safe runtime summary.</summary>
 221    KestrunRuntimeInspectionResult Inspect(KestrunHost host);
 222}
 223
 224/// <summary>
 225/// Request validation contract used by MCP tool handlers.
 226/// </summary>
 227public interface IKestrunRequestValidator
 228{
 229    /// <summary>Validates a proposed request without executing the route handler.</summary>
 230    KestrunRequestValidationResult Validate(KestrunHost host, KestrunRequestInput input);
 231}
 232
 233/// <summary>
 234/// Request invocation contract used by MCP tool handlers.
 235/// </summary>
 236public interface IKestrunRequestInvoker
 237{
 238    /// <summary>Invokes a route through the normal HTTP pipeline.</summary>
 239    Task<KestrunRouteInvokeResult> InvokeAsync(KestrunHost host, KestrunRequestInput input, CancellationToken cancellati
 240}