-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathProgram.cs
More file actions
55 lines (46 loc) · 2 KB
/
Program.cs
File metadata and controls
55 lines (46 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using ILSpy.Mcp.Application.Configuration;
using ILSpy.Mcp.Application.Services;
using ILSpy.Mcp.Application.UseCases;
using ILSpy.Mcp.Domain.Services;
using ILSpy.Mcp.Infrastructure.Decompiler;
using ILSpy.Mcp.Transport.Mcp.Tools;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using ModelContextProtocol.Server;
var builder = Host.CreateApplicationBuilder(args);
// Configure logging to stderr
builder.Logging.AddConsole(consoleLogOptions =>
{
consoleLogOptions.LogToStandardErrorThreshold = LogLevel.Trace;
});
// Configure options
builder.Services.Configure<ILSpyOptions>(
builder.Configuration.GetSection(ILSpyOptions.SectionName));
// Configure MCP server
var mcpBuilder = builder.Services.AddMcpServer();
mcpBuilder.WithStdioServerTransport();
mcpBuilder.WithToolsFromAssembly();
// Register application services
builder.Services.AddSingleton<ITimeoutService, TimeoutService>();
// Register domain services (ports)
builder.Services.AddScoped<IDecompilerService, ILSpyDecompilerService>();
// Register application use cases
builder.Services.AddScoped<DecompileTypeUseCase>();
builder.Services.AddScoped<DecompileMethodUseCase>();
builder.Services.AddScoped<ListAssemblyTypesUseCase>();
builder.Services.AddScoped<AnalyzeAssemblyUseCase>();
builder.Services.AddScoped<GetTypeMembersUseCase>();
builder.Services.AddScoped<FindTypeHierarchyUseCase>();
builder.Services.AddScoped<SearchMembersByNameUseCase>();
builder.Services.AddScoped<FindExtensionMethodsUseCase>();
// Register MCP tool handlers
builder.Services.AddScoped<DecompileTypeTool>();
builder.Services.AddScoped<DecompileMethodTool>();
builder.Services.AddScoped<ListAssemblyTypesTool>();
builder.Services.AddScoped<AnalyzeAssemblyTool>();
builder.Services.AddScoped<GetTypeMembersTool>();
builder.Services.AddScoped<FindTypeHierarchyTool>();
builder.Services.AddScoped<SearchMembersByNameTool>();
builder.Services.AddScoped<FindExtensionMethodsTool>();
await builder.Build().RunAsync();