Add middleware and authz support for server-side handlers (#733)

This commit is contained in:
Stephen Halter 2025-09-10 10:07:45 -07:00 • committed by GitHub
commit d344c65120
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,7 @@
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using ModelContextProtocol.Server;
namespace ModelContextProtocol.Protocol;
@ -43,7 +44,7 @@ public sealed class Tool : IBaseMetadata
/// if an invalid schema is provided.
/// </para>
/// <para>
/// The schema typically defines the properties (parameters) that the tool accepts,
/// The schema typically defines the properties (parameters) that the tool accepts,
/// their types, and which ones are required. This helps AI models understand
/// how to structure their calls to the tool.
/// </para>
@ -52,9 +53,9 @@ public sealed class Tool : IBaseMetadata
/// </para>
/// </remarks>
[JsonPropertyName("inputSchema")]
public JsonElement InputSchema
{
get => field;
public JsonElement InputSchema
{
get => field;
set
{
if (!McpJsonUtilities.IsValidMcpToolSchema(value))
@ -114,4 +115,10 @@ public sealed class Tool : IBaseMetadata
/// </remarks>
[JsonPropertyName("_meta")]
public JsonObject? Meta { get; set; }
/// <summary>
/// Gets or sets the callable server tool corresponding to this metadata if any.
/// </summary>
[JsonIgnore]
public McpServerTool? McpServerTool { get; set; }
}