Styling: remove a few redundant parens from object initializer expressions. (#548)
* Styling: remove a few redundant parens from object initializer expressions. * Fix build error.
This commit is contained in:
parent
802424ee08
commit
55bda787ae
23 changed files with 108 additions and 108 deletions
10
README.md
10
README.md
|
|
@ -173,17 +173,17 @@ using System.Text.Json;
|
||||||
|
|
||||||
McpServerOptions options = new()
|
McpServerOptions options = new()
|
||||||
{
|
{
|
||||||
ServerInfo = new Implementation() { Name = "MyServer", Version = "1.0.0" },
|
ServerInfo = new Implementation { Name = "MyServer", Version = "1.0.0" },
|
||||||
Capabilities = new ServerCapabilities()
|
Capabilities = new ServerCapabilities
|
||||||
{
|
{
|
||||||
Tools = new ToolsCapability()
|
Tools = new ToolsCapability
|
||||||
{
|
{
|
||||||
ListToolsHandler = (request, cancellationToken) =>
|
ListToolsHandler = (request, cancellationToken) =>
|
||||||
ValueTask.FromResult(new ListToolsResult()
|
ValueTask.FromResult(new ListToolsResult
|
||||||
{
|
{
|
||||||
Tools =
|
Tools =
|
||||||
[
|
[
|
||||||
new Tool()
|
new Tool
|
||||||
{
|
{
|
||||||
Name = "echo",
|
Name = "echo",
|
||||||
Description = "Echoes the input back to the client.",
|
Description = "Echoes the input back to the client.",
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ public class AnnotatedMessageTool
|
||||||
|
|
||||||
if (includeImage)
|
if (includeImage)
|
||||||
{
|
{
|
||||||
contents.Add(new ImageContentBlock()
|
contents.Add(new ImageContentBlock
|
||||||
{
|
{
|
||||||
Data = TinyImageTool.MCP_TINY_IMAGE.Split(",").Last(),
|
Data = TinyImageTool.MCP_TINY_IMAGE.Split(",").Last(),
|
||||||
MimeType = "image/png",
|
MimeType = "image/png",
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ public class SampleLlmTool
|
||||||
|
|
||||||
private static CreateMessageRequestParams CreateRequestSamplingParams(string context, string uri, int maxTokens = 100)
|
private static CreateMessageRequestParams CreateRequestSamplingParams(string context, string uri, int maxTokens = 100)
|
||||||
{
|
{
|
||||||
return new CreateMessageRequestParams()
|
return new CreateMessageRequestParams
|
||||||
{
|
{
|
||||||
Messages = [new SamplingMessage()
|
Messages = [new SamplingMessage
|
||||||
{
|
{
|
||||||
Role = Role.User,
|
Role = Role.User,
|
||||||
Content = new TextContentBlock { Text = $"Resource {uri} context: {context}" },
|
Content = new TextContentBlock { Text = $"Resource {uri} context: {context}" },
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@ public sealed class SampleLlmTool
|
||||||
|
|
||||||
private static CreateMessageRequestParams CreateRequestSamplingParams(string context, string uri, int maxTokens = 100)
|
private static CreateMessageRequestParams CreateRequestSamplingParams(string context, string uri, int maxTokens = 100)
|
||||||
{
|
{
|
||||||
return new CreateMessageRequestParams()
|
return new CreateMessageRequestParams
|
||||||
{
|
{
|
||||||
Messages = [new SamplingMessage()
|
Messages = [new SamplingMessage
|
||||||
{
|
{
|
||||||
Role = Role.User,
|
Role = Role.User,
|
||||||
Content = new TextContentBlock { Text = $"Resource {uri} context: {context}" },
|
Content = new TextContentBlock { Text = $"Resource {uri} context: {context}" },
|
||||||
|
|
|
||||||
|
|
@ -188,21 +188,21 @@ public static class AIContentExtensions
|
||||||
Text = textContent.Text,
|
Text = textContent.Text,
|
||||||
},
|
},
|
||||||
|
|
||||||
DataContent dataContent when dataContent.HasTopLevelMediaType("image") => new ImageContentBlock()
|
DataContent dataContent when dataContent.HasTopLevelMediaType("image") => new ImageContentBlock
|
||||||
{
|
{
|
||||||
Data = dataContent.Base64Data.ToString(),
|
Data = dataContent.Base64Data.ToString(),
|
||||||
MimeType = dataContent.MediaType,
|
MimeType = dataContent.MediaType,
|
||||||
},
|
},
|
||||||
|
|
||||||
DataContent dataContent when dataContent.HasTopLevelMediaType("audio") => new AudioContentBlock()
|
DataContent dataContent when dataContent.HasTopLevelMediaType("audio") => new AudioContentBlock
|
||||||
{
|
{
|
||||||
Data = dataContent.Base64Data.ToString(),
|
Data = dataContent.Base64Data.ToString(),
|
||||||
MimeType = dataContent.MediaType,
|
MimeType = dataContent.MediaType,
|
||||||
},
|
},
|
||||||
|
|
||||||
DataContent dataContent => new EmbeddedResourceBlock()
|
DataContent dataContent => new EmbeddedResourceBlock
|
||||||
{
|
{
|
||||||
Resource = new BlobResourceContents()
|
Resource = new BlobResourceContents
|
||||||
{
|
{
|
||||||
Blob = dataContent.Base64Data.ToString(),
|
Blob = dataContent.Base64Data.ToString(),
|
||||||
MimeType = dataContent.MediaType,
|
MimeType = dataContent.MediaType,
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ public abstract class ContentBlock
|
||||||
Meta = meta,
|
Meta = meta,
|
||||||
},
|
},
|
||||||
|
|
||||||
"image" => new ImageContentBlock()
|
"image" => new ImageContentBlock
|
||||||
{
|
{
|
||||||
Data = data ?? throw new JsonException("Image data must be provided for 'image' type."),
|
Data = data ?? throw new JsonException("Image data must be provided for 'image' type."),
|
||||||
MimeType = mimeType ?? throw new JsonException("MIME type must be provided for 'image' type."),
|
MimeType = mimeType ?? throw new JsonException("MIME type must be provided for 'image' type."),
|
||||||
|
|
@ -157,7 +157,7 @@ public abstract class ContentBlock
|
||||||
Meta = meta,
|
Meta = meta,
|
||||||
},
|
},
|
||||||
|
|
||||||
"audio" => new AudioContentBlock()
|
"audio" => new AudioContentBlock
|
||||||
{
|
{
|
||||||
Data = data ?? throw new JsonException("Audio data must be provided for 'audio' type."),
|
Data = data ?? throw new JsonException("Audio data must be provided for 'audio' type."),
|
||||||
MimeType = mimeType ?? throw new JsonException("MIME type must be provided for 'audio' type."),
|
MimeType = mimeType ?? throw new JsonException("MIME type must be provided for 'audio' type."),
|
||||||
|
|
@ -165,14 +165,14 @@ public abstract class ContentBlock
|
||||||
Meta = meta,
|
Meta = meta,
|
||||||
},
|
},
|
||||||
|
|
||||||
"resource" => new EmbeddedResourceBlock()
|
"resource" => new EmbeddedResourceBlock
|
||||||
{
|
{
|
||||||
Resource = resource ?? throw new JsonException("Resource contents must be provided for 'resource' type."),
|
Resource = resource ?? throw new JsonException("Resource contents must be provided for 'resource' type."),
|
||||||
Annotations = annotations,
|
Annotations = annotations,
|
||||||
Meta = meta,
|
Meta = meta,
|
||||||
},
|
},
|
||||||
|
|
||||||
"resource_link" => new ResourceLinkBlock()
|
"resource_link" => new ResourceLinkBlock
|
||||||
{
|
{
|
||||||
Uri = uri ?? throw new JsonException("URI must be provided for 'resource_link' type."),
|
Uri = uri ?? throw new JsonException("URI must be provided for 'resource_link' type."),
|
||||||
Name = name ?? throw new JsonException("Name must be provided for 'resource_link' type."),
|
Name = name ?? throw new JsonException("Name must be provided for 'resource_link' type."),
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ public sealed class ProgressNotificationParams : NotificationParams
|
||||||
return new ProgressNotificationParams
|
return new ProgressNotificationParams
|
||||||
{
|
{
|
||||||
ProgressToken = progressToken.GetValueOrDefault(),
|
ProgressToken = progressToken.GetValueOrDefault(),
|
||||||
Progress = new ProgressNotificationValue()
|
Progress = new ProgressNotificationValue
|
||||||
{
|
{
|
||||||
Progress = progress.GetValueOrDefault(),
|
Progress = progress.GetValueOrDefault(),
|
||||||
Total = total,
|
Total = total,
|
||||||
|
|
|
||||||
|
|
@ -421,14 +421,14 @@ internal sealed class AIFunctionMcpServerResource : McpServerResource
|
||||||
Contents = aiContents.Select<AIContent, ResourceContents>(
|
Contents = aiContents.Select<AIContent, ResourceContents>(
|
||||||
ac => ac switch
|
ac => ac switch
|
||||||
{
|
{
|
||||||
TextContent tc => new TextResourceContents()
|
TextContent tc => new TextResourceContents
|
||||||
{
|
{
|
||||||
Uri = request.Params!.Uri,
|
Uri = request.Params!.Uri,
|
||||||
MimeType = ProtocolResourceTemplate.MimeType,
|
MimeType = ProtocolResourceTemplate.MimeType,
|
||||||
Text = tc.Text
|
Text = tc.Text
|
||||||
},
|
},
|
||||||
|
|
||||||
DataContent dc => new BlobResourceContents()
|
DataContent dc => new BlobResourceContents
|
||||||
{
|
{
|
||||||
Uri = request.Params!.Uri,
|
Uri = request.Params!.Uri,
|
||||||
MimeType = dc.MediaType,
|
MimeType = dc.MediaType,
|
||||||
|
|
@ -441,7 +441,7 @@ internal sealed class AIFunctionMcpServerResource : McpServerResource
|
||||||
|
|
||||||
IEnumerable<string> strings => new()
|
IEnumerable<string> strings => new()
|
||||||
{
|
{
|
||||||
Contents = strings.Select<string, ResourceContents>(text => new TextResourceContents()
|
Contents = strings.Select<string, ResourceContents>(text => new TextResourceContents
|
||||||
{
|
{
|
||||||
Uri = request.Params!.Uri,
|
Uri = request.Params!.Uri,
|
||||||
MimeType = ProtocolResourceTemplate.MimeType,
|
MimeType = ProtocolResourceTemplate.MimeType,
|
||||||
|
|
|
||||||
|
|
@ -103,12 +103,12 @@ public static class McpServerExtensions
|
||||||
{
|
{
|
||||||
Role = role,
|
Role = role,
|
||||||
Content = dataContent.HasTopLevelMediaType("image") ?
|
Content = dataContent.HasTopLevelMediaType("image") ?
|
||||||
new ImageContentBlock()
|
new ImageContentBlock
|
||||||
{
|
{
|
||||||
MimeType = dataContent.MediaType,
|
MimeType = dataContent.MediaType,
|
||||||
Data = dataContent.Base64Data.ToString(),
|
Data = dataContent.Base64Data.ToString(),
|
||||||
} :
|
} :
|
||||||
new AudioContentBlock()
|
new AudioContentBlock
|
||||||
{
|
{
|
||||||
MimeType = dataContent.MediaType,
|
MimeType = dataContent.MediaType,
|
||||||
Data = dataContent.Base64Data.ToString(),
|
Data = dataContent.Base64Data.ToString(),
|
||||||
|
|
@ -344,7 +344,7 @@ public static class McpServerExtensions
|
||||||
|
|
||||||
void Log(LogLevel logLevel, string message)
|
void Log(LogLevel logLevel, string message)
|
||||||
{
|
{
|
||||||
_ = server.SendNotificationAsync(NotificationMethods.LoggingMessageNotification, new LoggingMessageNotificationParams()
|
_ = server.SendNotificationAsync(NotificationMethods.LoggingMessageNotification, new LoggingMessageNotificationParams
|
||||||
{
|
{
|
||||||
Level = McpServer.ToLoggingLevel(logLevel),
|
Level = McpServer.ToLoggingLevel(logLevel),
|
||||||
Data = JsonSerializer.SerializeToElement(message, McpJsonUtilities.JsonContext.Default.String),
|
Data = JsonSerializer.SerializeToElement(message, McpJsonUtilities.JsonContext.Default.String),
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ public abstract class MapMcpTests(ITestOutputHelper testOutputHelper) : KestrelI
|
||||||
// Default behavior when no options are provided
|
// Default behavior when no options are provided
|
||||||
path ??= UseStreamableHttp ? "/" : "/sse";
|
path ??= UseStreamableHttp ? "/" : "/sse";
|
||||||
|
|
||||||
await using var transport = new SseClientTransport(transportOptions ?? new SseClientTransportOptions()
|
await using var transport = new SseClientTransport(transportOptions ?? new SseClientTransportOptions
|
||||||
{
|
{
|
||||||
Endpoint = new Uri($"http://localhost{path}"),
|
Endpoint = new Uri($"http://localhost{path}"),
|
||||||
TransportMode = UseStreamableHttp ? HttpTransportMode.StreamableHttp : HttpTransportMode.Sse,
|
TransportMode = UseStreamableHttp ? HttpTransportMode.StreamableHttp : HttpTransportMode.Sse,
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@ public partial class SseIntegrationTests(ITestOutputHelper outputHelper) : Kestr
|
||||||
app.MapMcp();
|
app.MapMcp();
|
||||||
await app.StartAsync(TestContext.Current.CancellationToken);
|
await app.StartAsync(TestContext.Current.CancellationToken);
|
||||||
|
|
||||||
var sseOptions = new SseClientTransportOptions()
|
var sseOptions = new SseClientTransportOptions
|
||||||
{
|
{
|
||||||
Endpoint = new Uri("http://localhost/sse"),
|
Endpoint = new Uri("http://localhost/sse"),
|
||||||
Name = "In-memory SSE Client",
|
Name = "In-memory SSE Client",
|
||||||
|
|
@ -222,7 +222,7 @@ public partial class SseIntegrationTests(ITestOutputHelper outputHelper) : Kestr
|
||||||
app.MapMcp();
|
app.MapMcp();
|
||||||
await app.StartAsync(TestContext.Current.CancellationToken);
|
await app.StartAsync(TestContext.Current.CancellationToken);
|
||||||
|
|
||||||
var sseOptions = new SseClientTransportOptions()
|
var sseOptions = new SseClientTransportOptions
|
||||||
{
|
{
|
||||||
Endpoint = new Uri("http://localhost/sse"),
|
Endpoint = new Uri("http://localhost/sse"),
|
||||||
Name = "In-memory SSE Client",
|
Name = "In-memory SSE Client",
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ public class SseServerIntegrationTestFixture : IAsyncDisposable
|
||||||
|
|
||||||
public SseServerIntegrationTestFixture()
|
public SseServerIntegrationTestFixture()
|
||||||
{
|
{
|
||||||
var socketsHttpHandler = new SocketsHttpHandler()
|
var socketsHttpHandler = new SocketsHttpHandler
|
||||||
{
|
{
|
||||||
ConnectCallback = (context, token) =>
|
ConnectCallback = (context, token) =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ public class StreamableHttpClientConformanceTests(ITestOutputHelper outputHelper
|
||||||
return Results.Json(new JsonRpcResponse
|
return Results.Json(new JsonRpcResponse
|
||||||
{
|
{
|
||||||
Id = request.Id,
|
Id = request.Id,
|
||||||
Result = JsonSerializer.SerializeToNode(new CallToolResult()
|
Result = JsonSerializer.SerializeToNode(new CallToolResult
|
||||||
{
|
{
|
||||||
Content = [new TextContentBlock { Text = parameters.Arguments["message"].ToString() }],
|
Content = [new TextContentBlock { Text = parameters.Arguments["message"].ToString() }],
|
||||||
}, McpJsonUtilities.DefaultOptions),
|
}, McpJsonUtilities.DefaultOptions),
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ public class KestrelInMemoryTest : LoggedTest
|
||||||
Builder.Services.AddSingleton<IConnectionListenerFactory>(_inMemoryTransport);
|
Builder.Services.AddSingleton<IConnectionListenerFactory>(_inMemoryTransport);
|
||||||
Builder.Services.AddSingleton(XunitLoggerProvider);
|
Builder.Services.AddSingleton(XunitLoggerProvider);
|
||||||
|
|
||||||
HttpClient = new HttpClient(new SocketsHttpHandler()
|
HttpClient = new HttpClient(new SocketsHttpHandler
|
||||||
{
|
{
|
||||||
ConnectCallback = (context, token) =>
|
ConnectCallback = (context, token) =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ internal static class Program
|
||||||
|
|
||||||
McpServerOptions options = new()
|
McpServerOptions options = new()
|
||||||
{
|
{
|
||||||
Capabilities = new ServerCapabilities()
|
Capabilities = new ServerCapabilities
|
||||||
{
|
{
|
||||||
Tools = ConfigureTools(),
|
Tools = ConfigureTools(),
|
||||||
Resources = ConfigureResources(),
|
Resources = ConfigureResources(),
|
||||||
|
|
@ -75,7 +75,7 @@ internal static class Program
|
||||||
if (_minimumLoggingLevel is not null)
|
if (_minimumLoggingLevel is not null)
|
||||||
{
|
{
|
||||||
var logLevel = loggingLevels[random.Next(loggingLevels.Length)];
|
var logLevel = loggingLevels[random.Next(loggingLevels.Length)];
|
||||||
await server.SendMessageAsync(new JsonRpcNotification()
|
await server.SendMessageAsync(new JsonRpcNotification
|
||||||
{
|
{
|
||||||
Method = NotificationMethods.LoggingMessageNotification,
|
Method = NotificationMethods.LoggingMessageNotification,
|
||||||
Params = JsonSerializer.SerializeToNode(new LoggingMessageNotificationParams
|
Params = JsonSerializer.SerializeToNode(new LoggingMessageNotificationParams
|
||||||
|
|
@ -111,11 +111,11 @@ internal static class Program
|
||||||
{
|
{
|
||||||
ListToolsHandler = async (request, cancellationToken) =>
|
ListToolsHandler = async (request, cancellationToken) =>
|
||||||
{
|
{
|
||||||
return new ListToolsResult()
|
return new ListToolsResult
|
||||||
{
|
{
|
||||||
Tools =
|
Tools =
|
||||||
[
|
[
|
||||||
new Tool()
|
new Tool
|
||||||
{
|
{
|
||||||
Name = "echo",
|
Name = "echo",
|
||||||
Description = "Echoes the input back to the client.",
|
Description = "Echoes the input back to the client.",
|
||||||
|
|
@ -132,7 +132,7 @@ internal static class Program
|
||||||
}
|
}
|
||||||
"""),
|
"""),
|
||||||
},
|
},
|
||||||
new Tool()
|
new Tool
|
||||||
{
|
{
|
||||||
Name = "echoSessionId",
|
Name = "echoSessionId",
|
||||||
Description = "Echoes the session id back to the client.",
|
Description = "Echoes the session id back to the client.",
|
||||||
|
|
@ -142,7 +142,7 @@ internal static class Program
|
||||||
}
|
}
|
||||||
""", McpJsonUtilities.DefaultOptions),
|
""", McpJsonUtilities.DefaultOptions),
|
||||||
},
|
},
|
||||||
new Tool()
|
new Tool
|
||||||
{
|
{
|
||||||
Name = "sampleLLM",
|
Name = "sampleLLM",
|
||||||
Description = "Samples from an LLM using MCP's sampling feature.",
|
Description = "Samples from an LLM using MCP's sampling feature.",
|
||||||
|
|
@ -175,14 +175,14 @@ internal static class Program
|
||||||
{
|
{
|
||||||
throw new McpException("Missing required argument 'message'", McpErrorCode.InvalidParams);
|
throw new McpException("Missing required argument 'message'", McpErrorCode.InvalidParams);
|
||||||
}
|
}
|
||||||
return new CallToolResult()
|
return new CallToolResult
|
||||||
{
|
{
|
||||||
Content = [new TextContentBlock { Text = $"Echo: {message}" }]
|
Content = [new TextContentBlock { Text = $"Echo: {message}" }]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if (request.Params?.Name == "echoSessionId")
|
else if (request.Params?.Name == "echoSessionId")
|
||||||
{
|
{
|
||||||
return new CallToolResult()
|
return new CallToolResult
|
||||||
{
|
{
|
||||||
Content = [new TextContentBlock { Text = request.Server.SessionId ?? string.Empty }]
|
Content = [new TextContentBlock { Text = request.Server.SessionId ?? string.Empty }]
|
||||||
};
|
};
|
||||||
|
|
@ -198,7 +198,7 @@ internal static class Program
|
||||||
var sampleResult = await request.Server.SampleAsync(CreateRequestSamplingParams(prompt.ToString(), "sampleLLM", Convert.ToInt32(maxTokens.GetRawText())),
|
var sampleResult = await request.Server.SampleAsync(CreateRequestSamplingParams(prompt.ToString(), "sampleLLM", Convert.ToInt32(maxTokens.GetRawText())),
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
|
|
||||||
return new CallToolResult()
|
return new CallToolResult
|
||||||
{
|
{
|
||||||
Content = [new TextContentBlock { Text = $"LLM sampling result: {(sampleResult.Content as TextContentBlock)?.Text}" }]
|
Content = [new TextContentBlock { Text = $"LLM sampling result: {(sampleResult.Content as TextContentBlock)?.Text}" }]
|
||||||
};
|
};
|
||||||
|
|
@ -217,27 +217,27 @@ internal static class Program
|
||||||
{
|
{
|
||||||
ListPromptsHandler = async (request, cancellationToken) =>
|
ListPromptsHandler = async (request, cancellationToken) =>
|
||||||
{
|
{
|
||||||
return new ListPromptsResult()
|
return new ListPromptsResult
|
||||||
{
|
{
|
||||||
Prompts = [
|
Prompts = [
|
||||||
new Prompt()
|
new Prompt
|
||||||
{
|
{
|
||||||
Name = "simple_prompt",
|
Name = "simple_prompt",
|
||||||
Description = "A prompt without arguments"
|
Description = "A prompt without arguments"
|
||||||
},
|
},
|
||||||
new Prompt()
|
new Prompt
|
||||||
{
|
{
|
||||||
Name = "complex_prompt",
|
Name = "complex_prompt",
|
||||||
Description = "A prompt with arguments",
|
Description = "A prompt with arguments",
|
||||||
Arguments =
|
Arguments =
|
||||||
[
|
[
|
||||||
new PromptArgument()
|
new PromptArgument
|
||||||
{
|
{
|
||||||
Name = "temperature",
|
Name = "temperature",
|
||||||
Description = "Temperature setting",
|
Description = "Temperature setting",
|
||||||
Required = true
|
Required = true
|
||||||
},
|
},
|
||||||
new PromptArgument()
|
new PromptArgument
|
||||||
{
|
{
|
||||||
Name = "style",
|
Name = "style",
|
||||||
Description = "Output style",
|
Description = "Output style",
|
||||||
|
|
@ -254,7 +254,7 @@ internal static class Program
|
||||||
List<PromptMessage> messages = [];
|
List<PromptMessage> messages = [];
|
||||||
if (request.Params?.Name == "simple_prompt")
|
if (request.Params?.Name == "simple_prompt")
|
||||||
{
|
{
|
||||||
messages.Add(new PromptMessage()
|
messages.Add(new PromptMessage
|
||||||
{
|
{
|
||||||
Role = Role.User,
|
Role = Role.User,
|
||||||
Content = new TextContentBlock { Text = "This is a simple prompt without arguments." },
|
Content = new TextContentBlock { Text = "This is a simple prompt without arguments." },
|
||||||
|
|
@ -264,20 +264,20 @@ internal static class Program
|
||||||
{
|
{
|
||||||
string temperature = request.Params.Arguments?["temperature"].ToString() ?? "unknown";
|
string temperature = request.Params.Arguments?["temperature"].ToString() ?? "unknown";
|
||||||
string style = request.Params.Arguments?["style"].ToString() ?? "unknown";
|
string style = request.Params.Arguments?["style"].ToString() ?? "unknown";
|
||||||
messages.Add(new PromptMessage()
|
messages.Add(new PromptMessage
|
||||||
{
|
{
|
||||||
Role = Role.User,
|
Role = Role.User,
|
||||||
Content = new TextContentBlock { Text = $"This is a complex prompt with arguments: temperature={temperature}, style={style}" },
|
Content = new TextContentBlock { Text = $"This is a complex prompt with arguments: temperature={temperature}, style={style}" },
|
||||||
});
|
});
|
||||||
messages.Add(new PromptMessage()
|
messages.Add(new PromptMessage
|
||||||
{
|
{
|
||||||
Role = Role.Assistant,
|
Role = Role.Assistant,
|
||||||
Content = new TextContentBlock { Text = "I understand. You've provided a complex prompt with temperature and style arguments. How would you like me to proceed?" },
|
Content = new TextContentBlock { Text = "I understand. You've provided a complex prompt with temperature and style arguments. How would you like me to proceed?" },
|
||||||
});
|
});
|
||||||
messages.Add(new PromptMessage()
|
messages.Add(new PromptMessage
|
||||||
{
|
{
|
||||||
Role = Role.User,
|
Role = Role.User,
|
||||||
Content = new ImageContentBlock()
|
Content = new ImageContentBlock
|
||||||
{
|
{
|
||||||
Data = MCP_TINY_IMAGE,
|
Data = MCP_TINY_IMAGE,
|
||||||
MimeType = "image/png"
|
MimeType = "image/png"
|
||||||
|
|
@ -289,7 +289,7 @@ internal static class Program
|
||||||
throw new McpException($"Unknown prompt: {request.Params?.Name}", McpErrorCode.InvalidParams);
|
throw new McpException($"Unknown prompt: {request.Params?.Name}", McpErrorCode.InvalidParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new GetPromptResult()
|
return new GetPromptResult
|
||||||
{
|
{
|
||||||
Messages = messages
|
Messages = messages
|
||||||
};
|
};
|
||||||
|
|
@ -328,13 +328,13 @@ internal static class Program
|
||||||
string uri = $"test://static/resource/{i + 1}";
|
string uri = $"test://static/resource/{i + 1}";
|
||||||
if (i % 2 == 0)
|
if (i % 2 == 0)
|
||||||
{
|
{
|
||||||
resources.Add(new Resource()
|
resources.Add(new Resource
|
||||||
{
|
{
|
||||||
Uri = uri,
|
Uri = uri,
|
||||||
Name = $"Resource {i + 1}",
|
Name = $"Resource {i + 1}",
|
||||||
MimeType = "text/plain"
|
MimeType = "text/plain"
|
||||||
});
|
});
|
||||||
resourceContents.Add(new TextResourceContents()
|
resourceContents.Add(new TextResourceContents
|
||||||
{
|
{
|
||||||
Uri = uri,
|
Uri = uri,
|
||||||
MimeType = "text/plain",
|
MimeType = "text/plain",
|
||||||
|
|
@ -344,13 +344,13 @@ internal static class Program
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var buffer = Encoding.UTF8.GetBytes($"Resource {i + 1}: This is a base64 blob");
|
var buffer = Encoding.UTF8.GetBytes($"Resource {i + 1}: This is a base64 blob");
|
||||||
resources.Add(new Resource()
|
resources.Add(new Resource
|
||||||
{
|
{
|
||||||
Uri = uri,
|
Uri = uri,
|
||||||
Name = $"Resource {i + 1}",
|
Name = $"Resource {i + 1}",
|
||||||
MimeType = "application/octet-stream"
|
MimeType = "application/octet-stream"
|
||||||
});
|
});
|
||||||
resourceContents.Add(new BlobResourceContents()
|
resourceContents.Add(new BlobResourceContents
|
||||||
{
|
{
|
||||||
Uri = uri,
|
Uri = uri,
|
||||||
MimeType = "application/octet-stream",
|
MimeType = "application/octet-stream",
|
||||||
|
|
@ -365,10 +365,10 @@ internal static class Program
|
||||||
{
|
{
|
||||||
ListResourceTemplatesHandler = async (request, cancellationToken) =>
|
ListResourceTemplatesHandler = async (request, cancellationToken) =>
|
||||||
{
|
{
|
||||||
return new ListResourceTemplatesResult()
|
return new ListResourceTemplatesResult
|
||||||
{
|
{
|
||||||
ResourceTemplates = [
|
ResourceTemplates = [
|
||||||
new ResourceTemplate()
|
new ResourceTemplate
|
||||||
{
|
{
|
||||||
UriTemplate = "test://dynamic/resource/{id}",
|
UriTemplate = "test://dynamic/resource/{id}",
|
||||||
Name = "Dynamic Resource",
|
Name = "Dynamic Resource",
|
||||||
|
|
@ -400,7 +400,7 @@ internal static class Program
|
||||||
{
|
{
|
||||||
nextCursor = Convert.ToBase64String(Encoding.UTF8.GetBytes(endIndex.ToString()));
|
nextCursor = Convert.ToBase64String(Encoding.UTF8.GetBytes(endIndex.ToString()));
|
||||||
}
|
}
|
||||||
return new ListResourcesResult()
|
return new ListResourcesResult
|
||||||
{
|
{
|
||||||
NextCursor = nextCursor,
|
NextCursor = nextCursor,
|
||||||
Resources = resources.GetRange(startIndex, endIndex - startIndex)
|
Resources = resources.GetRange(startIndex, endIndex - startIndex)
|
||||||
|
|
@ -422,10 +422,10 @@ internal static class Program
|
||||||
throw new McpException($"Invalid resource URI: '{request.Params.Uri}'", McpErrorCode.InvalidParams);
|
throw new McpException($"Invalid resource URI: '{request.Params.Uri}'", McpErrorCode.InvalidParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ReadResourceResult()
|
return new ReadResourceResult
|
||||||
{
|
{
|
||||||
Contents = [
|
Contents = [
|
||||||
new TextResourceContents()
|
new TextResourceContents
|
||||||
{
|
{
|
||||||
Uri = request.Params.Uri,
|
Uri = request.Params.Uri,
|
||||||
MimeType = "text/plain",
|
MimeType = "text/plain",
|
||||||
|
|
@ -438,7 +438,7 @@ internal static class Program
|
||||||
ResourceContents contents = resourceContents.FirstOrDefault(r => r.Uri == request.Params.Uri)
|
ResourceContents contents = resourceContents.FirstOrDefault(r => r.Uri == request.Params.Uri)
|
||||||
?? throw new McpException($"Resource not found: '{request.Params.Uri}'", McpErrorCode.InvalidParams);
|
?? throw new McpException($"Resource not found: '{request.Params.Uri}'", McpErrorCode.InvalidParams);
|
||||||
|
|
||||||
return new ReadResourceResult()
|
return new ReadResourceResult
|
||||||
{
|
{
|
||||||
Contents = [contents]
|
Contents = [contents]
|
||||||
};
|
};
|
||||||
|
|
@ -523,9 +523,9 @@ internal static class Program
|
||||||
|
|
||||||
static CreateMessageRequestParams CreateRequestSamplingParams(string context, string uri, int maxTokens = 100)
|
static CreateMessageRequestParams CreateRequestSamplingParams(string context, string uri, int maxTokens = 100)
|
||||||
{
|
{
|
||||||
return new CreateMessageRequestParams()
|
return new CreateMessageRequestParams
|
||||||
{
|
{
|
||||||
Messages = [new SamplingMessage()
|
Messages = [new SamplingMessage
|
||||||
{
|
{
|
||||||
Role = Role.User,
|
Role = Role.User,
|
||||||
Content = new TextContentBlock { Text = $"Resource {uri} context: {context}" },
|
Content = new TextContentBlock { Text = $"Resource {uri} context: {context}" },
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ public class Program
|
||||||
|
|
||||||
private static void ConfigureOptions(McpServerOptions options)
|
private static void ConfigureOptions(McpServerOptions options)
|
||||||
{
|
{
|
||||||
options.Capabilities = new ServerCapabilities()
|
options.Capabilities = new ServerCapabilities
|
||||||
{
|
{
|
||||||
Tools = new(),
|
Tools = new(),
|
||||||
Resources = new(),
|
Resources = new(),
|
||||||
|
|
@ -41,9 +41,9 @@ public class Program
|
||||||
#region Helped method
|
#region Helped method
|
||||||
static CreateMessageRequestParams CreateRequestSamplingParams(string context, string uri, int maxTokens = 100)
|
static CreateMessageRequestParams CreateRequestSamplingParams(string context, string uri, int maxTokens = 100)
|
||||||
{
|
{
|
||||||
return new CreateMessageRequestParams()
|
return new CreateMessageRequestParams
|
||||||
{
|
{
|
||||||
Messages = [new SamplingMessage()
|
Messages = [new SamplingMessage
|
||||||
{
|
{
|
||||||
Role = Role.User,
|
Role = Role.User,
|
||||||
Content = new TextContentBlock { Text = $"Resource {uri} context: {context}" },
|
Content = new TextContentBlock { Text = $"Resource {uri} context: {context}" },
|
||||||
|
|
@ -63,13 +63,13 @@ public class Program
|
||||||
string uri = $"test://static/resource/{i + 1}";
|
string uri = $"test://static/resource/{i + 1}";
|
||||||
if (i % 2 == 0)
|
if (i % 2 == 0)
|
||||||
{
|
{
|
||||||
resources.Add(new Resource()
|
resources.Add(new Resource
|
||||||
{
|
{
|
||||||
Uri = uri,
|
Uri = uri,
|
||||||
Name = $"Resource {i + 1}",
|
Name = $"Resource {i + 1}",
|
||||||
MimeType = "text/plain"
|
MimeType = "text/plain"
|
||||||
});
|
});
|
||||||
resourceContents.Add(new TextResourceContents()
|
resourceContents.Add(new TextResourceContents
|
||||||
{
|
{
|
||||||
Uri = uri,
|
Uri = uri,
|
||||||
MimeType = "text/plain",
|
MimeType = "text/plain",
|
||||||
|
|
@ -79,13 +79,13 @@ public class Program
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var buffer = Encoding.UTF8.GetBytes($"Resource {i + 1}: This is a base64 blob");
|
var buffer = Encoding.UTF8.GetBytes($"Resource {i + 1}: This is a base64 blob");
|
||||||
resources.Add(new Resource()
|
resources.Add(new Resource
|
||||||
{
|
{
|
||||||
Uri = uri,
|
Uri = uri,
|
||||||
Name = $"Resource {i + 1}",
|
Name = $"Resource {i + 1}",
|
||||||
MimeType = "application/octet-stream"
|
MimeType = "application/octet-stream"
|
||||||
});
|
});
|
||||||
resourceContents.Add(new BlobResourceContents()
|
resourceContents.Add(new BlobResourceContents
|
||||||
{
|
{
|
||||||
Uri = uri,
|
Uri = uri,
|
||||||
MimeType = "application/octet-stream",
|
MimeType = "application/octet-stream",
|
||||||
|
|
@ -102,11 +102,11 @@ public class Program
|
||||||
{
|
{
|
||||||
ListToolsHandler = async (request, cancellationToken) =>
|
ListToolsHandler = async (request, cancellationToken) =>
|
||||||
{
|
{
|
||||||
return new ListToolsResult()
|
return new ListToolsResult
|
||||||
{
|
{
|
||||||
Tools =
|
Tools =
|
||||||
[
|
[
|
||||||
new Tool()
|
new Tool
|
||||||
{
|
{
|
||||||
Name = "echo",
|
Name = "echo",
|
||||||
Description = "Echoes the input back to the client.",
|
Description = "Echoes the input back to the client.",
|
||||||
|
|
@ -123,7 +123,7 @@ public class Program
|
||||||
}
|
}
|
||||||
""", McpJsonUtilities.DefaultOptions),
|
""", McpJsonUtilities.DefaultOptions),
|
||||||
},
|
},
|
||||||
new Tool()
|
new Tool
|
||||||
{
|
{
|
||||||
Name = "echoSessionId",
|
Name = "echoSessionId",
|
||||||
Description = "Echoes the session id back to the client.",
|
Description = "Echoes the session id back to the client.",
|
||||||
|
|
@ -133,7 +133,7 @@ public class Program
|
||||||
}
|
}
|
||||||
""", McpJsonUtilities.DefaultOptions),
|
""", McpJsonUtilities.DefaultOptions),
|
||||||
},
|
},
|
||||||
new Tool()
|
new Tool
|
||||||
{
|
{
|
||||||
Name = "sampleLLM",
|
Name = "sampleLLM",
|
||||||
Description = "Samples from an LLM using MCP's sampling feature.",
|
Description = "Samples from an LLM using MCP's sampling feature.",
|
||||||
|
|
@ -169,14 +169,14 @@ public class Program
|
||||||
{
|
{
|
||||||
throw new McpException("Missing required argument 'message'", McpErrorCode.InvalidParams);
|
throw new McpException("Missing required argument 'message'", McpErrorCode.InvalidParams);
|
||||||
}
|
}
|
||||||
return new CallToolResult()
|
return new CallToolResult
|
||||||
{
|
{
|
||||||
Content = [new TextContentBlock { Text = $"Echo: {message}" }]
|
Content = [new TextContentBlock { Text = $"Echo: {message}" }]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if (request.Params.Name == "echoSessionId")
|
else if (request.Params.Name == "echoSessionId")
|
||||||
{
|
{
|
||||||
return new CallToolResult()
|
return new CallToolResult
|
||||||
{
|
{
|
||||||
Content = [new TextContentBlock { Text = request.Server.SessionId ?? string.Empty }]
|
Content = [new TextContentBlock { Text = request.Server.SessionId ?? string.Empty }]
|
||||||
};
|
};
|
||||||
|
|
@ -192,7 +192,7 @@ public class Program
|
||||||
var sampleResult = await request.Server.SampleAsync(CreateRequestSamplingParams(prompt.ToString(), "sampleLLM", Convert.ToInt32(maxTokens.ToString())),
|
var sampleResult = await request.Server.SampleAsync(CreateRequestSamplingParams(prompt.ToString(), "sampleLLM", Convert.ToInt32(maxTokens.ToString())),
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
|
|
||||||
return new CallToolResult()
|
return new CallToolResult
|
||||||
{
|
{
|
||||||
Content = [new TextContentBlock { Text = $"LLM sampling result: {(sampleResult.Content as TextContentBlock)?.Text}" }]
|
Content = [new TextContentBlock { Text = $"LLM sampling result: {(sampleResult.Content as TextContentBlock)?.Text}" }]
|
||||||
};
|
};
|
||||||
|
|
@ -208,10 +208,10 @@ public class Program
|
||||||
ListResourceTemplatesHandler = async (request, cancellationToken) =>
|
ListResourceTemplatesHandler = async (request, cancellationToken) =>
|
||||||
{
|
{
|
||||||
|
|
||||||
return new ListResourceTemplatesResult()
|
return new ListResourceTemplatesResult
|
||||||
{
|
{
|
||||||
ResourceTemplates = [
|
ResourceTemplates = [
|
||||||
new ResourceTemplate()
|
new ResourceTemplate
|
||||||
{
|
{
|
||||||
UriTemplate = "test://dynamic/resource/{id}",
|
UriTemplate = "test://dynamic/resource/{id}",
|
||||||
Name = "Dynamic Resource",
|
Name = "Dynamic Resource",
|
||||||
|
|
@ -245,7 +245,7 @@ public class Program
|
||||||
nextCursor = Convert.ToBase64String(Encoding.UTF8.GetBytes(endIndex.ToString()));
|
nextCursor = Convert.ToBase64String(Encoding.UTF8.GetBytes(endIndex.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ListResourcesResult()
|
return new ListResourcesResult
|
||||||
{
|
{
|
||||||
NextCursor = nextCursor,
|
NextCursor = nextCursor,
|
||||||
Resources = resources.GetRange(startIndex, endIndex - startIndex)
|
Resources = resources.GetRange(startIndex, endIndex - startIndex)
|
||||||
|
|
@ -266,10 +266,10 @@ public class Program
|
||||||
throw new McpException($"Invalid resource URI: '{request.Params.Uri}'", McpErrorCode.InvalidParams);
|
throw new McpException($"Invalid resource URI: '{request.Params.Uri}'", McpErrorCode.InvalidParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ReadResourceResult()
|
return new ReadResourceResult
|
||||||
{
|
{
|
||||||
Contents = [
|
Contents = [
|
||||||
new TextResourceContents()
|
new TextResourceContents
|
||||||
{
|
{
|
||||||
Uri = request.Params.Uri,
|
Uri = request.Params.Uri,
|
||||||
MimeType = "text/plain",
|
MimeType = "text/plain",
|
||||||
|
|
@ -282,7 +282,7 @@ public class Program
|
||||||
ResourceContents? contents = resourceContents.FirstOrDefault(r => r.Uri == request.Params.Uri) ??
|
ResourceContents? contents = resourceContents.FirstOrDefault(r => r.Uri == request.Params.Uri) ??
|
||||||
throw new McpException($"Resource not found: '{request.Params.Uri}'", McpErrorCode.InvalidParams);
|
throw new McpException($"Resource not found: '{request.Params.Uri}'", McpErrorCode.InvalidParams);
|
||||||
|
|
||||||
return new ReadResourceResult()
|
return new ReadResourceResult
|
||||||
{
|
{
|
||||||
Contents = [contents]
|
Contents = [contents]
|
||||||
};
|
};
|
||||||
|
|
@ -292,27 +292,27 @@ public class Program
|
||||||
{
|
{
|
||||||
ListPromptsHandler = async (request, cancellationToken) =>
|
ListPromptsHandler = async (request, cancellationToken) =>
|
||||||
{
|
{
|
||||||
return new ListPromptsResult()
|
return new ListPromptsResult
|
||||||
{
|
{
|
||||||
Prompts = [
|
Prompts = [
|
||||||
new Prompt()
|
new Prompt
|
||||||
{
|
{
|
||||||
Name = "simple_prompt",
|
Name = "simple_prompt",
|
||||||
Description = "A prompt without arguments"
|
Description = "A prompt without arguments"
|
||||||
},
|
},
|
||||||
new Prompt()
|
new Prompt
|
||||||
{
|
{
|
||||||
Name = "complex_prompt",
|
Name = "complex_prompt",
|
||||||
Description = "A prompt with arguments",
|
Description = "A prompt with arguments",
|
||||||
Arguments =
|
Arguments =
|
||||||
[
|
[
|
||||||
new PromptArgument()
|
new PromptArgument
|
||||||
{
|
{
|
||||||
Name = "temperature",
|
Name = "temperature",
|
||||||
Description = "Temperature setting",
|
Description = "Temperature setting",
|
||||||
Required = true
|
Required = true
|
||||||
},
|
},
|
||||||
new PromptArgument()
|
new PromptArgument
|
||||||
{
|
{
|
||||||
Name = "style",
|
Name = "style",
|
||||||
Description = "Output style",
|
Description = "Output style",
|
||||||
|
|
@ -332,7 +332,7 @@ public class Program
|
||||||
List<PromptMessage> messages = new();
|
List<PromptMessage> messages = new();
|
||||||
if (request.Params.Name == "simple_prompt")
|
if (request.Params.Name == "simple_prompt")
|
||||||
{
|
{
|
||||||
messages.Add(new PromptMessage()
|
messages.Add(new PromptMessage
|
||||||
{
|
{
|
||||||
Role = Role.User,
|
Role = Role.User,
|
||||||
Content = new TextContentBlock { Text = "This is a simple prompt without arguments." },
|
Content = new TextContentBlock { Text = "This is a simple prompt without arguments." },
|
||||||
|
|
@ -342,20 +342,20 @@ public class Program
|
||||||
{
|
{
|
||||||
string temperature = request.Params.Arguments?["temperature"].ToString() ?? "unknown";
|
string temperature = request.Params.Arguments?["temperature"].ToString() ?? "unknown";
|
||||||
string style = request.Params.Arguments?["style"].ToString() ?? "unknown";
|
string style = request.Params.Arguments?["style"].ToString() ?? "unknown";
|
||||||
messages.Add(new PromptMessage()
|
messages.Add(new PromptMessage
|
||||||
{
|
{
|
||||||
Role = Role.User,
|
Role = Role.User,
|
||||||
Content = new TextContentBlock { Text = $"This is a complex prompt with arguments: temperature={temperature}, style={style}" },
|
Content = new TextContentBlock { Text = $"This is a complex prompt with arguments: temperature={temperature}, style={style}" },
|
||||||
});
|
});
|
||||||
messages.Add(new PromptMessage()
|
messages.Add(new PromptMessage
|
||||||
{
|
{
|
||||||
Role = Role.Assistant,
|
Role = Role.Assistant,
|
||||||
Content = new TextContentBlock { Text = "I understand. You've provided a complex prompt with temperature and style arguments. How would you like me to proceed?" },
|
Content = new TextContentBlock { Text = "I understand. You've provided a complex prompt with temperature and style arguments. How would you like me to proceed?" },
|
||||||
});
|
});
|
||||||
messages.Add(new PromptMessage()
|
messages.Add(new PromptMessage
|
||||||
{
|
{
|
||||||
Role = Role.User,
|
Role = Role.User,
|
||||||
Content = new ImageContentBlock()
|
Content = new ImageContentBlock
|
||||||
{
|
{
|
||||||
Data = MCP_TINY_IMAGE,
|
Data = MCP_TINY_IMAGE,
|
||||||
MimeType = "image/png"
|
MimeType = "image/png"
|
||||||
|
|
@ -367,7 +367,7 @@ public class Program
|
||||||
throw new McpException($"Unknown prompt: {request.Params.Name}", McpErrorCode.InvalidParams);
|
throw new McpException($"Unknown prompt: {request.Params.Name}", McpErrorCode.InvalidParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new GetPromptResult()
|
return new GetPromptResult
|
||||||
{
|
{
|
||||||
Messages = messages
|
Messages = messages
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ public partial class McpClientResourceTemplateTests : ClientServerTestBase
|
||||||
protected override void ConfigureServices(ServiceCollection services, IMcpServerBuilder mcpServerBuilder)
|
protected override void ConfigureServices(ServiceCollection services, IMcpServerBuilder mcpServerBuilder)
|
||||||
{
|
{
|
||||||
mcpServerBuilder.WithReadResourceHandler((request, cancellationToken) =>
|
mcpServerBuilder.WithReadResourceHandler((request, cancellationToken) =>
|
||||||
new ValueTask<ReadResourceResult>(new ReadResourceResult()
|
new ValueTask<ReadResourceResult>(new ReadResourceResult
|
||||||
{
|
{
|
||||||
Contents = [new TextResourceContents { Text = request.Params?.Uri ?? string.Empty }]
|
Contents = [new TextResourceContents { Text = request.Params?.Uri ?? string.Empty }]
|
||||||
}));
|
}));
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ public partial class McpServerBuilderExtensionsPromptsTests : ClientServerTestBa
|
||||||
case "FirstCustomPrompt":
|
case "FirstCustomPrompt":
|
||||||
case "SecondCustomPrompt":
|
case "SecondCustomPrompt":
|
||||||
case "FinalCustomPrompt":
|
case "FinalCustomPrompt":
|
||||||
return new GetPromptResult()
|
return new GetPromptResult
|
||||||
{
|
{
|
||||||
Messages = [new() { Role = Role.User, Content = new TextContentBlock { Text = $"hello from {request.Params.Name}" } }],
|
Messages = [new() { Role = Role.User, Content = new TextContentBlock { Text = $"hello from {request.Params.Name}" } }],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ public partial class McpServerBuilderExtensionsResourcesTests : ClientServerTest
|
||||||
case "test://Resource3":
|
case "test://Resource3":
|
||||||
case "test://ResourceTemplate1":
|
case "test://ResourceTemplate1":
|
||||||
case "test://ResourceTemplate2":
|
case "test://ResourceTemplate2":
|
||||||
return new ReadResourceResult()
|
return new ReadResourceResult
|
||||||
{
|
{
|
||||||
Contents = [new TextResourceContents { Text = request.Params?.Uri ?? "(null)" }]
|
Contents = [new TextResourceContents { Text = request.Params?.Uri ?? "(null)" }]
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ public partial class McpServerBuilderExtensionsToolsTests : ClientServerTestBase
|
||||||
case "FirstCustomTool":
|
case "FirstCustomTool":
|
||||||
case "SecondCustomTool":
|
case "SecondCustomTool":
|
||||||
case "FinalCustomTool":
|
case "FinalCustomTool":
|
||||||
return new CallToolResult()
|
return new CallToolResult
|
||||||
{
|
{
|
||||||
Content = [new TextContentBlock { Text = $"{request.Params.Name}Result" }],
|
Content = [new TextContentBlock { Text = $"{request.Params.Name}Result" }],
|
||||||
};
|
};
|
||||||
|
|
@ -671,7 +671,7 @@ public partial class McpServerBuilderExtensionsToolsTests : ClientServerTestBase
|
||||||
|
|
||||||
await client.SendNotificationAsync(
|
await client.SendNotificationAsync(
|
||||||
NotificationMethods.CancelledNotification,
|
NotificationMethods.CancelledNotification,
|
||||||
parameters: new CancelledNotificationParams()
|
parameters: new CancelledNotificationParams
|
||||||
{
|
{
|
||||||
RequestId = requestId,
|
RequestId = requestId,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue