Cover for X (Twitter) MCP vs X API for Claude Code, Codex and More

X (Twitter) MCP vs X API for Claude Code, Codex and More

Build on the X API or add an X MCP server? Compare both routes, then post, reply, quote and run polls on X from Claude Code, Cursor or Codex.

Nov 7, 20265 min readAlexandroAlexandro
Table of Contents

There are two ways to let Claude Code, Cursor, Codex or another agent like Muse or OpenClaw post to X (Twitter). You can build on the X API yourself, or add an X MCP server that already speaks it. For most people the MCP server wins, and with PublishQ it's one line in Claude Code after you connect your X account:

claude mcp add --transport http publishq https://publishq.com/mcp

Approve it in the browser, then ask "Post this to X and add a poll: MCP server, CLI or SDK, open for a day."

x api integration versus an mcp server

The two routes side by side

Build on the X APIPublishQ MCP server
Before the first postA developer account, an app, OAuth keys and a token flowConnect your X account in PublishQ
What your agent callsEndpoints you wrap as tools yourselfpublishq_create_post, ready to use
Photos and videoChunked media upload, then attach the media IDspublishq_upload_media, then pass the media ID
Polls, replies, quotesSeparate fields you map yourselfSettings on the X account entry
Rate limitsYour code tracks themThe error names the rule, and the agent retries
Other platformsAnother integration eachThe same call, more accounts

Building on the X API makes sense if you want full control of every request, or you're already deep in a custom integration. If what you want is "my agent posts to X," the build is most of the work and none of the value.

What your agent can post through the MCP server

  • Text up to 280 characters, or up to 25,000 on Premium. Emojis count as 2 characters and every link counts as 23.
  • Up to 4 photos, or one video, or one GIF.
  • A poll with 2 to 4 options of up to 25 characters each, open from 5 minutes up to 7 days.
  • A reply to one post (replyToTweetId), or a quote of one post (quoteTweetId).
  • A post in a community you're a member of (communityId), optionally shared with your followers too.
  • Who may reply, with replySettings: following, mentionedUsers, subscribers or verified.

A poll can't carry media or a quote, and a quote can't carry media or a poll. X refuses those combinations, and the agent gets an error that says so.

ai agent posting a poll on x

A poll, as the agent sends it

{
  "content": "Which one should I build next?",
  "accounts": [
    {
      "accountId": "9a8b7c6d-5e4f-3210-9876-543210fedcba",
      "platformSpecificSettings": {
        "poll": { "options": ["MCP server", "CLI", "SDK"], "durationMinutes": 1440 },
        "replySettings": "following"
      }
    }
  ],
  "publishNow": true
}

durationMinutes of 1440 keeps the poll open for a day, and replySettings limits replies to people you follow.

The long post, the short post

Writing for X usually means writing a shorter version of something. Put your LinkedIn and X accounts in one call, write the full text once, and give X its own version with postOverrides. The X post previewer counts characters the way X does, links and emojis included, so the short version fits before you send it. Every X field is in the Twitter API guide, and the X limits page has the numbers.

Setup per client

  • Claude Code: the command at the top, then Authenticate in /mcp. More on the Claude Code X page.
  • Cursor: {"mcpServers": {"publishq": {"url": "https://publishq.com/mcp"}}} in ~/.cursor/mcp.json. See the Cursor X page.
  • Codex: npx @publishq/cli@latest login, then codex mcp add publishq -- npx -y @publishq/mcp@latest. Codex handles a week of queued posts well, see the Codex X page.
  • Claude and ChatGPT: add https://publishq.com/mcp as a custom connector or app.

scheduling a week of x posts with codex

When you're ready to schedule

Give the post a scheduledAt time instead of publishNow, or leave both out and it's saved as a draft for you to check. The X scheduler shows the queue on a calendar, and the MCP docs list every tool the agent gets. For image posts, the X carousel generator designs the slides.

Other agents: Muse, OpenClaw, Hermes Agent and more

The MCP route works the same in any agent that can use MCP tools or run a command:

For an agent that isn't listed, open publishq.com/agents and copy the line at the top of that page into your agent. It reads the page, sets itself up, and gives you a link to approve the login in your browser.

Create a PublishQ account, connect X, and ask your agent for a poll. It's the quickest way to see the whole thing work.

Frequently Asked Questions

Direct answers extracted from this article.

Yes. Connect your X account in PublishQ, add https://publishq.com/mcp to Claude Code, approve it in your browser, and Claude Code can post, reply, quote and create polls.
Not with the PublishQ MCP server. You connect your X account in PublishQ, and the agent uses PublishQ's tools. Building on the X API yourself needs a developer account, an app and OAuth keys.
Yes. A poll takes 2 to 4 options of up to 25 characters and can stay open from 5 minutes to 7 days. A poll can't carry media or a quote.
X allows 280 characters, or up to 25,000 on Premium. Emojis count as 2 characters and every link counts as 23.
Yes. Put both accounts in one publishq_create_post call and give X a shorter version with postOverrides.
Start for Free

No credit card required • Set up in under 3 minutes