From 1a74e1c0583869bad204f6a44895ae1152ef3c90 Mon Sep 17 00:00:00 2001 From: mika kuns Date: Sat, 25 Apr 2026 11:25:42 +0200 Subject: [PATCH] feat(mcp/external): AddTask accepts tags on creation Co-Authored-By: Claude Sonnet 4.6 --- .../External/ExternalMcpService.cs | 6 +++- .../External/ExternalMcpServiceTests.cs | 32 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/ClaudeDo.Worker/External/ExternalMcpService.cs b/src/ClaudeDo.Worker/External/ExternalMcpService.cs index b1a188d..4f79363 100644 --- a/src/ClaudeDo.Worker/External/ExternalMcpService.cs +++ b/src/ClaudeDo.Worker/External/ExternalMcpService.cs @@ -87,13 +87,14 @@ public sealed class ExternalMcpService return ToDto(task); } - [McpServerTool, Description("Create a new task in the given list. Set queueImmediately=true to enqueue it for agent execution.")] + [McpServerTool, Description("Create a new task in the given list. Set queueImmediately=true to enqueue it for agent execution. Optional tags are attached on creation; missing tag names auto-create.")] public async Task AddTask( string listId, string title, string? description, string createdBy, bool queueImmediately, + IReadOnlyList? tags, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(listId)) @@ -119,6 +120,9 @@ public sealed class ExternalMcpService }; await _tasks.AddAsync(entity, cancellationToken); + if (tags is not null && tags.Count > 0) + await _tasks.SetTagsAsync(entity.Id, tags, cancellationToken); + if (queueImmediately) _queue.WakeQueue(); diff --git a/tests/ClaudeDo.Worker.Tests/External/ExternalMcpServiceTests.cs b/tests/ClaudeDo.Worker.Tests/External/ExternalMcpServiceTests.cs index 5617859..9a5ed11 100644 --- a/tests/ClaudeDo.Worker.Tests/External/ExternalMcpServiceTests.cs +++ b/tests/ClaudeDo.Worker.Tests/External/ExternalMcpServiceTests.cs @@ -140,4 +140,36 @@ public sealed class ExternalMcpServiceTests : IDisposable Assert.Contains(tags, t => t.Name == "agent"); Assert.Contains(tags, t => t.Name == "custom-tag"); } + + [Fact] + public async Task AddTask_WithTags_AttachesTags() + { + var listId = await SeedListAsync(); + var queue = CreateQueue(); + var sut = BuildSut(queue); + + var dto = await sut.AddTask( + listId, "scope-creep handoff", "desc", "claude-cli", + queueImmediately: false, + tags: new[] { "agent", "custom" }, + CancellationToken.None); + + var tags = await _tasks.GetTagsAsync(dto.Id); + Assert.Contains(tags, t => t.Name == "agent"); + Assert.Contains(tags, t => t.Name == "custom"); + } + + [Fact] + public async Task AddTask_NullTags_BehavesAsBefore() + { + var listId = await SeedListAsync(); + var queue = CreateQueue(); + var sut = BuildSut(queue); + + var dto = await sut.AddTask( + listId, "no tags", null, "claude-cli", + queueImmediately: false, tags: null, CancellationToken.None); + + Assert.Empty(await _tasks.GetTagsAsync(dto.Id)); + } }