Get the FREE Ultimate OpenClaw Setup Guide →

x

A comprehensive mcp server to post on x.com, with oauth v1 and v2, as well as v1.1 and v2 x API implementation

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio mbelinky-x-mcp-server npx -y @mbelinky/x-mcp-server \
  --env API_KEY="your_api_key_here" \
  --env AUTH_TYPE="oauth1_or_oauth2" \
  --env ACCESS_TOKEN="your_access_token_here" \
  --env API_SECRET_KEY="your_api_secret_key_here" \
  --env OAUTH2_CLIENT_ID="your_client_id_here" \
  --env ACCESS_TOKEN_SECRET="your_access_token_secret_here" \
  --env OAUTH2_ACCESS_TOKEN="your_access_token_here" \
  --env OAUTH2_CLIENT_SECRET="your_client_secret_here" \
  --env OAUTH2_REFRESH_TOKEN="your_refresh_token_here"

How to use

This MCP server, @mbelinky/x-mcp-server, provides an enhanced X (Twitter) integration with dual authentication (OAuth 1.0a and OAuth 2.0), media uploads, and rate limiting. It exposes tools to post tweets (with optional media), search tweets, and delete tweets programmatically. Depending on the authentication method and operation, the server switches between v1.1 and v2 X API endpoints to maximize compatibility and features. You can use the available tools to compose posts, fetch tweet results, and manage content from automated workflows or chat-assisted prompts.

How to install

Prerequisites:

  • Node.js 18+ and npm/yarn installed
  • Access to an X Developer account and configured app credentials (OAuth 1.0a or OAuth 2.0)

Install from npm:

  1. Ensure you have a project folder
  2. Install the MCP server package in your project or globally:
npm install -g @mbelinky/x-mcp-server

Configure credentials (example environment file):

# .env
API_KEY=your_api_key_here
API_SECRET_KEY=your_api_secret_key_here
ACCESS_TOKEN=your_access_token_here
ACCESS_TOKEN_SECRET=your_access_token_secret_here
AUTH_TYPE=oauth1
OAUTH2_CLIENT_ID=your_client_id_here
OAUTH2_CLIENT_SECRET=your_client_secret_here
OAUTH2_ACCESS_TOKEN=your_access_token_here
OAUTH2_REFRESH_TOKEN=your_refresh_token_here

Run the server directly with npx (as shown in mcp_config):

npx -y @mbelinky/x-mcp-server

Alternatively, install locally and run build/index.js if you clone the repo:

git clone https://github.com/mbelinky/x-mcp-server.git
cd x-mcp-server/twitter-mcp
npm install
npm run build
node build/index.js

Note: The exact command may vary if you integrate into a launcher like Claude with a JSON config; use the mcp_config block as the canonical runtime configuration.

Additional notes

Tips and caveats:

  • If you mix OAuth 1.0a and OAuth 2.0, clearly separate credentials in your environment to avoid cross-contamination.
  • Media uploads with OAuth 2.0 must use v2 endpoints; OAuth 1.0a can fall back to v1.1 for certain media or delete operations.
  • For delete operations, expect occasional 500 errors with v2; the server’s fallback to v1.1 is intentional to increase reliability.
  • Ensure the callback URLs in your X App settings are properly configured to match your local or deployed environment (e.g., http://localhost:3000/callback).
  • Rate limiting is built in; monitor quotas to avoid hitting API limits during automated posting or mass searches.
  • When posting media, prefer providing file paths over base64-encoded content for reliability with Claude and other clients.

Related MCP Servers

Sponsor this space

Reach thousands of developers