Twitter MCP 服务器
用于 Twitter API 集成的模型上下文协议服务器实现。
设置
- 克隆存储库
- 安装依赖项:
npm install
- 将
.env.example
复制到.env
并填写您的 Twitter API 凭据 - 构建项目:
npm run build
- 启动服务器:
npm start
环境变量
.env
中所需的 Twitter API 凭据:
可用工具
推文操作
postTweet
:发布新推文postTweetWithMedia
:发布带有媒体附件的推文getTweetById
:通过 ID 获取特定推文replyToTweet
:回复现有推文deleteTweet
:删除推文
搜索与分析
searchTweets
:搜索推文getHashtagAnalytics
:获取主题标签的分析数据
用户操作
getUserInfo
:获取用户信息getUserTimeline
:获取用户的推文getFollowers
:获取用户的关注者getFollowing
:获取用户关注的帐户
订婚
likeTweet
:喜欢一条推文unlikeTweet
:与推文不同retweet
:转发一条推文undoRetweet
:撤消转发getRetweets
:获取转发推文的用户getLikedTweets
:获取用户喜欢的推文
列表管理
createList
:创建新列表addUserToList
:将用户添加到列表removeUserFromList
:从列表中删除用户getListMembers
:获取列表成员
错误处理
所有工具都返回标准化的错误响应:
- 缺少参数:
Missing required parameter: parameter_name
- API 错误:来自 Twitter API 的错误消息
- 未找到错误:针对资源的适当“未找到”消息
响应格式
所有成功的响应都遵循以下格式:
发展
- 构建:
npm run build
- 开始:
npm start
- 观察模式:
npm run dev
状态:运行正常 响应:返回推文ID 最新测试:成功
状态:运行正常响应:返回完整的推文数据最新测试:成功
状态:运行正常响应:确认操作最新测试:成功
状态:运行正常响应:确认操作最新测试:成功
状态:运行正常 响应:返回回复推文ID 最新测试:成功
状态:运行正常 响应:完成用户资料数据 最新测试:成功
状态:运行正常响应:确认操作最新测试:成功
状态:运行正常响应:确认列表创建最新测试:成功
状态:运行正常响应:返回拥有者和成员列表最新测试:成功
状态:错误 400 错误:请求参数无效 需要修复:参数验证
状态:错误 400 错误:请求参数无效 需要修复:查询参数格式
状态:错误 400 错误:请求参数无效 需要修复:参数验证
- 错误处理:
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Tools
通过模型上下文协议实现与 Twitter 的交互,允许大型语言模型发布推文、搜索推文和回复推文。
Related Resources
Related MCP Servers
- -securityFlicense-qualityProvides AI agents with comprehensive Twitter functionality through the Model Context Protocol standard, enabling reading tweets, posting content, managing interactions, and accessing timeline data with robust error handling.Last updated -41JavaScript
- -securityAlicense-qualityA Model Context Protocol server that enables AI to interact with Twitter, allowing functions like searching tweets, comparing sentiments across accounts, and retrieving timeline content.Last updated -MIT License
- -securityAlicense-qualityA 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 -874TypeScriptMIT License
- -securityAlicense-qualityA Model Context Protocol server that enables AI agents to interact with Twitter without direct API access, supporting tweet operations, user interactions, and Grok AI integration.Last updated -52TypeScriptMIT License