2using System.Diagnostics.CodeAnalysis;
3using System.Reflection;
4using System.Threading.Tasks;
16 private Icons? icons =
null;
65 public KeyValuePair<string, object>[]
MetaData {
get; }
81 Dictionary<string, object> Result =
new Dictionary<string, object>()
83 {
"name", this.Method.Name }
86 PopulateArguments(this.
Method, Result);
88 if (!
string.IsNullOrEmpty(this.
Title))
89 Result.Add(
"title", this.
Title);
94 if (!this.icons.
Empty)
95 Result.Add(
"icons", this.icons.
ToJson());
97 if ((this.
MetaData?.Length ?? 0) > 0)
99 Dictionary<string, object>
MetaData =
new Dictionary<string, object>();
101 foreach (KeyValuePair<string, object> P
in this.
MetaData!)
110 private static void PopulateArguments(MethodInfo
Method,
111 Dictionary<string, object> Result)
113 ParameterInfo[] Parameters =
Method.GetParameters();
117 foreach (ParameterInfo Parameter
in Parameters)
119 Dictionary<string, object?> PromptArgument =
new Dictionary<string, object?>()
121 {
"name", Parameter.Name },
122 {
"required", !Parameter.HasDefaultValue }
126 Attribute?.
Annotate(PromptArgument);
133 Result[
"arguments"] =
Arguments.ToArray();
150 Dictionary<string, object?>?
MetaData,
151 [NotNullWhen(
false)] out
string? Reason,
152 [NotNullWhen(
true)] out
object?[]?
Arguments)
Represents an HTTP request.
Represets a response of an HTTP client request.
Information about a protected method.
ProtectedMethodArgumentInfo[] Arguments
Arguments
int? RequestArgument
Request argument index
int? IdArgument
ID argument index
MethodInfo Method
Method information.
int? ResponseArgument
Response argument index
Abstract base class for HTTP-based Model Context Protocol (MCP) server resource, as defined in:
Provides meta-data about a parameter.
virtual void Annotate(Dictionary< string, object?> Schema)
Annotates a schema object with information in the attribute.
Base interface to add icons property.
bool Empty
If there are icons defined.
Dictionary< string, object >[] ToJson()
Converts object to a generic representation.
Contains information about an MCP Server Prompt
string IconsMethod
Name of method that returns an Icon?, an an Icon[]? or an Icons? resource representing the prompt....
string Title
A human-readable title for the prompt.
McpParameterAttribute? ReturnAttributes
Any MCP attributes declared for the return value.
KeyValuePair< string, object >[] MetaData
Meta-data associated with prompt.
bool TryBuildRequest(object? Id, Dictionary< string, object?> Parameters, HttpRequest Request, HttpResponse Response, Dictionary< string, object?>? MetaData, [NotNullWhen(false)] out string? Reason, [NotNullWhen(true)] out object?[]? Arguments)
Tries to build a request for the method, based on the provided named parameters.
Prompt(MethodInfo Method, string Title, string Description, string IconsMethod, params KeyValuePair< string, object >[] MetaData)
Contains information about an MCP Server Prompt
async Task< Dictionary< string, object > > ToJson(HttpMcpServerResource Resource)
Converts object to a generic representation.
string Description
A human-readable description of the prompt.
Contains information about an MCP Server Resource
A chunked list is a linked list of chunks of objects of type T .