feat(worker): add external MCP app-settings read tool
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
31
src/ClaudeDo.Worker/External/AppSettingsMcpTools.cs
vendored
Normal file
31
src/ClaudeDo.Worker/External/AppSettingsMcpTools.cs
vendored
Normal file
@@ -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<ClaudeDoDbContext> _dbFactory;
|
||||||
|
|
||||||
|
public AppSettingsMcpTools(IDbContextFactory<ClaudeDoDbContext> dbFactory) => _dbFactory = dbFactory;
|
||||||
|
|
||||||
|
[McpServerTool, Description("Read the worker's app-level defaults (model, max turns, permission mode, worktree strategy). Read-only.")]
|
||||||
|
public async Task<AppSettingsReadDto> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user