Twitter交互服务器

一个基于Model Context Protocol(MCP)的服务器,提供使用agent-twitter-client库与Twitter交互的工具。

  • by takiAA
  • JavaScript
  • 本地部署
  • 26 星标
  • 更新于
在 GitHub 查看 takiAA/twitter-scraper-mcp

使用说明

推特MCP服务器

MCP(模型上下文协议)服务器,提供使用代理Twitter客户端库与Twitter交互的工具。

特性

  • getTweet:通过推特ID检索推特
  • sendTweet:在推特上发布新推文

先决条件

  • Node.js(v14或更高版本)
  • npm或纱线
  • Twitter帐户凭据

安装

  1. 克隆此存储库
  2. 安装依赖项:
npm install
# or
yarn install
  1. 创建一个 .env 根目录中的文件,其中包含您的Twitter凭据:
TWITTER_USERNAME=your_twitter_username
TWITTER_PASSWORD=your_twitter_password
TWITTER_EMAIL=your_email@example.com (optional)
TWITTER_2FA_SECRET=your_2fa_secret (optional)

# Optional API credentials (used as fallback)
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

用法

运行服务器

您可以使用FastMCP CLI工具运行服务器:

# For development and testing in the terminal
npx fastmcp dev

# For visual inspection with the MCP Inspector
npx fastmcp inspect

使用工具

getTweet

通过推特ID检索推特。

参数:

  • tweetId (string):要检索的推文的ID

例子:

getTweet({"tweetId": "1734609533274853865"})

sendTweet

在推特上发布一条新推文。

参数:

  • text (string):要发送的推文的文本内容

例子:

sendTweet({"text": "Hello World from MCP!"})

发展

此服务器是使用以下方式构建的:

要构建TypeScript代码:

npx tsc

许可证

麻省理工学院