How to post on X with an AI agent
Connect your agent to the X API through xmcp, the official X MCP server, then ask it to draft posts and only publish after you approve. Claude Code, Codex and Cursor all add it as an MCP server. Grok Bot connects to your X account directly and asks before it posts anything.
Checked against official docs on Oct 26, 2026.
Get the free starter kit. One short email a day when our setups change.
Free starter kit on signup: 2 Claude Code skills and 1 agent persona from our paid packs. By subscribing you agree to get The AI Loadout Daily, one email each morning. No spam, we never sell your email, and every email has a one-click unsubscribe link.
Claude Code
git clone https://github.com/xdevplatform/xmcp && cd xmcppython -m venv .venv && source .venv/bin/activate && pip install -r requirements.txtPut X_OAUTH_CONSUMER_KEY and X_OAUTH_CONSUMER_SECRET from your X developer app in .env, plus X_API_TOOL_ALLOWLIST=getUsersByUsername,createPosts,searchPostsRecentpython server.py (serves http://127.0.0.1:8000/mcp by default)claude mcp add --transport http xmcp http://127.0.0.1:8000/mcpAsk: "Draft 3 posts about today's release. Show them to me. Do not call createPosts until I say which one."
Codex
Start xmcp the same way (python server.py)codex mcp add xmcp --url http://127.0.0.1:8000/mcpcodex mcp list to confirm it is connectedAsk Codex to draft first and post only after you approve
Cursor
Start xmcp the same way (python server.py)Add to .cursor/mcp.json: {"mcpServers":{"xmcp":{"url":"http://127.0.0.1:8000/mcp"}}}Cursor asks for approval before each MCP tool call by default, so leave that on for createPosts
Grok Bot
Connect your X account to Grok BotAsk: "Draft a post about X. Do not post it."Edit the draft, then tell Grok Bot to post it. Posting is a sensitive action, so it asks you first
Gotchas
- Posting through the X API needs a developer account and app. Check X's current API pricing before you build on it.
- Keep X_API_TOOL_ALLOWLIST short. Every tool you load is one more thing the agent can call.
- Never let an agent auto-reply or auto-follow at scale. That breaks X's automation rules.
The loadout for this job
- Tools: Claude, ChatGPT
- Skill: Prompt copywriting framework
- Repo: X Algorithm
- Model: Grok 4.7
- Bot: Grok Bot
- Full setup: Best AI setup for social media posts
FAQ
Can an AI agent post on X for me?
Yes, through the X API. xmcp is X's own MCP server for it. Keep a human approval step before anything goes live.
Is there an official X MCP server?
Yes. xdevplatform/xmcp on GitHub runs locally and exposes X API endpoints as MCP tools.
Related how-tos
Sources
Commands change. Check the linked docs before you run anything. All how-to guides