Integrations

Connecting OpenClaw with Twitter / X: A Practical Guide

·20 min read

Twitter / X is where a lot of fast-moving market and audience context shows up first: mentions, replies, keyword conversations, competitor threads, post reactions, and account signals. That makes it a strong fit for an AI assistant that helps teams monitor conversations, research accounts, and act on threads from Slack instead of living inside the feed all day. If you are running OpenClaw yourself, this guide still covers the API tier tradeoffs and integration overhead you would otherwise need to manage.

How OpenClaw Integrations Work

OpenClaw is a self-hosted AI assistant that runs on your own server — typically an EC2 instance — and connects to Slack. It uses Claude under the hood to process requests. Out of the box, OpenClaw doesn't ship with pre-built connections to third-party tools. Instead, integrations are built using the skills system: markdown files in ~/.openclaw/skills/ that give Claude instructions for a particular domain, combined with HTTP tool calls to any API you expose to it.

In practice, adding a real integration means: getting API credentials from the third-party service, building or configuring a small proxy/endpoint that OpenClaw can call, and writing a skill file that tells Claude how to use it. For some tools this is an afternoon of work. For others — like Twitter / X — it's considerably more involved.

Connecting OpenClaw with Twitter / X: Step by Step

Step 1: Create a Twitter Developer Account and Project

Go to developer.twitter.com and apply for a developer account. Once approved, create a Project and an App within it. You'll receive an API Key, API Secret, Access Token, and Access Token Secret. These credentials are what your integration will use.

Step 2: Choose Your API Tier — This Is the Hard Part

Twitter/X restructured its API pricing significantly in 2023 and the free tier is extremely limited — 1,500 tweets posted per month, read access to your own account only. For any meaningful use:

  • Basic tier (~$100/mo): 10,000 posts/month, limited read access
  • Pro tier (~$5,000/mo): Full v2 API access, filtering streams, higher rate limits

If you want to monitor mentions, search tweets, or track competitors, you need at least the Basic tier. Full social listening requires Pro or Enterprise. Factor this cost into your decision.

Step 3: Build the OpenClaw Skill and API Proxy

Similar to other integrations, you'll need a small proxy service that stores your Twitter API credentials and exposes simple endpoints OpenClaw can call. Then write a skill file at ~/.openclaw/skills/twitter.md explaining what data is available. For read operations, use the Twitter v2 API endpoints — they're generally well-documented and stable.

Challenges and Caveats

The Free Tier Is Nearly Useless for This Use Case

Twitter/X's free API access no longer includes meaningful read access. If you're hoping to connect OpenClaw to monitor mentions or search tweets without paying, you'll be disappointed. Budget for at least the Basic tier.

Rate Limits Bite Frequently

Even on paid tiers, Twitter's rate limits are aggressive. Searches are limited per 15-minute window. If your OpenClaw integration is responding to many Slack queries about Twitter, you may hit limits during busy periods.

API Changes Have Been Frequent and Disruptive

Since the ownership change in 2022, Twitter/X has made numerous API changes with limited notice. Integrations that worked in 2022 may require significant updates today. Plan for ongoing maintenance.

X API in 2026: The Subscription Tiers Are Gone

Most "connect Twitter to OpenClaw" guides tell you to pick the Basic tier at roughly $100/month or the Pro tier at roughly $5,000/month. X no longer sells either. The X API moved to pay-per-usage credits: you buy credit in the Developer Console, set a spending limit, and every request deducts from the balance, priced per resource returned.

X's MCP documentation listing both first-party servers: the hosted X MCP server and the docs MCP server

That pricing change matters more for OpenClaw than for a normal integration, because OpenClaw is agentic. It does not make one API call, it makes a chain of them while reasoning: search, then resolve the authors, then pull the parent thread, then draft a reply. Under subscription pricing that chain was free at the margin. Under credits it has a price, and the price scales with how many posts the agent touches, not with how many questions your team asks in Slack.

What a credit actually costs

These are the read and write rates X publishes, per resource (docs.x.com pricing):

X API pay-per-usage pricing page showing the credit model and the read-operation rate table

Operation Unit cost What it means in a workflow
Post: Read $0.005 per post A 100-post search response is $0.50
User: Read $0.010 per user Author expansions roughly double the bill
Following/Followers: Read $0.010 per resource A 1,000-follower pull is $10
Post: Create $0.015 per request A plain post
Post: Create (with URL) $0.200 per request A link post is 13x a plain post
Post: Create (summoned) $0.010 per request Replies invoked through summon
DM Interaction: Create $0.015 per request —
Bookmark $0.005 per request —
Trends $0.010 per request Pricey relative to what it returns
Owned Reads $0.001 per resource Your own timeline, mentions, bookmarks, liked posts

Three things in that table decide your architecture:

  1. Owned Reads are five times cheaper. Any endpoint where {id} is the authenticated user and that user owns the developer app bills at $0.001 instead of $0.005 (/2/users/{id}/tweets, /mentions, /liked_tweets, /bookmarks, /followers, /following and the list endpoints). For monitoring your own account's conversation, that is the cheap path and it is also the more complete one.
  2. A post with a URL costs $0.20. Marketing posts almost always carry a link. Ten link posts a day is $2/day in writes before any reads. If the agent is drafting link posts, have it hand the copy to a human or to a scheduling tool rather than posting through the API.
  3. Resources deduplicate within a 24-hour UTC window. Asking about the same post twice in one day bills once, and the window resets at midnight UTC. X calls this a soft guarantee: it holds in the vast majority of cases but not through service outages. Do not build a budget model that assumes dedup will save you.

There is also a hard ceiling: pay-per-usage plans are capped at 3 million Post reads per monthly billing cycle. Above that you need Enterprise. At $0.005 a read that ceiling is roughly $15,000 of reads, so it is not a small-account problem, but it is worth knowing it exists before you point a full-archive crawler at it.

Two Official X Servers, And Only One Is Yours

X ships two hosted first-party MCP servers, and most guides mention neither:

Server URL What it does Do you want it?
X MCP https://api.x.com/mcp Calls the X API: search, users, timelines, mentions, bookmarks, news, trends, Articles ✅ Yes, this is the one
Docs MCP https://docs.x.com/mcp Searches and reads X's own API documentation (search_x, get_page_x) Optional, useful while building

The X MCP server is Streamable HTTP, protocol 2025-06-18, serverInfo: xmcp. It exposes the API across six capability groups: posts (fetch, likers, reposters, quoters, recent counts), search (full archive, user search, news search), users (resolve current user, look up by id or handle, read posts, timelines, mentions), bookmarks (list, add, remove, folders), news and trends by WOEID, and Articles (create draft, publish).

The Docs MCP server is genuinely useful during the build and genuinely useless afterwards. Two tools, no auth, point your client at the URL and it is connected. Add it as a second server if you are writing the skill file and want the agent to check endpoint details without you leaving the terminal. Remove it once the workflow is stable so it is not eating tool-selection attention.

The Connection Route Everyone Gets Wrong

Here is the fact that breaks most attempts: X does not support dynamic client registration, and api.x.com/mcp does not advertise MCP OAuth discovery.

That is not a bug, it is a consequence of X's auth model. X OAuth requires your own developer app. A hosted MCP server normally lets an arbitrary client register itself and get credentials on the spot; X refuses that, because the credential is an app you created and that X reviewed. So you cannot paste the URL into a client, click "Connect", and expect a consent screen. You get an error, or a client that sits there with zero tools.

You have two routes, and the difference between them is user context:

Route A: App-only Bearer (read-only, no bridge)

Create an X app, copy the App-only Bearer token from the app's Keys and tokens page, and point any client that supports remote MCP with custom headers straight at the endpoint.

{
  "mcpServers": {
    "xapi": {
      "url": "https://api.x.com/mcp",
      "headers": { "Authorization": "Bearer YOUR_APP_ONLY_BEARER_TOKEN" }
    }
  }
}

This is the fastest thing that works and it is fine for search, user lookup, trends and news. The trade-off is stated plainly by X: no auto-refresh and no user context. Every call is attributed to the application, not to a person. So anything phrased as "me" or "my" silently fails or returns nothing: bookmarks, Articles, and any timeline read of the authenticated user. If your Slack prompt says "check my bookmarks", this route cannot answer it.

Route B: The xurl mcp bridge (OAuth 2.0 user context)

The bridge is a small local process that owns your app's identity, performs the one-time PKCE login, and injects a fresh Bearer token on every call. It runs through the npm launcher, so there is no separate install.

// ~/.openclaw/settings.json — bridge route
{
  mcpServers: {
    xapi: {
      command: "npx",
      args: ["-y", "@xdevplatform/xurl", "mcp", "https://api.x.com/mcp"],
      env: {
        CLIENT_ID: "YOUR_X_APP_CLIENT_ID",
        CLIENT_SECRET: "YOUR_X_APP_CLIENT_SECRET",
      },
      // whichever key your client uses for spawn timeout
      startup_timeout_sec: 300,
    },
  },
}

The bridge is required for writes (bookmarks, Articles, posting) and for any tool that needs user context. It caches tokens in ~/.xurl and refreshes automatically, including a forced refresh after a 401.

What OpenClaw gets on each route

Capability App-only Bearer xurl bridge
Full-archive post search ✅ ✅
User lookup, timelines, mentions ✅ ✅
News and trends by WOEID ✅ ✅
Post counts (recent and all) ✅ ✅
Bookmarks list/add/remove ❌ ✅
Article draft + publish ❌ ✅
Post as a user ❌ ✅
"My timeline" / "my likes" ❌ ✅
Token refresh ❌ manual ✅ automatic
Headless scheduling ✅ (static token) ✅ after one out-of-band login

Setup Prerequisites, In Order

These four are cheap to do and each one is a separate way to lose an evening.

  1. Create the app and enable OAuth 2.0 in the X Developer Portal. The bridge route needs CLIENT_ID and CLIENT_SECRET from that app. The app also has to be in the Pay-per-use package and Production environment, or you will get client-not-enrolled immediately after a successful login, which reads like an auth bug and is actually a packaging mistake.
  2. Register http://localhost:8080/callback as a redirect URI on the app. If you use a different callback, set REDIRECT_URI and register that one instead. Miss this and the browser login dies with a redirect error after the user has already approved.
  3. Set startup_timeout_sec to at least 300. This is the one that makes people give up. On first run with no cached token, the bridge opens a browser and holds the MCP handshake until the human finishes logging in. Clients default to ten or thirty seconds and report a timeout on a step the user is still performing. Nothing is broken; the client just stopped waiting.
  4. For a headless box, authenticate out-of-band first. If OpenClaw runs on a server with no display, nothing will open a browser. Run the paste-a-code flow once, then the bridge reuses the cached token:
export CLIENT_ID="YOUR_X_APP_CLIENT_ID"
export CLIENT_SECRET="YOUR_X_APP_CLIENT_SECRET"
xurl auth oauth2 --headless

The export is not optional even if you set env in the client config: the client env block only applies to the bridge, not to manual xurl runs from your shell. That mismatch produces "You weren't able to give access to the App" in the browser, which sounds like an X outage and is a missing environment variable.

One more, subtler: the OAuth login authorises whichever X account is logged in when the browser opens, not necessarily the account that owns the app. If the agent posts on behalf of a brand or a bot account, switch accounts in the browser first, or pass -u <handle> in the bridge args to reuse a previously authorised user.

Rate Limits Survive the Pricing Change

Pay-per-usage changed the billing, not the ceilings. The limits are still per endpoint, per window, and split between app-level and user-level. X's docs are explicit that limits are per 15 minutes unless marked /sec or /24hrs.

X API rate limit tables — per-endpoint app and user limits, with the default and maximum result counts

Endpoint Per app Per user Notes
/2/tweets/search/recent 450/15min 300/15min 10 default, 100 max results; 512-char query
/2/tweets/search/all 1/sec, 300/15min 1/sec 10 default, 500 max results; 1024-char query
/2/users/:id/tweets 10,000/15min 900/15min Owned Read pricing when yours
/2/users/:id/mentions 450/15min 300/15min Owned Read pricing when yours
POST /2/tweets 10,000/24hrs 100/15min Writes are the tighter ceiling per user
DELETE /2/tweets/:id — 50/15min —
/2/tweets/search/stream 50/15min — 1 connection, 1,000 rules, 250 posts/sec
/2/users/by/username/:username/tweets 1,500/15min 900/15min —
/2/users/:id/liked_tweets 75/15min 75/15min Low; do not bulk-pull likes
/2/tweets/:id/retweeted_by 75/15min 75/15min Same for quoters and likers
/2/news/search 200/15min 200/15min —
/2/usage/tweets 50/15min — Your daily consumption, for budget alerts

Three traps live in that table:

  • The default result count is 10, not the maximum. An agent asked "what are people saying about us" without max_results gets ten posts and reports on them confidently. Put an explicit instruction in the skill file: request 100 for recent search, 500 for full archive, and page with next_token while the returned count equals the max.
  • search/all is one request per second per user. A backfill loop hits that almost immediately, and the agent sees 429s in the middle of a multi-step task, which the human reads as "the integration is broken" rather than "we are being rate limited".
  • Engagement lookups are the expensive-in-both-currencies endpoints. Likers, reposters and quoters are 75 per 15 minutes and they bill a User: Read at $0.010 for each account returned. A "who engaged with our launch post" sweep over a popular post is both slow and surprisingly expensive. Sample instead.

Every response carries x-rate-limit-limit, x-rate-limit-remaining and x-rate-limit-reset (a Unix timestamp). Have the skill file tell the agent to read x-rate-limit-reset and wait until that instant rather than retrying on a fixed sleep.

Budget Controls You Should Turn On Before The First Prompt

Credits make an agent's cost visible in a way subscriptions never did, and X's own console controls are the cheapest guardrail:

  • Set a spending limit per billing cycle. When the limit is reached, requests are blocked until the next cycle. This is the difference between a bad week and a bad invoice.
  • Enable auto-recharge, but understand its shape. It triggers the first time the balance drops below the threshold after having been at or above it, so a balance exactly equal to the threshold counts as armed: buy $5 with a $5 trigger and your very first spend fires a top-up. It fires at most once per 5 minutes and pauses at zero or negative balance, so a bursty workload can still run out mid-window. Raise the recharge amount so one top-up comfortably outlasts five minutes of peak use.
  • Query the usage endpoint for a real number. GET /2/usage/tweets returns daily post consumption and is limited to 50/15min, which is plenty for a nightly check. Have a scheduled task read it and post to Slack when consumption is pacing over budget.
  • Note that a negative balance blocks requests. X allows the balance to go slightly negative, and while it is negative every request is refused. That failure mode looks exactly like an auth problem.

Five Workflows Worth Building

1. Daily mention triage in Slack

"Pull the last 24 hours of posts mentioning @ourbrand. Group by theme, flag any from accounts above 10k followers, and draft a reply for each negative one. Do not post. Show me the drafts."

Use the mention timeline, not full-archive search. It is an Owned Read at $0.001 per resource, it is the complete view of your own conversation, and it is 30 posts to a page instead of a $0.50 search.

2. Launch reception report with cost control

"Count posts matching 'our launch' for the last 7 days. Then pull the top 50 by engagement, and give me a one-page summary. Do not pull author details unless I ask."

The two-step structure is the point: post counts cost $0.005 or $0.010 per request regardless of how many posts match, while fetching posts bills per post. Count first, read second, and let the count decide whether the read is worth it.

3. Competitor thread pull

"Search full archive for 'competitor-name' since 30 days ago, excluding replies and reposts, minimum 10 likes. Group by complaint theme and quote the three strongest examples."

-is:reply -is:retweet min_faves:10 cuts the result set before billing, which is the difference between a $3 pull and a $30 one. Set max_results at 500 and page explicitly.

4. Grounded content drafting

"Summarise what developers are saying about our new API this week, with three quotable posts, then draft a thread responding to the top complaint. Draft only."

Pair the X MCP server with the Docs MCP server here: one retrieves the public conversation, the other can confirm what our documentation actually says before the agent promises a feature.

5. Bookmark-driven research intake

"List my bookmarks from the last 14 days, cluster them by topic, and turn each cluster into a three-bullet research note in Notion."

This one requires the bridge. App-only Bearer has no user identity, so bookmarks return nothing and the agent will report an empty folder rather than an auth error.

X-Specific Pitfalls

The traps that are specific to X plus an agent, rather than to "connecting an API" in general.

  1. Your base data may still describe the subscription tiers. Several published guides and internal docs still list Free, Basic and Pro. If an onboarding doc asks you to budget $5,000/month for Pro, it is describing a product X no longer sells. Budget in credits instead, and treat the spending limit as the real control.

  2. A URL in a post costs 13 times more than a post without one. $0.20 versus $0.015. An agent that appends a link to every announcement is the single fastest way to burn a credit balance. Draft link posts for human review, or route them through a scheduler that posts outside the API billing.

  3. Dedup is a soft guarantee. Resources dedupe within a 24-hour UTC window, but X says outright that edge cases like service outages can defeat it. Do not build a cost model that assumes the same post fetched twice is free.

  4. There is no dynamic client registration, so "paste the URL" does not work. api.x.com/mcp does not advertise MCP OAuth discovery. A client that insists on automatic registration will show zero tools with no useful error. Use the bridge, or app-only Bearer with a manual header.

  5. The handshake is held during first login. If the client's startup timeout is the default ten or thirty seconds, the connection fails while the human is still typing a password. Set it to 300 or more.

  6. Client env does not reach manual xurl commands. CLIENT_ID and CLIENT_SECRET set in a client config apply to the bridge only. Run xurl auth oauth2 in a shell without exporting them and the browser shows "You weren't able to give access to the App".

  7. The login authorises the browser's account, not the app owner's. Connecting a brand or bot account silently authorises your personal account instead, and every post lands under the wrong name. Switch browser accounts first, or pass -u.

  8. client-not-enrolled is a packaging error, not an auth error. It means the app is not in the Pay-per-use package and Production environment. Move it in the portal rather than re-running OAuth.

  9. App-only Bearer cannot see bookmarks, Articles or "me". It is read-only and user-less. Any tool that needs identity fails, and it usually fails quietly rather than with a 401.

  10. X Chat DMs are a separate encrypted API. The MCP server's DM-adjacent billing rows exist, but the encrypted X Chat surface has its own API and encryption SDK. If the requirement is "answer customer DMs", the X MCP server is not the tool, and no amount of tool configuration will make it one.

  11. The agent must not run at the edge of the automation rules. X's automation policies still apply to any account that posts, replies or follows programmatically. MCP removes the integration friction, not the platform policy. Keep replies human-approved and rate-limited.

  12. Do not run the client with --verbose. The bridge's stdout has to stay a clean JSON-RPC channel; diagnostics go to stderr. Verbose flags corrupt the stream and produce garbled tool output that looks like a server bug.

Also read


Skip All of This — Use Cody Instead

Cody includes Twitter / X integration out of the box. Connect it once, then ask about mentions, replies, keyword conversations, post engagement, and audience signals directly from Slack, without managing API tiers or building your own proxy service.

Get started with Cody →


Related Guides


Need the model-flexible version? See: How to Connect Twitter / X to OpenClaw: Setup, Models, and Workflow Guide.