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/mcpApprove it in the browser, then ask "Post this to X and add a poll: MCP server, CLI or SDK, open for a day."

The two routes side by side
| Build on the X API | PublishQ MCP server | |
|---|---|---|
| Before the first post | A developer account, an app, OAuth keys and a token flow | Connect your X account in PublishQ |
| What your agent calls | Endpoints you wrap as tools yourself | publishq_create_post, ready to use |
| Photos and video | Chunked media upload, then attach the media IDs | publishq_upload_media, then pass the media ID |
| Polls, replies, quotes | Separate fields you map yourself | Settings on the X account entry |
| Rate limits | Your code tracks them | The error names the rule, and the agent retries |
| Other platforms | Another integration each | The 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,subscribersorverified.
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.

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, thencodex 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/mcpas a custom connector or app.

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:
| Agent | Guide |
|---|---|
| Muse | X from Muse |
| OpenClaw | X from OpenClaw |
| Hermes Agent | X from Hermes Agent |
| Manus | X from Manus |
| Kiro | X from Kiro |
| Gemini CLI | X from Gemini CLI |
| Claude Cowork | X from Claude Cowork |
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.
