using Microsoft.Extensions.AI; using ModelContextProtocol.Protocol; using System.ComponentModel; using System.Text.Json; using System.Text.Json.Nodes; namespace ModelContextProtocol.Server; /// /// Provides options for controlling the creation of an . /// /// /// /// These options allow for customizing the behavior and metadata of resources created with /// . They provide control over naming, description, /// and dependency injection integration. /// /// /// When creating resources programmatically rather than using attributes, these options /// provide the same level of configuration flexibility. /// /// public sealed class McpServerResourceCreateOptions { /// /// Gets or sets optional services used in the construction of the . /// /// /// These services will be used to determine which parameters should be satisfied from dependency injection. As such, /// what services are satisfied via this provider should match what's satisfied via the provider passed in at invocation time. /// public IServiceProvider? Services { get; set; } /// /// Gets or sets the URI template of the . /// /// /// If , but an is applied to the member, /// the from the attribute is used. If that's not present, /// a URI template will be inferred from the member's signature. /// public string? UriTemplate { get; set; } /// /// Gets or sets the name to use for the . /// /// /// If , but an is applied to the member, /// the name from the attribute is used. If that's not present, a name based on the members's name is used. /// public string? Name { get; set; } /// /// Gets or sets the title to use for the . /// public string? Title { get; set; } /// /// Gets or sets the description to use for the . /// /// /// If , but a is applied to the member, /// the description from that attribute is used. /// public string? Description { get; set; } /// /// Gets or sets the MIME (media) type of the . /// public string? MimeType { get; set; } /// /// Gets or sets the JSON serializer options to use when marshalling data to/from JSON. /// /// /// The default is . /// public JsonSerializerOptions? SerializerOptions { get; set; } /// /// Gets or sets the JSON schema options when creating from a method. /// /// /// The default is . /// public AIJsonSchemaCreateOptions? SchemaCreateOptions { get; set; } /// /// Gets or sets the metadata associated with the resource. /// /// /// Metadata includes information such as attributes extracted from the method and its declaring class. /// If not provided, metadata will be automatically generated for methods created via reflection. /// public IReadOnlyList? Metadata { get; set; } /// /// Gets or sets the icons for this resource. /// /// /// This property can be used by clients to display the resource's icon in a user interface. /// public IList? Icons { get; set; } /// /// Gets or sets metadata reserved by MCP for protocol-level metadata. /// /// /// /// This is used to seed the property. Any metadata from /// instances on the method will be added to this object, but /// properties already present in this are not overwritten. /// /// /// Implementations must not make assumptions about its contents. /// /// public JsonObject? Meta { get; set; } /// /// Creates a shallow clone of the current instance. /// internal McpServerResourceCreateOptions Clone() => new() { Services = Services, UriTemplate = UriTemplate, Name = Name, Title = Title, Description = Description, MimeType = MimeType, SerializerOptions = SerializerOptions, SchemaCreateOptions = SchemaCreateOptions, Metadata = Metadata, Icons = Icons, Meta = Meta, }; }