Implement MCP task support (SEP-1686) (#1170)
Co-authored-by: Stephen Halter <halter73@gmail.com>
This commit is contained in:
parent
81664c3fce
commit
10e4f5b20f
2 changed files with 11580 additions and 46 deletions
|
|
@ -26,6 +26,17 @@ public static class McpServerServiceCollectionExtensions
|
|||
services.Configure(configureOptions);
|
||||
}
|
||||
|
||||
// Register IMcpTaskStore from options if not already registered.
|
||||
// This allows users to either:
|
||||
// 1. Register IMcpTaskStore directly in DI (takes precedence)
|
||||
// 2. Set options.TaskStore in the configuration callback (used as fallback)
|
||||
// If neither is done, resolving IMcpTaskStore will throw.
|
||||
services.TryAddSingleton<IMcpTaskStore>(sp =>
|
||||
{
|
||||
var options = sp.GetRequiredService<IOptions<McpServerOptions>>().Value;
|
||||
return options.TaskStore ?? throw new InvalidOperationException("No IMcpTaskStore has been configured. Either register an IMcpTaskStore in the service collection or set McpServerOptions.TaskStore when configuring the MCP server.");
|
||||
});
|
||||
|
||||
return new DefaultMcpServerBuilder(services);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
<PackageId>ModelContextProtocol</PackageId>
|
||||
<Description>.NET SDK for the Model Context Protocol (MCP) with hosting and dependency injection extensions.</Description>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<!-- Suppress the experimental tasks warning -->
|
||||
<NoWarn>$(NoWarn);MCPEXP001</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)' != 'netstandard2.0'">
|
||||
|
|
|
|||
Loading…
Reference in a new issue