这是一个通过 agent-twitter-client 库提供对 Twitter 功能安全访问的模型上下文协议(MCP)服务器。
Twitter 客户端 MCP 提供以下功能:
用户资料操作
推文操作
搜索操作
关系操作
重要提示:保护 Twitter 凭证
此 MCP 服务器需要 Twitter 凭证才能运行。为了保护这些敏感凭证:
此服务器实现了多层安全措施以确保您的凭证安全:
npm install
npm run build
Twitter 客户端 MCP 需要以下环境变量:
TWITTER_USERNAME=your_username
TWITTER_PASSWORD=your_password
TWITTER_EMAIL=your_email@example.com
可选地,您可以添加 Twitter API v2 凭证以实现高级功能:
TWITTER_API_KEY=your_api_key
TWITTER_API_SECRET_KEY=your_api_secret
TWITTER_ACCESS_TOKEN=your_access_token
TWITTER_ACCESS_TOKEN_SECRET=your_access_secret
服务器公开了以下 MCP 工具:
| 工具名称 | 描述 | 参数 |
|---|---|---|
profileByUsername | 根据用户名获取 Twitter 用户资料 | username: 字符串 |
myProfile | 获取已认证用户的资料 | check: 布尔值 |
getTweet | 根据ID获取特定推文 | tweetId: 字符串 |
getUserTweets | 获取 Twitter 用户的推文 | username: 字符串, count?: 数字 |
sendTweet | 发布新的推文 | text: 字符串, inReplyToId?: 字符串 |
likeTweet | 喜欢推文 | tweetId: 字符串 |
retweet | 转发推文 | tweetId: 字符串 |
searchTweets | 搜索推文 | query: 字符串, count?: 数字, searchMode?: 字符串 ('top', 'latest', 'photos', 'videos') |
searchProfiles | 搜索 Twitter 用户资料 | query: 字符串, count?: 数字 |
getFollowers | 获取跟随某 Twitter 用户的用户列表 | username: 字符串, count?: 数字 |
getFollowing | 获取某 Twitter 用户正在关注的用户列表 | username: 字符串, count?: 数字 |
followUser | 关注 Twitter 用户 | username: 字符串 |
# 使用环境变量启动服务器
TWITTER_USERNAME=your_username TWITTER_PASSWORD=your_password TWITTER_EMAIL=your_email@example.com npm start
要将此 MCP 服务器添加到 Cursor:
Twitter 客户端 MCP(或您喜欢的任何名称)commandnode/path/to/twitter-client-mcp/dist/index.js(替换为您实际的路径)TWITTER_USERNAME:您的 Twitter 用户名TWITTER_PASSWORD:您的 Twitter 密码TWITTER_EMAIL:您的 Twitter 邮件地址您也可以使用 npx 直接从 GitHub 运行 MCP 服务器:
TWITTER_USERNAME=your_username TWITTER_PASSWORD=your_password TWITTER_EMAIL=your_email@example.com npx -y github:mzkrasner/twitter-client-mcp
为了更安全和方便的使用,通过您的主目录中的 .cursor/mcp.json 文件配置 Cursor:
{
"mcpServers": {
"twitter-client-mcp": {
"command": "npx",
"args": [
"-y",
"github:mzkrasner/twitter-client-m
- mcp"
],
"env": {
"TWITTER_USERNAME": "your_username",
"TWITTER_PASSWORD": "your_password",
"TWITTER_EMAIL": "your_email@example.com"
}
}
}
}
在开发 MCP 服务器时,请使用 console.error() 而不是 console.log() 来进行所有调试和日志记录语句。MCP 协议通过标准输出与客户端通信,因此任何 console.log() 语句都会干扰这种通信。
MIT