home / mcp / twitter mcp server

Twitter MCP Server

A Model Context Protocol server allows to interact with Twitter, enabling posting tweets and searching Twitter.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "enescinr-twitter-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@enescinar/twitter-mcp"
      ],
      "env": {
        "API_KEY": "your_api_key_here",
        "ACCESS_TOKEN": "your_access_token_here",
        "API_SECRET_KEY": "your_api_secret_key_here",
        "ACCESS_TOKEN_SECRET": "your_access_token_secret_here"
      }
    }
  }
}

You can connect your applications or assistants to Twitter through this MCP Server, letting you post tweets and search tweets directly from your client. It exposes two practical actions: posting new tweets and querying Twitter content, enabling conversational workflows and automation.

How to use

You interact with this MCP Server from an MCP client by calling its two available tools: post_tweet and search_tweets. Use post_tweet to publish a new tweet and search_tweets to look up tweets based on keywords, hashtags, or user mentions. Provide the content you want to tweet or the search query as part of your request to the client. The MCP Server handles authentication with Twitter using your API keys and forwards your requests to Twitter on your behalf.

Typical usage patterns include composing a tweet like “Hello from your assistant!” using post_tweet, or querying recent tweets about a topic using search_tweets. You can combine these tools into longer interaction flows, such as monitoring a topic and replying with a tweet when a threshold is met.

How to install

Prerequisites you need before enabling the MCP server: Node.js and npm (npm provides npx), and a Twitter Developer account with API keys.

Create your Twitter Developer keys in the Twitter Developer Portal. You will need the API key, API secret key, Access token, and Access token secret.

Add the MCP server configuration to your client configuration. The following snippet shows the exact structure to enable the server via npx. Place it in your client’s MCP configuration file.

{
  "mcpServers": {
    "twitter-mcp": {
      "command": "npx",
      "args": ["-y", "@enescinar/twitter-mcp"],
      "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"
      }
    }
  }
}

Notes and steps to run

Restart your client after adding the MCP server configuration. The server will be available as twitter-mcp under your MCP client, and you can start issuing post_tweet and search_tweets commands immediately.

Troubleshooting

If you encounter issues, check the logs for the MCP server. Common locations include the client’s log directory for MCP-related logs. Review any authentication errors from Twitter and verify that your API keys are correctly set in the environment section of the MCP config.

Development notes

If you want to experiment with or extend the server locally, you can install dependencies with npm, build if necessary, and run the server. The typical flow uses npm to install, build, and start the local MCP server when running from source.

Available tools

post_tweet

Post a new tweet to Twitter with the provided text content.

search_tweets

Search Twitter for tweets matching a given query and return results.