Fixed crash loop

This commit is contained in:
2026-10-30 12:50:47 +02:00
parent 4fa379f74e
commit ff69aee6d3
2 changed files with 58 additions and 1 deletions
@@ -35,6 +35,63 @@ public class McpToolingTests
_serviceProvider = services.BuildServiceProvider();
}
[Fact]
public void McpServer_WithApplicationMcpTools_SchemaGeneration_Succeeds()
{
var services = new ServiceCollection();
services.AddLogging();
services.AddSingleton<IGrantsService, TestGrantsService>();
services.AddSingleton<IProjectService, TestProjectService>();
services.AddSingleton<IExecutionService, TestExecutionService>();
services.AddSingleton<IGovernanceService, TestGovernanceService>();
services.AddSingleton<IEvidenceService, TestEvidenceService>();
services.AddSingleton<ICommunicationsService, TestCommunicationsService>();
services.AddSingleton<IUserService, TestUserService>();
services.AddApplicationMcpTools();
var mcpBuilder = services.AddMcpServer();
mcpBuilder.WithApplicationMcpTools();
var sp = services.BuildServiceProvider();
var tools = sp.GetServices<ModelContextProtocol.Server.McpServerTool>().ToList();
Assert.NotEmpty(tools);
Assert.True(tools.Count >= 40, $"Expected at least 40 MCP server tools, but found {tools.Count}");
}
[Theory]
[InlineData(typeof(GrantsMcpTools))]
[InlineData(typeof(ProjectsMcpTools))]
[InlineData(typeof(ExecutionMcpTools))]
[InlineData(typeof(GovernanceMcpTools))]
[InlineData(typeof(EvidenceMcpTools))]
[InlineData(typeof(CommunicationsMcpTools))]
[InlineData(typeof(UsersMcpTools))]
public void McpServer_ToolsSchemaGeneration_Succeeds(Type toolType)
{
var services = new ServiceCollection();
services.AddLogging();
services.AddSingleton<IGrantsService, TestGrantsService>();
services.AddSingleton<IProjectService, TestProjectService>();
services.AddSingleton<IExecutionService, TestExecutionService>();
services.AddSingleton<IGovernanceService, TestGovernanceService>();
services.AddSingleton<IEvidenceService, TestEvidenceService>();
services.AddSingleton<ICommunicationsService, TestCommunicationsService>();
services.AddSingleton<IUserService, TestUserService>();
services.AddApplicationMcpTools();
var mcpBuilder = services.AddMcpServer();
// Register just the one tool type using reflection
var withToolsMethod = typeof(Microsoft.Extensions.DependencyInjection.McpServerBuilderExtensions)
.GetMethods()
.First(m => m.Name == "WithTools" && m.IsGenericMethodDefinition && m.GetParameters().Length == 2)
.MakeGenericMethod(toolType);
withToolsMethod.Invoke(null, new object?[] { mcpBuilder, null });
var sp = services.BuildServiceProvider();
var tools = sp.GetServices<ModelContextProtocol.Server.McpServerTool>().ToList();
Assert.NotEmpty(tools);
}
[Fact]
public void AddApplicationMcpTools_RegistersAllToolTypesAndInAppClient()
{