How to connect X to AI agents
verified
TL;DR
There is an official MCP server (https://api.x.com/mcp) and an official API (X API v2), so agents can search, fetch and create posts with your own developer app over OAuth 2.0. Pricing is pay-per-use: creating a post costs $0.015 per request ($0.20 if the post contains a URL) and reading a post costs $0.005 per resource. Browser automation and scraping are prohibited by the terms of service and the automation rules.
| Recommended method | Official MCP |
|---|---|
| Authentication | OAuth 2.0 (an app-only Bearer token is also available. OAuth 1.0a can be used with the API and the self-hosted xmcp) |
| Pricing | Pay-per-use (no subscription. Buy credits upfront in the Developer Console; they are deducted per request. There is no free plan) |
| Verified | 2026.12.05 |
Official MCP and AI guides
- Official MCP serverYes
Hosting: Remote and local
A hosted official MCP server from the X Developer Platform (Streamable HTTP, with OAuth discovery). Authentication is OAuth 2.0 or an app-only Bearer token; OAuth 1.0a is not available on the hosted server (it can be used with the API and the self-hosted xmcp). It does not support dynamic client registration, so you need the OAuth 2.0 Client ID of your own X app. For clients without native OAuth support there is an official local bridge, xurl (`npx -y @xdevplatform/xurl mcp https://api.x.com/mcp`). Adding ?read_only=true to the URL makes the connection read-only. A self-hosted version is published in the official xdevplatform/xmcp repository (Python; it generates tools from the X API OpenAPI specification with FastMCP). The tool list below covers the main tools from the xmcp list; there are more than 100 tools in total. The hosted server's full tool list is only published inside an authenticated session, and whether it matches the xmcp list exactly is Unverified.
- Official guide for AI agentsYes
There is an official Docs MCP (https://docs.x.com/mcp, hosted) for searching and reading the developer documentation itself. The MCP setup steps are also collected on the documentation's MCP page.
Tools of the official MCP server
| Tool | Type | What it does |
|---|---|---|
searchPostsRecent | Read | Search recent posts |
searchPostsAll | Read | Search the full archive of posts |
getPostsById | Read | Fetch a post by its ID |
getPostsLikingUsers | Read | Fetch the users who liked a post |
createPosts | Write | Create a post |
deletePosts | Write | Delete a post |
getUsersByUsername | Read | Fetch a user by username |
getUsersMe | Read | Fetch the authenticated user |
searchUsers | Read | Search users |
getUsersPosts | Read | Fetch a user's posts |
getUsersTimeline | Read | Fetch a user's home timeline |
getUsersMentions | Read | Fetch mentions |
getUsersBookmarks | Read | Fetch bookmarks |
createUsersBookmark | Write | Bookmark a post |
getTrendsByWoeid | Read | Fetch trends for a location (WOEID) |
getNews | Read | Fetch news stories |
searchNews | Read | Search news |
likePost | Write | Like a post |
repostPost | Write | Repost a post |
createDirectMessagesByParticipantId | Write | Send a direct message |
Connectors
Official connectors from AI services
There is an X connector (Standard) for Copilot Studio, and also for Power Automate, Power Apps and Logic Apps. However, the shared application maintained by Microsoft is no longer available; only Bring your own application is supported, and Microsoft Learn states that a paid Enterprise tier application is required.
Not supported: Claude, ChatGPT, Gemini
Third-party integration services
There is a built-in X node. It can create, reply to, delete, search, like and repost tweets, create direct messages, fetch users and add members to lists. It can also be used as a tool by AI agents. Your own X developer app (Client ID / Client Secret) is required.
There is an X connector (Standard), but as with Copilot Studio only Bring your own application is supported, and Microsoft Learn states that a paid Enterprise tier application is required.
The X (Twitter) service is still available, with 17 triggers, queries and actions in total (triggers such as a new post by you, a new mention, a new follower, and posts matching a search; queries for account stats and profiles; and a post-a-tweet action). Triggers poll: every hour on Free, every 15 minutes on Starter, and every 5 minutes on Pro and Pro+.
There is a Twitter toolkit with 87 tools (creating and deleting posts, search, direct messages, lists, bookmarks, follows, media uploads, and more), usable from agents through Composio's MCP / Tool Router. Composio-managed OAuth has been discontinued, so registering your own X developer app's Client ID, Client Secret and app-only Bearer token is required (per Composio's official documentation).
X (Twitter) appears in the integration app list, and Yoom states that it connects to the X API without code to automate actions such as posting.
Not supported: Zapier, Make
Unverified: Pipedream
Security assessment
For each available connection method: who provides it, the permissions it requires, how the terms treat it, and the data path. Items we could not confirm are marked Unverified.
- Official MCPOfficial MCP serverThe service provider
Permissions required Read and write Determined by the OAuth 2.0 scopes of your own X app (tweet.read, tweet.write, users.read, media.write, like.write, and others; adding offline.access gives a refresh token). Access tokens last two hours. An app-only Bearer token is read-only and cannot act as a user. ?read_only=true removes write tools on the server side
Terms of service No issues An official connection method, used within the Developer Agreement and Developer Policy. The Developer Policy prohibits using X content to train foundation models
Source: relevant section of the terms
Data path The MCP client connects directly to X's servers (api.x.com). With the xurl bridge, access and refresh tokens are stored locally in ~/.xurl, so the machine's file permissions and device management apply. Fetched content, such as posts, is passed to the connected MCP client (the AI provider). Separately check that the AI client is on a setting or plan where the data is not used for training. - Official connectorMicrosoft CopilotOfficial from the integration service
Permissions required Read and write Limited to the permissions of your own X app that you bring. Connections are not shareable; each user creates their own connection
Terms of service No issues The route uses the official API and raises no terms issue. However, Microsoft Learn states that a paid Enterprise tier application is required (a pricing and contract condition).
Source: relevant section of the terms
Data path Connects to the X API through Microsoft's cloud (Power Platform) - Third-party integrationn8nOfficial from the integration service
Permissions required Read and write Limited to the OAuth permissions of your own X app. API usage is billed to your own developer account's credits
Terms of service No issues A route that uses the official API with your own app
Source: relevant section of the terms
Data path When self-hosted, your own n8n connects directly to X. With n8n Cloud, requests go through n8n's servers - Third-party integrationPower AutomateOfficial from the integration service
Permissions required Read and write Limited to the permissions of your own X app that you bring. Connections are not shareable
Terms of service No issues The route uses the official API and raises no terms issue. However, Microsoft Learn states that a paid Enterprise tier application is required (a pricing and contract condition).
Source: relevant section of the terms
Data path Connects to the X API through Microsoft's cloud - Third-party integrationIFTTTOfficial from the integration service
Permissions required Read and write The permissions of the X account connected to IFTTT. Scope details are unverified
Terms of service Unverified What form of API agreement IFTTT connects under is Unverified from public information
Source: relevant section of the terms
Data path Goes through IFTTT's servers. The storage region is unverified - Third-party integrationComposioOfficial from the integration service
Permissions required Read and write Limited to the OAuth 2.0 scopes of your own X developer app. API usage is billed to your own developer account's credits
Terms of service No issues A route that uses the official API with your own developer app. Composio-managed authentication was discontinued in February 2026, and bringing your own app is now required
Source: relevant section of the terms
Data path Goes through Composio's servers. You register your app's Client Secret and Bearer token with Composio - Third-party integrationYoomOfficial from the integration service
Permissions required Read and write The permissions of the X account connected to Yoom. Details are Unverified
Terms of service Unverified What form of API agreement Yoom connects under is Unverified
Source: relevant section of the terms
Data path Goes through Yoom's servers. Details are Unverified
Data you can fetch within the terms of service
Posts, users, lists, direct messages, trends and more are available through the official API and the official MCP server. Taking data that only exists on web screens, which the API does not offer, by scraping or browser automation is not permitted.
- ScrapingProhibited
The Terms of Service (Misuse of the Services) prohibit accessing the services other than through the published interfaces, and state that crawling or scraping the Services in any form, for any purpose without prior written consent is expressly prohibited. The Automation Rules also prohibit non-API automation such as scripting the X website, and violations can result in permanent suspension of the account. robots.txt also returns Disallow: / for User-agent: *.
- Fetching with the agent's own browser
There is an official API or MCP server, so we do not recommend having an agent sign in and operate the site in a browser on your behalf.
Usage
How to connect
- Create a developer account in the X Developer Console (console.x.com), agree to the Developer Agreement, and create an app.
- Buy credits in the Developer Console (pay-per-use; the API cannot be used with a zero balance). A spending limit can also be set.
- Enable OAuth 2.0 in the app's authentication settings, register the callback URI of the MCP client you will use, and note the Client ID.
- Configure the MCP client with https://api.x.com/mcp and the Client ID, and in the browser consent screen grant only the scopes you need (such as tweet.read, tweet.write, users.read and offline.access). For read-only use, use https://api.x.com/mcp?read_only=true as the URL.
- For clients without native OAuth support, set the CLIENT_ID and CLIENT_SECRET environment variables (from your own X app), start the local bridge with
npx -y @xdevplatform/xurl mcp https://api.x.com/mcp, and complete the first browser sign-in (the callback http://localhost:8080/callback must be registered on the app).
Look up posts by keyword
Search recent posts about "agent connections" and show me the ones with the most engagement
searchPostsRecent searches recent posts. Reads cost $0.005 per resource, and the same resource is not charged twice within the same UTC day.
Check your own account
Tell me the name and username of the connected X account
getUsersMe fetches the authenticated account. Reads of your own data are Owned Reads at $0.001 per resource.
Create a post
Post this text: I published today's article
createPosts creates a post. Creating a post costs $0.015 per request, and $0.20 if it contains a URL. Automated replies and automated likes are restricted by the automation rules.
Pitfalls and tips
Pitfalls
- Pricing is pay-per-use, and reads are billed per resource returned. If a search returns 100 posts, the post reads alone cost $0.50. Letting an agent repeat broad searches consumes credits quickly.
- A post containing a URL costs $0.20 per request, more than 13 times a regular post ($0.015). Watch the cost of automating link posts.
- Pay-per-use post reads are capped at 3 million per billing cycle. Beyond that, an Enterprise plan is required.
- Only one live OAuth grant exists per app and user. Signing in from a second client with the same app revokes the first client's tokens. Use a separate app per client.
- X's automation rules state that AI-powered automated reply bots require X's prior written approval.
- Using X content to train foundation or frontier models is prohibited by the Developer Policy.
- The Zapier and Make integrations for X have been discontinued. Old integration articles and templates that remain online no longer work.
- Many unofficial MCP servers for X also circulate, but scraping-based ones and ones routed through third-party proxies may breach the terms' prohibition on scraping. Do not use them where the official MCP server is sufficient.
Tips
- For read-only use, add ?read_only=true so write tools are removed from the tool list.
- Your own data, such as your posts and bookmarks, costs $0.001 per resource as Owned Reads. Analyzing your own account is cheaper than regular reads.
- Set a spending limit in the Developer Console to prevent unexpected charges if an agent runs away.