diff --git a/src/ClaudeDo.Worker/External/AppSettingsMcpTools.cs b/src/ClaudeDo.Worker/External/AppSettingsMcpTools.cs new file mode 100644 index 0000000..8e065f5 --- /dev/null +++ b/src/ClaudeDo.Worker/External/AppSettingsMcpTools.cs @@ -0,0 +1,31 @@ +using System.ComponentModel; +using ClaudeDo.Data; +using ClaudeDo.Data.Repositories; +using Microsoft.EntityFrameworkCore; +using ModelContextProtocol.Server; + +namespace ClaudeDo.Worker.External; + +public sealed record AppSettingsReadDto( + string DefaultModel, int DefaultMaxTurns, string DefaultPermissionMode, + string WorktreeStrategy, string? CentralWorktreeRoot, + bool WorktreeAutoCleanupEnabled, int WorktreeAutoCleanupDays); + +[McpServerToolType] +public sealed class AppSettingsMcpTools +{ + private readonly IDbContextFactory _dbFactory; + + public AppSettingsMcpTools(IDbContextFactory dbFactory) => _dbFactory = dbFactory; + + [McpServerTool, Description("Read the worker's app-level defaults (model, max turns, permission mode, worktree strategy). Read-only.")] + public async Task GetAppSettings(CancellationToken cancellationToken) + { + using var ctx = await _dbFactory.CreateDbContextAsync(cancellationToken); + var row = await new AppSettingsRepository(ctx).GetAsync(cancellationToken); + return new AppSettingsReadDto( + row.DefaultModel, row.DefaultMaxTurns, row.DefaultPermissionMode, + row.WorktreeStrategy, row.CentralWorktreeRoot, + row.WorktreeAutoCleanupEnabled, row.WorktreeAutoCleanupDays); + } +}