Fix: Synthesize handlers for empty tool/prompt/resource collections (#865)
* Initial plan * Allow handlers for empty tool/prompt/resource collections Changed condition from `IsEmpty: false` to `not null` check in McpServerImpl.cs for resources (line 298), prompts (line 459), and tools (line 547). This allows handlers to be synthesized even when collections are empty, enabling dynamic addition of items after initialization. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Stephen Toub <stoub@microsoft.com>
This commit is contained in:
parent
bfc0980ef5
commit
8f2e21d734
1 changed files with 177 additions and 13 deletions
|
|
@ -292,7 +292,7 @@ internal sealed partial class McpServerImpl : McpServer
|
|||
var subscribe = resourcesCapability?.Subscribe;
|
||||
|
||||
// Handle resources provided via DI.
|
||||
if (resources is { IsEmpty: false })
|
||||
if (resources is not null)
|
||||
{
|
||||
var originalListResourcesHandler = listResourcesHandler;
|
||||
listResourcesHandler = async (request, cancellationToken) =>
|
||||
|
|
@ -453,7 +453,7 @@ internal sealed partial class McpServerImpl : McpServer
|
|||
var listChanged = promptsCapability?.ListChanged;
|
||||
|
||||
// Handle tools provided via DI by augmenting the handlers to incorporate them.
|
||||
if (prompts is { IsEmpty: false })
|
||||
if (prompts is not null)
|
||||
{
|
||||
var originalListPromptsHandler = listPromptsHandler;
|
||||
listPromptsHandler = async (request, cancellationToken) =>
|
||||
|
|
@ -541,7 +541,7 @@ internal sealed partial class McpServerImpl : McpServer
|
|||
var listChanged = toolsCapability?.ListChanged;
|
||||
|
||||
// Handle tools provided via DI by augmenting the handlers to incorporate them.
|
||||
if (tools is { IsEmpty: false })
|
||||
if (tools is not null)
|
||||
{
|
||||
var originalListToolsHandler = listToolsHandler;
|
||||
listToolsHandler = async (request, cancellationToken) =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue