Skip to content

Full per-platform meta parity for posts (API + MCP) - #101

Merged
paulocastellano merged 5 commits into
mainfrom
feat/mcp-api-platform-meta
Jun 16, 2026
Merged

Full per-platform meta parity for posts (API + MCP)#101
paulocastellano merged 5 commits into
mainfrom
feat/mcp-api-platform-meta

Conversation

@paulocastellano

Copy link
Copy Markdown
Contributor

Why

The public REST API and MCP tools only validated aspect_ratio in PostPlatform.meta. Because validated() strips keys without rules, every other per-platform setting (channel_id, board_id, privacy_level, mentions, embeds, TikTok flags) was silently dropped. As a result Discord, Pinterest and TikTok could not be configured or published via API/MCP — only via the web UI.

What

  • app/Support/PostPlatformMetaRules.php — single source of truth for per-platform meta:
    • rules() — all meta.* validation rules.
    • addRequiredOnPublishErrors() — required-on-publish from submitted request platforms (web + API update).
    • assertStoredPostPublishable() — required-on-publish from a post's stored state (MCP publish, which doesn't resubmit platforms).
    • requiredMetaViolation() — one definition of what each platform requires to publish.
  • Web UpdatePostRequest refactored to use the shared source (DRY, no behavior change).
  • API StorePostRequest / UpdatePostRequest now accept all per-platform meta; update enforces required-on-publish (TikTok privacy, Pinterest board, Discord channel).
  • MCP CreatePostTool / UpdatePostTool accept all per-platform meta, with documented schemas.
  • MCP PublishPostTool guards a post's stored meta before dispatching, so a misconfigured post fails fast with a clear message instead of only at publish time.

Tests

  • tests/Feature/Api/PostApiPlatformMetaTest.php — API persists Discord/Pinterest/TikTok meta, rejects publishing Discord without a channel, publishes with a channel.
  • tests/Feature/Mcp/PostPlatformMetaToolTest.php — MCP create persists meta, publish guards/permits based on the channel.
  • PostPlatform::factory()->discord() state added.

Full suite green (2092 passed).

Centralize per-platform PostPlatform.meta validation in PostPlatformMetaRules
(shared by web, REST API and MCP). The API and MCP previously only accepted
aspect_ratio, silently stripping channel_id/board_id/privacy_level and the rest
via validated(), so Discord/Pinterest/TikTok couldn't be configured or published
through those entry points. Now all per-platform meta is accepted and persisted,
required-on-publish is enforced on API update (TikTok privacy, Pinterest board,
Discord channel), and the MCP publish tool guards a post's stored meta before
dispatching. Adds API + MCP tests and a PostPlatform discord() factory state.
Broaden the post meta tests beyond Discord: store persists Instagram aspect
ratio, Pinterest board, TikTok privacy + flags; API update enforces TikTok
privacy and Pinterest board on publish and allows drafts without required meta;
MCP update merges meta and the publish guard ignores disabled platforms.
…etaRules

The shared rules() returned only meta sub-keys, so every caller still repeated
its own 'platforms.*.meta' => array parent (with slightly different sometimes/
nullable combos). Fold the parent into rules() with a single safe contract so
callers just spread one source for the whole meta block.
Record in CLAUDE.md that all platforms.*.meta validation and required-on-publish
logic lives only in PostPlatformMetaRules, why (validated() strips unlisted keys),
and where to add new per-platform meta + tests.
- Assert nested Discord meta keys (mention token/label, embed title/color)
  survive validated(), replacing a vacuous coalesced assertion.
- Cover the MCP publish guard for TikTok privacy and Pinterest board, not
  just Discord.
- Use assertUnprocessable() to match sibling API tests; type-hint the API
  UpdatePostRequest withValidator closure.
@paulocastellano
paulocastellano merged commit ce10739 into main Jun 16, 2026
2 checks passed
@paulocastellano
paulocastellano deleted the feat/mcp-api-platform-meta branch June 16, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant