Hosted MCP server
Connect Claude, ChatGPT, Claude Code, Cursor or VS Code to TwittrAPI by URL. Nothing to install; sign in with your TwittrAPI account (OAuth) or send your API key in a header.
The hosted MCP server gives AI apps the tools of the twittrapi-mcp package without installing anything: profiles, tweets, followers, search, lists, communities and trends, and, once you add your X session, posting, likes, follows and DMs on your own account (see Account tools):
https://mcp.twittrapi.com/mcpUse the URL exactly like this, with /mcp at the end. https://mcp.twittrapi.com on its own is not the MCP endpoint; apps report "404 Not found" or cannot find the sign-in for it.
It speaks MCP over Streamable HTTP. Every tool call is one billed API call on your TwittrAPI balance, at your normal price and rate limit. Results use the simple format by default.
There are two ways to sign in:
| How | For | |
|---|---|---|
| OAuth | The app opens a TwittrAPI page, you log in and click Allow access. The app never sees your API key. | Claude.ai, Claude Desktop, ChatGPT, Claude Code, VS Code |
| API key header | The app sends Authorization: Bearer YOUR_API_KEY or X-API-KEY: YOUR_API_KEY on every request. | Cursor, Claude Code, scripts, any client that lets you set headers |
Claude.ai and Claude Desktop
- Open Customize > Connectors, click Add and choose Add custom connector. On Team and Enterprise plans an owner adds it under the organization's connector settings first.
- Name:
TwittrAPI, URL:https://mcp.twittrapi.com/mcp(with/mcpat the end). Click Continue. Claude detects the sign-in by itself, so leave the next step as it is and click Add. - On the connector's page, click Connect. Log in to your TwittrAPI account and click Allow access.
Claude Desktop uses the connectors of your Claude account, so the connector shows up there too.
ChatGPT
- Open Settings > Apps & Connectors > Advanced settings and turn on Developer mode (available on the plans that offer custom connectors).
- Choose Create, enter the name
TwittrAPI, the MCP server URLhttps://mcp.twittrapi.com/mcpand authentication OAuth. - Log in to your TwittrAPI account and click Allow access.
Claude Code
With OAuth (Claude Code opens the browser when you authenticate in /mcp):
claude mcp add --transport http twittrapi https://mcp.twittrapi.com/mcpWith your API key instead:
claude mcp add --transport http twittrapi https://mcp.twittrapi.com/mcp \
--header "Authorization: Bearer $TWITTRAPI_API_KEY"Cursor
Add this to ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (one project). Cursor reads the key from your environment:
{
"mcpServers": {
"twittrapi": {
"url": "https://mcp.twittrapi.com/mcp",
"headers": { "X-API-KEY": "${env:TWITTRAPI_API_KEY}" }
}
}
}VS Code (GitHub Copilot agent mode)
Add .vscode/mcp.json to the workspace. VS Code signs you in with OAuth when the server starts:
{
"servers": {
"twittrapi": {
"type": "http",
"url": "https://mcp.twittrapi.com/mcp"
}
}
}To use your API key instead, add an input so the key is not stored in the file:
{
"inputs": [
{ "type": "promptString", "id": "twittrapi-key", "description": "TwittrAPI API key", "password": true }
],
"servers": {
"twittrapi": {
"type": "http",
"url": "https://mcp.twittrapi.com/mcp",
"headers": { "X-API-KEY": "${input:twittrapi-key}" }
}
}
}Other clients
Any MCP client with Streamable HTTP support works. Send JSON-RPC as POST to https://mcp.twittrapi.com/mcp with your key in X-API-KEY or Authorization: Bearer. The server is stateless: there are no sessions and no server-sent event stream (GET returns 405), and the old SSE transport is not offered. Clients that only support stdio can use the npm package instead (npx -y twittrapi-mcp).
Account tools: post, like, DM
Without more setup the server only reads public X data. To let the assistant act on your own X account, give it your X session: the cookie of a browser that is logged in to x.com and your own proxy. The assistant then also gets these tools:
| What | Tools |
|---|---|
| Post | create_tweet, reply_to_tweet, delete_tweet, create_draft, list_drafts |
| Engage | like_tweet, unlike_tweet, retweet, unretweet, bookmark_tweet, unbookmark_tweet, follow_user, unfollow_user |
| Direct messages | list_dm_conversations, send_dm, list_dm_requests, accept_dm_request, decline_dm_request |
| Lists and bookmarks | create_list, add_list_member, remove_list_member, list_bookmark_folders, list_bookmark_folder_tweets, search_bookmarks, list_community_memberships |
| Articles | list_articles, get_article, create_article, update_article, publish_article, unpublish_article, delete_article |
Each one is one billed call, like a read. Trial keys cannot use them; they work after your first top-up. The tools are marked as changing your account, so apps like Claude and ChatGPT ask you before one runs and you see the tweet before it goes out.
There are two ways to give the server your session. Pick the one your app supports:
| How | For | |
|---|---|---|
| Saved in the dashboard | You save the session once under Connected apps, then tick Also act on my X account when you connect an app. | Claude.ai, Claude Desktop, ChatGPT, and every app that signs in with OAuth |
| Headers | The app sends the session in X-Twitter-Cookie and X-Twitter-Proxy on every request. Nothing is stored. | Claude Code, Cursor, VS Code, scripts |
Saved in the dashboard (Claude.ai, ChatGPT)
- Log in to x.com in your browser and copy the cookie as described in Your X session. The JSON export of a cookie extension works too.
- Open Connected apps in the dashboard and click Add X account. Paste the cookie, enter your proxy (
http://user:pass@host:portorhost:port:user:pass) and, for DMs, your X Chat passcode. Click Save and check. The account then shows up with its @handle and whether X accepted the session. - Connect the app as described above (Claude.ai, ChatGPT). On the TwittrAPI consent page, tick Also act on my X account and click Allow access.
An app you already connected before saving a session only has read access. Remove the connector in the app and add it again, then tick the box. Connected apps shows which apps may act on your accounts.
Sessions are stored encrypted and only sent to the MCP server for apps you allowed to act. Delete removes one at once. After you logged out of x.com, add the account again with a fresh cookie: it replaces the old session.
Several X accounts
You can save up to 200 X accounts, one by one or with Bulk import (lines, CSV or Cookie-Editor JSON files). The assistant uses the default account unless you name another one: "Post this from @acme_support". See X accounts for AI apps for the formats, choosing an account and what each status means.
Headers (Claude Code, Cursor, VS Code)
Send the session along with your API key. Claude Code:
claude mcp add --transport http twittrapi https://mcp.twittrapi.com/mcp \
--header "Authorization: Bearer $TWITTRAPI_API_KEY" \
--header "X-Twitter-Cookie: $TWITTRAPI_X_COOKIE" \
--header "X-Twitter-Proxy: $TWITTRAPI_X_PROXY"Cursor (~/.cursor/mcp.json), with the values in your environment:
{
"mcpServers": {
"twittrapi": {
"url": "https://mcp.twittrapi.com/mcp",
"headers": {
"X-API-KEY": "${env:TWITTRAPI_API_KEY}",
"X-Twitter-Cookie": "${env:TWITTRAPI_X_COOKIE}",
"X-Twitter-Proxy": "${env:TWITTRAPI_X_PROXY}"
}
}
}
}VS Code (.vscode/mcp.json), with inputs so nothing is stored in the file:
{
"inputs": [
{ "type": "promptString", "id": "twittrapi-key", "description": "TwittrAPI API key", "password": true },
{ "type": "promptString", "id": "x-cookie", "description": "X cookie (auth_token=...; ct0=...; twid=...)", "password": true },
{ "type": "promptString", "id": "x-proxy", "description": "Proxy (http://user:pass@host:port)", "password": true }
],
"servers": {
"twittrapi": {
"type": "http",
"url": "https://mcp.twittrapi.com/mcp",
"headers": {
"X-API-KEY": "${input:twittrapi-key}",
"X-Twitter-Cookie": "${input:x-cookie}",
"X-Twitter-Proxy": "${input:x-proxy}"
}
}
}
}| Header | Value |
|---|---|
X-Twitter-Cookie | auth_token=...; ct0=...; twid=u%3D... (how to copy it) |
X-Twitter-Proxy | http://user:pass@host:port (which proxy) |
X-Twitter-Chat-Passcode | Optional. Your X Chat passcode, needed for DMs. |
Send cookie and proxy together, or neither. The headers also work with an OAuth sign-in and then win over a session saved in the dashboard. The server uses them for that one request and does not store them.
Direct messages
X encrypts newer chats. To send a DM or to accept or decline a message request, the server needs your X Chat passcode: save it in the dashboard or send it in X-Twitter-Chat-Passcode. Reading the list of conversations works without it.
Keep your account safe
- Anyone with the cookie can use your X account. Only put it into apps and config files you control, and never commit it.
- Use a dedicated account rather than your main one. X can limit accounts that post, follow or like automatically.
- If the assistant reports that the session may be logged out (X answers 401 or 403), log in to x.com again and save or send the new cookie. If it reports a proxy error (407), check the proxy's user and password.
What you approve, and how to disconnect
The consent page shows the app's name as the app registered it, the address the app receives the sign-in at, and that its calls are billed to your balance. If you saved an X session, it also offers Also act on my X account; leave it unticked to give the app read access only. Only continue if you started the connection yourself.
- Your apps are listed under Connected apps in the dashboard, with when they were connected and last used. Disconnect ends an app's access within a minute.
- Regenerating your API key disconnects every app. Reconnect them afterwards.
- Access tokens last one hour and are renewed by the app with a refresh token, which works once and expires after 30 days without use.
- The server only accepts tokens issued for it. Apps can register themselves (OAuth dynamic client registration) and must use PKCE; sign-in addresses must be
httpsor a local address on your own computer.
Limits and errors
- The same rate limit as your key applies, plus at most 8 requests in flight per key on the MCP server.
- A request may take up to 90 seconds and carry up to 256 KB.
- Tool errors come back as readable tool results: 402 means the balance is used up (top up, do not retry), 429 means slow down. Details: Errors.
Troubleshooting
| Message | Fix |
|---|---|
| "Connecting to the server: 404 Not found" or "Couldn't determine how this server signs in" | The URL is missing /mcp. Remove the connector and add it again with https://mcp.twittrapi.com/mcp. Do not continue with manual configuration. |
| The login page says "Could not reach the server" | Reload the login page and log in again. |
| The app says it is not authorized after it worked before | The app was disconnected or your API key was regenerated. Remove the connector and connect it again. |
| The assistant cannot post, like or send DMs | The app was connected without Also act on my X account, or no X session is saved. Save the session under Connected apps, then remove the connector and connect it again with the box ticked. With headers: send both X-Twitter-Cookie and X-Twitter-Proxy. |
| "X session may be logged out" | Log in to x.com again, copy the new cookie and replace the saved session (or update the header). |
To run your own instance (for example inside a company network), see "HTTP mode" in the twittrapi-mcp README.