Skip to main content
Glama

X (Twitter) MCP Server

by Dishant27

X(Twitter)MCP 服务器

该 MCP 服务器允许客户端与 X(以前称为 Twitter)进行交互,从而实现包括发布推文、搜索内容、管理帐户和组织列表在内的综合平台操作。

快速入门

  1. 创建 X 开发者帐户并从X 开发者门户获取 API 密钥

  2. 在环境变量中设置所有必需的 API 密钥

  3. 克隆此存储库: git clone https://github.com/Dishant27/twitter-mcp.git

  4. 安装依赖项: npm install

  5. 运行服务器:

  • 使用环境变量:

TWITTER_API_KEY=your_api_key \ TWITTER_API_SECRET=your_api_secret \ TWITTER_ACCESS_TOKEN=your_access_token \ TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret \ npm start
  • 使用.env文件:

# Create a .env file with your X API keys echo "TWITTER_API_KEY=your_api_key TWITTER_API_SECRET=your_api_secret TWITTER_ACCESS_TOKEN=your_access_token TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret" > .env # Start the server npm start
  1. 与 MCP 客户端(例如 Claude)一起使用。

克劳德配置

要将此服务器与 Claude 一起使用,您需要设置 MCP 配置。以下是配置结构的示例:

{ "name": "x", "display_name": "X", "description": "X MCP allows Claude to interact with X (formerly Twitter)", "path": "path/to/twitter-mcp/dist/index.js", "startup": { "env": { "TWITTER_API_KEY": "your_api_key", "TWITTER_API_SECRET": "your_api_secret", "TWITTER_ACCESS_TOKEN": "your_access_token", "TWITTER_ACCESS_TOKEN_SECRET": "your_access_token_secret" } }, "transport": "stdio" }

将此配置保存在您的 Claude MCP 配置目录中,通常位于:

  • Windows: %APPDATA%\AnthropicClaude\mcp-servers

  • macOS: ~/Library/Application Support/AnthropicClaude/mcp-servers

  • Linux: ~/.config/AnthropicClaude/mcp-servers

特征

后期操作

  • 帖子内容(最多 280 个字符)

  • 按查询搜索帖子,可自定义结果计数

账户管理

  • 获取任何用户或经过身份验证的帐户的个人资料信息

  • 更新个人资料详细信息(姓名、简历、位置、网站网址)

  • 关注和取消关注用户

  • 列出任何用户或经过身份验证的帐户的关注者

  • 列出用户关注的帐户

列表管理

  • 创建新列表(公共或私人)

  • 获取有关特定列表的信息

  • 检索经过身份验证的用户拥有的所有列表

可用的 MCP 工具

工具名称

描述

post_tweet

将新内容发布到 X

search_tweets

在 X 上搜索内容

get_profile

获取用户或经过身份验证的帐户的个人资料信息

update_profile

更新已验证用户的个人资料

follow_user

关注用户

unfollow_user

取消关注用户

list_followers

列出用户或已验证帐户的关注者

list_following

列出用户或经过身份验证的帐户正在关注的帐户

create_list

创建新列表

get_list_info

获取有关列表的信息

get_user_lists

获取已验证用户拥有的所有列表

要求

  • Node.js 18.x 或更高版本

  • X 带有 API 密钥的开发者帐户

  • API v1 和 v2 访问

环境变量

多变的

描述

TWITTER_API_KEY

您的 API 密钥

TWITTER_API_SECRET

您的 API 秘密

TWITTER_ACCESS_TOKEN

您的访问令牌

TWITTER_ACCESS_TOKEN_SECRET

您的访问令牌秘密

存储库结构

twitter-mcp/ ├── .github/ │ └── workflows/ │ ├── publish.yml │ └── release.yml ├── code/ │ ├── account_management.py # Sample Python code for account management │ ├── post_tweet.py # Sample Python code for posting content │ └── retrieve_tweets.py # Sample Python code for retrieving content ├── src/ │ ├── index.ts # Main entry point │ ├── twitter-api.ts # X API client │ ├── formatter.ts # Response formatter │ └── types.ts # Type definitions ├── .env.example ├── .gitignore ├── Dockerfile ├── LICENSE ├── package.json ├── README.md └── tsconfig.json

执照

麻省理工学院

-
security - not tested
A
license - permissive license
-
quality - not tested

Related MCP Servers

  • A
    security
    A
    license
    A
    quality
    Server for X (Twitter) integration that provides tools for reading your timeline and engaging with tweets. Designed for use with Claude desktop.
    Last updated -
    12
    42
    MIT License
  • A
    security
    A
    license
    A
    quality
    Enables interaction with Twitter through a Model Context Protocol, allowing large language models to post tweets, search for tweets, and reply to tweets.
    Last updated -
    53
    1
    22
    MIT License
    • Apple
  • -
    security
    A
    license
    -
    quality
    A Model Context Protocol server that enables AI models and applications to interact directly with Twitter/X, providing capabilities to create posts, reply to tweets, retrieve user data, and manage account actions.
    Last updated -
    6
    11
    MIT License
  • -
    security
    F
    license
    -
    quality
    Enables complete management of X (Twitter) accounts through a single API key, supporting functions like getting tweets, searching, generating and posting replies.
    Last updated -
    2
    • Apple

View all related MCP servers

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Dishant27/twitter-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server