4using System.Threading.Tasks;
17 private readonly
string fileName;
18 private readonly
bool isTextFile;
33 string FileName, params KeyValuePair<string, object>[]
MetaData)
36 this.fileName = FileName;
37 this.isTextFile = this.IsTextFile();
40 private static string GetContentType(
string FileName)
51 private bool IsTextFile()
63 if (ContentType is
null)
70 int i = s.IndexOf(
';', 12);
74 if (s.EndsWith(
"xml") ||
76 s.EndsWith(
"script") ||
78 s.EndsWith(
"turtle") ||
87 case "application/x-www-form-urlencoded":
88 case "application/link-format":
89 case "application/jwt":
90 case "application/sparql-query":
119 params KeyValuePair<string, object>[]
MetaData)
123 this.fileName = FileName;
124 this.isTextFile = this.IsTextFile();
147 params KeyValuePair<string, object>[]
MetaData)
151 this.fileName = FileName;
152 this.isTextFile = this.IsTextFile();
176 params KeyValuePair<string, object>[]
MetaData)
180 this.fileName = FileName;
181 this.isTextFile = this.IsTextFile();
205 params KeyValuePair<string, object>[]
MetaData)
209 this.fileName = FileName;
210 this.isTextFile = this.IsTextFile();
245 params KeyValuePair<string, object>[]
MetaData)
250 this.fileName = FileName;
251 this.isTextFile = this.IsTextFile();
259 public override async Task<IResourceContent[]>
Read(
260 Dictionary<string, object>?
MetaData)
const string DefaultContentType
text/plain
Static class managing encoding and decoding of internet content.
static bool TryGetContentType(string FileExtension, out string ContentType)
Tries to get the content type of an item, given its file extension.
DateTime? LastModified
The moment the resource was last modified, as an ISO 8601 formatted string.
double? Priority
Describes how important this data is for operating the server.
McpRole?[] Audience
Describes who the intended audience of this object or data is.
An optionally-sized icon that can be displayed in a user interface.
Base interface to add icons property.
Contains information about an MCP Server File Resource
FileResource(string Name, string Title, string Description, Uri Uri, string FileName, string? RequiredPrivilege, long? Size, params KeyValuePair< string, object >[] MetaData)
Contains information about an MCP Server File Resource
FileResource(string Name, string Title, string Description, Uri Uri, string FileName, string? RequiredPrivilege, long? Size, Icon Icon, params KeyValuePair< string, object >[] MetaData)
Contains information about an MCP Server File Resource
FileResource(string Name, string Title, string Description, Uri Uri, string FileName, string? RequiredPrivilege, long? Size, Icons? Icons, McpRole[]? Audience, double? Priority, DateTime? LastModified, params KeyValuePair< string, object >[] MetaData)
Contains information about an MCP Server File Resource
FileResource(string Name, string Title, string Description, Uri Uri, string FileName, string? RequiredPrivilege, params KeyValuePair< string, object >[] MetaData)
Contains information about an MCP Server File Resource
FileResource(string Name, string Title, string Description, Uri Uri, string FileName, params KeyValuePair< string, object >[] MetaData)
Contains information about an MCP Server File Resource
static bool IsTextFile(string? ContentType)
Checks if a Content-Type represents a text file.
override async Task< IResourceContent[]> Read(Dictionary< string, object >? MetaData)
Reads the resource.
FileResource(string Name, string Title, string Description, Uri Uri, string FileName, string? RequiredPrivilege, long? Size, Icons? Icons, params KeyValuePair< string, object >[] MetaData)
Contains information about an MCP Server File Resource
Contains information about an MCP Server Resource
Uri Uri
URI of the resource.
string Title
A human-readable title for the prompt.
string Name
Name of resource.
KeyValuePair< string, object >[] MetaData
Meta-data associated with prompt.
string? RequiredPrivilege
Privilege required to access the resource, if any. If null, no additional privilege is required.
long? Size
The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization),...
string Description
A human-readable description of the prompt.
string? ContentType
Content-Type of resource, if known.
static async Task< string > ReadAllTextAsync(string FileName)
Reads a text file asynchronously.
static async Task< byte[]> ReadAllBytesAsync(string FileName)
Reads a binary file asynchronously.
Interface for MCP Resource Content.
McpRole
Identifies a Role in a Model Context Protocol (MCP) context.