x-agent MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@x-agent MCP Serverpublish this approved post: We just shipped v2.0!"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
X-agent
Private, self-hosted X publishing automation built around the authenticated X web UI.
x-agent lets an AI assistant or local operator publish reviewed posts, linear threads, replies, and Community posts through Playwright. It does not require X API credits and keeps the authenticated browser session on infrastructure you control.
This is browser automation, not an official X API client. X may change its UI, authentication behaviour, or terms at any time. Use it only with an account you control and in accordance with X's rules.
Capabilities
Publish one final, approved X post.
Publish a linear thread: root post followed by sequential replies.
Reply to an ordinary or Community post.
Select an X Community by exact name, with fail-closed verification.
List Communities available to the current account without publishing.
Attach one image to a post or to the root of a thread.
Use the project through CLI, stdio MCP, or bearer-protected Streamable HTTP MCP.
Related MCP server: ilo
Architecture
Chat or local operator
|
+-- CLI
+-- MCP stdio
+-- Streamable HTTP MCP (Bearer token)
|
v
x_agent.posts
|
Playwright and Chromium
|
authenticated X cookie session
|
x.comThe chat agent drafts and obtains explicit approval. The execution layer receives only final text and performs the external action. x_agent/posts.py owns browser interaction, audience selection, media verification, reply chaining, and sanitized diagnostics.
Safety model
Publishing is an external side effect and must happen only after explicit approval of the final draft.
The implementation fails closed:
A requested Community must be uniquely matched, selected, and confirmed. Failure never falls back to Everyone.
A requested image must produce both an X composer preview and a successful upload response. Otherwise Post is never clicked.
A thread stops at the first failed reply and reports already-published URLs; it never continues blindly.
Repository layout
x_agent/
browser.py Browser setup, cookies, authentication checks
cookies.py Cookie-file handling
posts.py Posts, replies, threads, Communities, media verification
cli.py stdin-based command-line interface
mcp_server.py Dependency-free stdio MCP server
mcp_http.py Streamable HTTP MCP server with bearer authentication
debug.py Sanitized file logging
systemd/ Example service units
tests/ Unit tests
*.env.example Configuration templates; no secretsHistorical experiments, local backups, logs, screenshots, cookies, virtual environments, and environment files are deployment artefacts, not production source.
Prerequisites
Linux with Python 3.11+.
Playwright and Chromium or Chrome.
An X account authenticated in a browser session you control.
A cookie export available only on the deployment host.
Example setup:
python3 -m venv venv
./venv/bin/pip install playwright mcp uvicorn starlette
./venv/bin/playwright install chromiumSession cookies
Store the cookie export outside the repository, for example:
/opt/x-agent/x_cookies.jsonProtect it:
sudo chown root:root /opt/x-agent/x_cookies.json
sudo chmod 600 /opt/x-agent/x_cookies.jsonNever commit cookies, tokens, browser profiles, logs, screenshots, or .env files. Refresh the cookie export from a trusted browser session when x_status reports an expired session.
CLI
The CLI reads text from standard input rather than process arguments.
PYTHONPATH=/opt/x-agent /opt/x-agent/venv/bin/python3 -m x_agent.cli status
printf '%s' 'Final approved text' |
PYTHONPATH=/opt/x-agent /opt/x-agent/venv/bin/python3 -m x_agent.cli post --publish
printf '%s' 'Final approved text' |
PYTHONPATH=/opt/x-agent /opt/x-agent/venv/bin/python3 -m x_agent.cli post --publish --image /absolute/path/to/image.png
printf '%s' '["1/2 Root", "2/2 Reply"]' |
PYTHONPATH=/opt/x-agent /opt/x-agent/venv/bin/python3 -m x_agent.cli thread --publish --image /absolute/path/to/image.png
printf '%s' 'Final approved text' |
PYTHONPATH=/opt/x-agent /opt/x-agent/venv/bin/python3 -m x_agent.cli post --publish --community 'Hacking / Ethical Hacking'
printf '%s' 'Final approved reply' |
PYTHONPATH=/opt/x-agent /opt/x-agent/venv/bin/python3 -m x_agent.cli reply https://x.com/account/status/123 --publishMCP tools
Tool | Side effect | Description |
x_status() | No | Check authenticated X session. |
list_x_communities() | No | List Communities available to this account. |
create_x_post(text, community=None, image_path=None) | Yes | Publish one approved post. community=None means Everyone. |
create_x_thread(posts, community=None, image_path=None) | Yes | Publish a linear reply thread; image applies to root only. |
reply_x_post(post_url, text) | Yes | Reply to an existing post. |
HTTP MCP
The Streamable HTTP endpoint uses a bearer token and listens on 127.0.0.1:8765 by default.
Create /etc/x-agent/mcp.env with root-only permissions:
X_AGENT_MCP_TOKEN=replace-with-a-long-random-value
X_AGENT_X_USERNAME=your_x_handleInstall systemd/x-agent-mcp.service as /etc/systemd/system/x-agent-mcp.service, then:
sudo systemctl daemon-reload
sudo systemctl enable --now x-agent-mcp.service
sudo systemctl status x-agent-mcp.serviceIf reverse-proxying externally, use TLS, bearer authentication, restrictive firewall or proxy policy, and keep cookies and logs inaccessible.
Community publishing
Omitting community preserves X's default audience: Everyone.
With community="Exact Community Name", the agent opens the audience picker before entering text, finds a single exact normalized match, selects it, and verifies the result. Any ambiguity aborts before root publication. Thread replies follow the context created by the root post.
Use list_x_communities() before publishing when the display name is uncertain.
Image publishing
Pass an absolute local path through image_path (MCP) or --image (CLI). Supported formats are JPG, JPEG, PNG, WEBP, and GIF. A thread can have an image on the root post.
Before posting, the agent requires:
An attachment preview rendered by X in the active composer.
A successful media-upload response.
If either proof is missing, publication aborts without creating a post.
Diagnostics
Runtime log:
/var/log/x-agent/thread-debug.logFailure screenshots are stored under /var/log/x-agent/. Diagnostics omit post bodies, cookie values, bearer tokens, and full upload URLs. They retain operation stage, selector decision, audience state, response status, post IDs, and post URLs.
Testing
PYTHONPATH=. ./venv/bin/python3 tests/test_posts.py
./venv/bin/python3 -m py_compile x_agent/*.pyDeployment notes
Keep reviewed source in a Git repository, for example /home/ai/x-agent-build, and deploy a reviewed copy to /opt/x-agent. Restart x-agent-mcp.service after changing long-running MCP code; CLI executions load fresh code every run.
License
Licensed under the MIT License.
This server cannot be deployed
Maintenance
Related MCP Connectors
Remote streamable-HTTP MCP server running on a single Cloudflare Worker. Your assistant gets live Airbnb, Amazon, Booking.com, Google Flights, Maps and Reddit data, social search on X, Instagram and TikTok, the Meta Ad Library, and image/video generation without any keys. Connect your own accounts to let it send WhatsApp or Telegram messages, work an IMAP inbox, manage Meta Ads campaigns and publish to X and LinkedIn. OAuth 2.1 with PKCE; stored credentials are AES-256-GCM encrypted.
X (Twitter) data for AI agents: tweets, profiles, followers, search, trends + social listening.
X/Twitter reads, search, monitors and posting. Pay-per-call in USDC — no signup, no API keys.
AI social media team for founders: make and publish posts, carousels and short video to LinkedIn, X, Instagram, TikTok, YouTube, Facebook, Threads, Reddit and Bluesky, from any agent. OAuth sign-in, no API key; every draft waits for approval.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with Twitter/X through Playwright browser automation without requiring an official API key. It provides tools for posting content, searching tweets, reading feeds, and managing social interactions like follows and likes.4MIT
- AlicenseNot gradedqualityAmaintenanceA local-first MCP server for social publishing on X (Twitter), enabling draft management, scheduling, and posting via CLI or AI agents.41 npm5MIT
- FlicenseNot gradedqualityCmaintenanceEnables posting single tweets, threads, and saving drafts to X (Twitter) automatically using Playwright.-
- AlicenseAqualityAmaintenanceA local Model Context Protocol server that lets your coding agent draft, get human approval for, and publish posts to X using the X API v2.33376 npm3MIT