Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.
PHP ai-agentsblueskyfacebookinstagramlaravellinkedinmastodonmcpmcp-serveropen-sourcerest-apiself-hostedsocial-mediasocial-media-managementsocial-media-schedulerthreadstiktokvuejsxyoutube
fix(mcp): publish-post-tool blocks terminal states, not only Published
Paulo Castellano27f27b6683c8
diff --git a/app/Mcp/Tools/Post/PublishPostTool.php b/app/Mcp/Tools/Post/PublishPostTool.phpindex e27d9b391..d69904d9a 100644--- a/app/Mcp/Tools/Post/PublishPostTool.php+++ b/app/Mcp/Tools/Post/PublishPostTool.php@@ -47,8 +47,8 @@ class PublishPostTool extends Tool'scheduled_at' => $scheduledAt,]);- if (data_get($result, 'action') === PostAction::AlreadyPublished) {- return Response::error('Post is already published.');+ if (in_array(data_get($result, 'action'), [PostAction::AlreadyPublished, PostAction::Finalized], true)) {+ return Response::error('Post is already published or in a terminal state.');}/** @var Post $updated */diff --git a/tests/Feature/Mcp/PostPublishToolTest.php b/tests/Feature/Mcp/PostPublishToolTest.phpindex c3b29b903..7b269fdc2 100644--- a/tests/Feature/Mcp/PostPublishToolTest.php+++ b/tests/Feature/Mcp/PostPublishToolTest.php@@ -256,3 +256,26 @@ test('publish post 404 from another workspace', function () {$response->assertHasErrors(['Post not found.']);});++test('publish post rejects posts already in a terminal state', function (PostStatus $status) {+ $post = Post::factory()->create([+ 'workspace_id' => $this->workspace->id,+ 'user_id' => $this->user->id,+ 'status' => $status,+ ]);++ PostPlatform::factory()->linkedin()->create([+ 'post_id' => $post->id,+ 'social_account_id' => $this->socialAccount->id,+ ]);++ $response = TryPostServer::actingAs($this->user)+ ->tool(PublishPostTool::class, ['post_id' => $post->id]);++ $response->assertHasErrors(['Post is already published or in a terminal state.']);+})->with([+ PostStatus::Published,+ PostStatus::PartiallyPublished,+ PostStatus::Failed,+ PostStatus::Publishing,+]);