Twitter MCP Server

by taazkareem
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Supported as a platform for the MCP server, with specific configuration paths provided for macOS users.

  • Used for package management and running server scripts, facilitating installation and development workflows.

  • The server uses TypeScript for its response format, providing strongly typed structure for communication between the client and server.

Twitter MCP 服务器

为 AI 代理提供强大的 Twitter 集成,利用模型上下文协议 (MCP) 标准,通过干净一致的界面提供全面的 Twitter 功能。

概述

该服务器通过 MCP 工具提供对 Twitter 功能的访问,从而实现与 AI 助手和其他兼容 MCP 的客户端的无缝集成。它基于agent-twitter-client库构建,并提供强大的错误处理、速率限制和一致的响应格式。

特征

基础阅读

  • 获取具有媒体支持的用户的推文
  • 获取包含详细信息的用户资料
  • 通过主题标签或关键词搜索推文
  • 按最新/热门筛选搜索结果
  • 速率限制(每个请求最多 50 条推文)

用户交互

  • 喜欢/不喜欢推文
  • 转发/撤销转发
  • 发布推文:
    • 文本内容
    • 媒体附件(图片、视频)
    • 回复功能
    • 引用推文功能

高级功能

  • 获取用户关系(关注者/关注者)
  • 获取热门话题
  • 访问不同的时间线类型:
    • 主页时间线
    • 遵循时间线
    • 用户时间线
  • 列表管理(获取列表推文)

媒体与高级交互

  • 媒体处理:
    • 图像上传(JPEG、PNG、GIF)
    • 视频上传 (MP4)
    • 替代文本支持
  • 线程创建
  • 关注/取消关注用户

工具

阅读工具

  • get_tweets - 获取用户最近的推文
  • get_profile获取用户的个人资料信息
  • search_tweets - 通过标签或关键词搜索推文

交互工具

  • like_tweet - 喜欢或不喜欢一条推文
  • retweet - 转发或撤消转发
  • post_tweet - 发布带有可选媒体的新推文
  • create_thread - 创建 Twitter 线程

时间线工具

  • get_timeline - 从不同的时间线类型获取推文
  • get_list_tweets - 从 Twitter 列表中获取推文
  • get_trends - 获取当前热门话题

用户管理工具

  • get_user_relationships - 获取关注者或关注者列表
  • follow_user - 关注或取消关注用户

安装

  1. 安装依赖项:
npm install
  1. 构建服务器:
npm run build
  1. 配置环境变量:
# Required: Twitter Account Credentials (for user authentication) TWITTER_USERNAME=your_username TWITTER_PASSWORD=your_password TWITTER_EMAIL=your_email # Twitter API Authentication (Optional) TWITTER_API_KEY=your_api_key TWITTER_API_SECRET_KEY=your_api_secret_key TWITTER_ACCESS_TOKEN=your_access_token TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret
  1. 将服务器配置添加到您的 MCP 客户端:

在 MacOS 上:

~/Library/Application Support/Claude/claude_desktop_config.json

在 Windows 上:

%APPDATA%/Claude/claude_desktop_config.json

配置:

{ "mcpServers": { "twitter-mcp-server": { "command": "/path/to/twitter-mcp-server/build/index.js" } } }

发展

对于使用自动重建的开发:

npm run watch

调试

由于 MCP 服务器通过 stdio 进行通信,因此您可以使用 MCP Inspector 进行调试:

npm run inspector

检查器将提供一个 URL 来访问浏览器中的调试工具。

错误处理

服务器实现了全面的错误处理:

  • 所有参数的输入验证
  • 速率限制保护
  • 详细错误消息
  • 适当的错误传播
  • 用于调试的日志记录

响应格式

所有工具都以一致的格式返回响应:

{ content: [{ type: "text", text: string // JSON stringified response or error message }] }

贡献

欢迎贡献代码!欢迎提交 Pull 请求。

执照

MIT 许可证 - 详情请参阅许可证文件

-
security - not tested
F
license - not found
-
quality - not tested

通过模型上下文协议标准为 AI 代理提供全面的 Twitter 功能,支持阅读推文、发布内容、管理交互以及访问时间线数据,并具有强大的错误处理功能。

  1. Overview
    1. Features
      1. Basic Reading
      2. User Interactions
      3. Advanced Features
      4. Media & Advanced Interactions
    2. Tools
      1. Reading Tools
      2. Interaction Tools
      3. Timeline Tools
      4. User Management Tools
    3. Installation
      1. Development
        1. Debugging
      2. Error Handling
        1. Response Format
          1. Contributing
            1. License
              ID: qep2xkblkw