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
<?php
declare(strict_types=1);
namespace App\Mcp\Tools\Post;
use App\Actions\PostNote\UpdatePostNote;
use App\Http\Resources\Api\PostNoteResource;
use App\Mcp\Concerns\AuthorizesMcpTool;
use App\Mcp\Concerns\ResolvesPostNotes;
use App\Models\Post;
use App\Models\PostNote;
use App\Models\Workspace;
use Illuminate\Contracts\JsonSchema\JsonSchema;
use Laravel\Mcp\Request;
use Laravel\Mcp\Response;
use Laravel\Mcp\ResponseFactory;
use Laravel\Mcp\Server\Attributes\Description;
use Laravel\Mcp\Server\Tool;
use Laravel\Mcp\Server\Tools\Annotations\IsDestructive;
use Laravel\Mcp\Server\Tools\Annotations\IsOpenWorld;
use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly;
#[IsReadOnly(false)]
#[IsDestructive(true)]
#[IsOpenWorld(false)]
#[Description('Edit the text of a note on a post. Only the note\'s author can edit it. Mentions work as in create-post-note-tool: @[user:id] for a member, @[everyone] for everyone who sees the post; a mention of someone who cannot see the post is removed. Only the people this edit adds as mentions are emailed, not those the note already mentioned. Everyone with the post open sees the change at once. Returns the updated note with mentions [{id, name}] and reactions.')]
class UpdatePostNoteTool extends Tool
{
use AuthorizesMcpTool, ResolvesPostNotes;
public function handle(Request $request): Response|ResponseFactory
{
$workspace = $this->currentWorkspace($request);
if (! $workspace instanceof Workspace) {
return $workspace;
}
$ids = $request->validate([
'post_id' => ['required', 'uuid'],
'note_id' => ['required', 'uuid'],
]);
$post = $this->notesPost($request, $workspace, data_get($ids, 'post_id'));
if (! $post instanceof Post) {
return $post;
}
$note = $this->noteOfPost($post, data_get($ids, 'note_id'));
if (! $note instanceof PostNote) {
return $note;
}
if ($denied = $this->denyUnlessCan($request, 'update', $note)) {
return $denied;
}
$validated = $request->validate([
'body' => ['required', 'string', 'max:2000'],
]);
return Response::structured((new PostNoteResource(UpdatePostNote::execute($post, $note, $request->user(), $validated)))->resolve());
}
public function schema(JsonSchema $schema): array
{
return [
'post_id' => $schema->string()->required()->description('The UUID of the post.'),
'note_id' => $schema->string()->required()->description('The UUID of the note, from list-post-notes-tool.'),
'body' => $schema->string()->required()->description('The new note text (max 2000 characters). Mention a teammate with @[user:id], or everyone with @[everyone].'),
];
}
}