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.

9.2 KB
Raw Blame
<?php

declare(strict_types=1);

use App\Mcp\Servers\TryPostServer;
use App\Mcp\Tools\Idea\CreateIdeaTool;
use App\Mcp\Tools\Label\CreateLabelTool;
use App\Mcp\Tools\Label\UpdateLabelTool;
use App\Mcp\Tools\Platform\ListContentTypesTool;
use App\Mcp\Tools\Post\AttachMediaFromUploadTool;
use App\Mcp\Tools\Post\AttachMediaFromUrlTool;
use App\Mcp\Tools\Post\CreatePostsTool;
use App\Mcp\Tools\Post\CreatePostTool;
use App\Mcp\Tools\Post\DeletePostTool;
use App\Mcp\Tools\Post\GetPostTool;
use App\Mcp\Tools\Post\PreviewPostTool;
use App\Mcp\Tools\Post\PublishPostTool;
use App\Mcp\Tools\Post\SetPostRecurrenceTool;
use App\Mcp\Tools\Post\UpdatePostTool;
use App\Mcp\Tools\Repurpose\CreateRepurposeTool;
use App\Mcp\Tools\Repurpose\UpdateRepurposeTool;
use App\Mcp\Tools\Signature\CreateSignatureTool;
use App\Mcp\Tools\Signature\ListSignaturesTool;
use App\Mcp\Tools\SocialAccount\GeneratePostingScheduleTool;
use App\Mcp\Tools\SocialAccount\GetInstagramAudioTool;
use App\Mcp\Tools\SocialAccount\GetTikTokCreatorInfoTool;
use App\Mcp\Tools\SocialAccount\ListFreeSlotsTool;
use App\Mcp\Tools\SocialAccount\ListSocialAccountsTool;
use App\Mcp\Tools\SocialAccount\ReorderQueueTool;
use App\Mcp\Tools\SocialAccount\SearchInstagramAudioTool;
use App\Mcp\Tools\SocialAccount\UpdatePostingScheduleTool;
use App\Mcp\Tools\Webhook\CreateWebhookTool;
use App\Support\PostPlatformMetaRules;
use Laravel\Mcp\Server\Attributes\Instructions;

function mcpToolText(string $tool): string
{
    return json_encode(app($tool)->toArray(), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}

function mcpToolDescription(string $tool): string
{
    return app($tool)->toArray()['description'];
}

function mcpServerInstructions(): string
{
    return (new ReflectionClass(TryPostServer::class))->getAttributes(Instructions::class)[0]->newInstance()->value;
}

dataset('post writing tools', [
    'create-post' => [CreatePostTool::class],
    'create-posts' => [CreatePostsTool::class],
    'update-post' => [UpdatePostTool::class],
]);

test('post writing tools explain how to publish a thread', function (string $tool) {
    expect(mcpToolDescription($tool))->toContain('thread_replies')->toContain('X, Bluesky or Mastodon');
})->with('post writing tools');

test('post writing tools say content is plain text', function (string $tool) {
    expect(mcpToolText($tool))->toContain('plain text')->not->toContain('<strong>')->not->toContain('or HTML');
})->with('post writing tools');

test('tools that schedule or publish list the required meta', function (string $tool) {
    expect(mcpToolText($tool))->toContain('privacy_level')->toContain('board_id')->toContain('channel_id')->toContain('required_meta')
        ->toContain('x_poll')->toContain('meta.poll');
})->with([
    'create-post' => [CreatePostTool::class],
    'create-posts' => [CreatePostsTool::class],
    'update-post' => [UpdatePostTool::class],
    'publish-post' => [PublishPostTool::class],
]);

test('list-content-types says a poll is refused even as a draft and what it needs', function () {
    expect(mcpToolDescription(ListContentTypesTool::class))
        ->toContain('The exception is a poll')
        ->toContain('drafts included')
        ->toContain('x_poll, mastodon_poll, threads_poll) needs meta.poll');
});

test('the attach media tools say a poll takes no media', function (string $tool) {
    expect(mcpToolDescription($tool))->toContain('x_poll, mastodon_poll or threads_poll) takes no media');
})->with([
    'upload' => [AttachMediaFromUploadTool::class],
    'url' => [AttachMediaFromUrlTool::class],
]);

test('tools that change a post list the statuses that block it', function (string $tool) {
    expect(mcpToolText($tool))->toContain('publishing, published or failed');
})->with([
    'update-post' => [UpdatePostTool::class],
    'delete-post' => [DeletePostTool::class],
]);

test('scheduled_at says it is utc and where the calendar ends', function (string $tool) {
    expect(mcpToolText($tool))->toContain('UTC')->toContain('2038-01-19');
})->with([
    'create-post' => [CreatePostTool::class],
    'create-posts' => [CreatePostsTool::class],
    'update-post' => [UpdatePostTool::class],
    'publish-post' => [PublishPostTool::class],
]);

test('get-post says its times are utc', function () {
    expect(mcpToolText(GetPostTool::class))->toContain('UTC');
});

test('delete-post says the post stays on the network', function () {
    expect(mcpToolText(DeletePostTool::class))->toContain('never removed from the network');
});

test('the url attach tool lists the download limits', function () {
    expect(mcpToolText(AttachMediaFromUrlTool::class))->toContain('20 seconds')->toContain('HEIC');
});

test('the upload attach tool names tools by their mcp name', function () {
    expect(mcpToolText(AttachMediaFromUploadTool::class))->not->toContain('RequestMediaUploadTool')->toContain('request-media-upload-tool');
});

test('preview-post does not promise truncation', function () {
    expect(mcpToolText(PreviewPostTool::class))->not->toContain('length truncation');
});

test('the meta documentation describes stories and single video feed posts', function () {
    expect(PostPlatformMetaRules::documentation())
        ->not->toContain('Instagram stories: no settings')
        ->toContain('publishes as a Reel');
});

test('the server instructions mention threads, the queue and approvals', function () {
    expect(mcpServerInstructions())->toContain('thread')->toContain('queue')->toContain('list-content-types-tool');
});

test('the posting schedule tools state their limits', function () {
    expect(mcpToolText(UpdatePostingScheduleTool::class))->toContain('at most 4')->toContain('1 to 28')
        ->and(mcpToolText(GeneratePostingScheduleTool::class))->toContain('1 to 28');
});

test('the queue tools state how many items they take', function () {
    expect(mcpToolText(ListFreeSlotsTool::class))->toContain('30')
        ->and(mcpToolText(ReorderQueueTool::class))->toContain('500');
});

test('the recurrence tool states its last possible occurrence', function () {
    expect(mcpToolText(SetPostRecurrenceTool::class))->toContain('2037-12-31');
});

test('tiktok creator info says the video duration is not checked for the agent', function () {
    expect(mcpToolText(GetTikTokCreatorInfoTool::class))->toContain('not checked');
});

test('signature tools say a signature is not added automatically', function (string $tool) {
    expect(mcpToolText($tool))->toContain('not added automatically');
})->with([
    'create-signature' => [CreateSignatureTool::class],
    'list-signatures' => [ListSignaturesTool::class],
]);

test('label tools give the color format', function (string $tool) {
    expect(mcpToolText($tool))->toContain('#RRGGBB');
})->with([
    'create-label' => [CreateLabelTool::class],
    'update-label' => [UpdateLabelTool::class],
]);

test('the idea tool states its limits', function () {
    expect(mcpToolText(CreateIdeaTool::class))->toContain('10000');
});

test('the webhook tool explains the signature and the pause', function () {
    expect(mcpToolText(CreateWebhookTool::class))->toContain('255')->toContain('X-Webhook-Signature')->toContain('5 failed');
});

test('repurpose tools give real schemas for formats, modes and destinations', function (string $tool) {
    $properties = data_get(app($tool)->toArray(), 'inputSchema.properties');

    expect(data_get($properties, 'source_format.enum'))->toBe(['reel', 'video', 'story'])
        ->and(data_get($properties, 'publish_mode.enum'))->toBe(['publish', 'draft'])
        ->and(array_keys(data_get($properties, 'destinations.items.properties')))->toBe(['social_account_id', 'content_type', 'meta']);
})->with([
    'create-repurpose' => [CreateRepurposeTool::class],
    'update-repurpose' => [UpdateRepurposeTool::class],
]);

test('media url descriptions give the server limits, pixels included', function (string $tool) {
    expect(mcpToolText($tool))->toContain('megapixels')->not->toContain('workspace size limits')->not->toContain('workspace-wide');
})->with([
    'attach-media-from-url' => [AttachMediaFromUrlTool::class],
    'create-post' => [CreatePostTool::class],
]);

test('the account listing and post text explain the x long post limit', function (string $tool) {
    expect(mcpToolText($tool))->toContain('long_posts')->toContain('25000')->toContain('280');
})->with([
    'list-social-accounts' => [ListSocialAccountsTool::class],
    'create-post' => [CreatePostTool::class],
    'create-posts' => [CreatePostsTool::class],
    'update-post' => [UpdatePostTool::class],
]);

test('the instagram audio tools name the platform that takes music', function (string $tool) {
    expect(mcpToolDescription($tool))->toContain('instagram-facebook');
})->with([
    'search' => [SearchInstagramAudioTool::class],
    'get' => [GetInstagramAudioTool::class],
]);

test('the instagram audio search says which fields let the app show the track', function () {
    expect(mcpToolDescription(SearchInstagramAudioTool::class))->toContain('title, artist, cover_url and preview_url into meta.audio');
});

test('the meta documentation explains how instagram music and collaborators behave', function () {
    expect(PostPlatformMetaRules::documentation())
        ->toContain('platform instagram-facebook')
        ->toContain('only after they accept the invite in the Instagram app')
        ->toContain('only refused when the post publishes');
});