The X MCP Server requires API keys and tokens for either OAuth 1.0a or OAuth 2.0 authentication. Follow the relevant steps below to obtain the necessary environment variable (ENV) values. After acquiring the values, fill them in through the FastMCP connection interface using your "Install Now" button.
For OAuth 1.0a
Log in to the X Developer Portal
Create a New App
- Navigate to the Developer Portal Dashboard.
- Click "Projects & Apps" → "New Project".
- Name your project and select your use case.
- Within the project, create a new App.
Configure App Permissions
- In your new App, find "User authentication settings".
- Click "Set up".
- Enable OAuth 1.0a.
- Set permissions to "Read and Write".
- Add a Callback URL:
http://localhost:3000/callback
.
- Set any website URL (e.g., a GitHub repo).
Generate API Keys and Tokens
- In the "Keys and tokens" tab, copy your:
- Scroll down to "Access Token and Secret", and click "Generate".
- Copy your:
- Access Token
- Access Token Secret
Fill in the FastMCP Connection Interface
- After clicking "Install Now", fill in the required values:
API_KEY
: [your API Key]
API_SECRET_KEY
: [your API Secret Key]
ACCESS_TOKEN
: [your Access Token]
ACCESS_TOKEN_SECRET
: [your Access Token Secret]
For OAuth 2.0
Log in to the X Developer Portal
Create a New App
- Follow steps as above to set up a new app in the Developer Portal.
Configure App Permissions for OAuth 2.0
- In "User authentication settings", enable OAuth 2.0.
- Set permissions to at least:
tweet.read
, tweet.write
, users.read
, media.write
, offline.access
(required scopes).
- Add a Callback URL:
http://localhost:3000/callback
.
Obtain OAuth 2.0 Credentials
- In the "Keys and tokens" tab, copy your:
- OAuth 2.0 Client ID
- OAuth 2.0 Client Secret
Generate User Tokens
Clone the MCP server repository:
git clone https://github.com/mbelinky/x-mcp-server.git
cd x-mcp-server/twitter-mcp
npm install
# Run the OAuth2 setup script
node scripts/oauth2-setup.js
Follow the instructions from the script to authenticate and retrieve:
- Access Token
- Refresh Token
Alternative: Manually complete the OAuth 2.0 PKCE authentication flow using the credentials and required scopes, then exchange the authorization code for your tokens.
Fill in the FastMCP Connection Interface
- After clicking "Install Now", fill in the required values:
AUTH_TYPE
: oauth2
OAUTH2_CLIENT_ID
: [your client ID]
OAUTH2_CLIENT_SECRET
: [your client secret]
OAUTH2_ACCESS_TOKEN
: [your OAuth2 access token]
OAUTH2_REFRESH_TOKEN
: [your OAuth2 refresh token]
Note: All credentials should be entered through the FastMCP connection interface after clicking your "Install Now" button. Do not share these credentials publicly.