Skip to content

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.

fix(mcp): use morph alias for mediable_type to match production storage

Paulo Castellano41a704dc6af1
diff --git a/app/Mcp/Tools/Post/AttachMediaFromUploadTool.php b/app/Mcp/Tools/Post/AttachMediaFromUploadTool.php
index 520c0eb7d..dcebfe95f 100644
--- a/app/Mcp/Tools/Post/AttachMediaFromUploadTool.php
+++ b/app/Mcp/Tools/Post/AttachMediaFromUploadTool.php
@@ -36,7 +36,7 @@ class AttachMediaFromUploadTool extends Tool
$media = Media::query()
->where('upload_token', data_get($validated, 'upload_token'))
- ->where('mediable_type', Workspace::class)
+ ->where('mediable_type', (new Workspace)->getMorphClass())
->where('mediable_id', $workspaceId)
->first();
diff --git a/tests/Feature/Mcp/AttachMediaFromUploadToolTest.php b/tests/Feature/Mcp/AttachMediaFromUploadToolTest.php
index e44811454..fa3560bac 100644
--- a/tests/Feature/Mcp/AttachMediaFromUploadToolTest.php
+++ b/tests/Feature/Mcp/AttachMediaFromUploadToolTest.php
@@ -24,7 +24,7 @@ beforeEach(function () {
$this->token = (string) Str::uuid();
$this->media = Media::factory()->create([
- 'mediable_type' => Workspace::class,
+ 'mediable_type' => (new Workspace)->getMorphClass(),
'mediable_id' => $this->workspace->id,
'collection' => 'assets',
'upload_token' => $this->token,
@@ -48,7 +48,7 @@ test('rejects a token from a different workspace', function () {
$foreignToken = (string) Str::uuid();
Media::factory()->create([
- 'mediable_type' => Workspace::class,
+ 'mediable_type' => (new Workspace)->getMorphClass(),
'mediable_id' => $otherWs->id,
'collection' => 'assets',
'upload_token' => $foreignToken,