MCP cover image
See in Github
2025-04-05

使用Elizaos Agent-Twitter-Client库,用于安全Twitter客户端集成的模型上下文协议(MCP)服务器

1

Github Watches

1

Github Forks

0

Github Stars

Twitter Client MCP

A Model Context Protocol (MCP) server that provides secure access to Twitter functionality through the agent-twitter-client library.

Features

The Twitter Client MCP provides the following capabilities:

  • Profile Operations

    • Get profile information by username
    • Get the authenticated user's profile
  • Tweet Operations

    • Get a specific tweet by ID
    • Get tweets from a user
    • Send new tweets
    • Like tweets
    • Retweet tweets
  • Search Operations

    • Search for tweets
    • Search for profiles
  • Relationship Operations

    • Get followers of a user
    • Get users that a user is following
    • Follow a user

Security ⚠️

IMPORTANT: TWITTER CREDENTIAL PROTECTION

This MCP server requires Twitter credentials to operate. To protect these sensitive credentials:

  1. NEVER share your credentials
  2. NEVER run commands that display your credentials
  3. NEVER allow the LLM to execute shell commands directly without your approval

Multiple Layers of Protection

This server implements several layers of security to keep your credentials safe:

1. Credential Isolation

  • Your credentials are only loaded during initialization
  • After loading, credentials are immediately removed from environment variables
  • Credentials are never logged or transmitted to the LLM

2. Memory Protection

  • Secure memory allocation using sodium-native
  • Memory locking to prevent swapping to disk
  • Zero-out memory buffers after use

3. Access Prevention

  • Secure environment variable handling
  • Strict validation of required environment variables
  • Console output sanitization to prevent leaking secrets

Setup

  1. Clone the repository
  2. Install dependencies:
    npm install
    
  3. Build the project:
    npm run build
    

Required Environment Variables

The Twitter Client MCP requires the following environment variables:

TWITTER_USERNAME=your_username
TWITTER_PASSWORD=your_password
TWITTER_EMAIL=your_email@example.com

Optionally, you can add Twitter API v2 credentials for advanced functionality:

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

Tools

The server exposes the following MCP tools:

Tool Name Description Parameters
profileByUsername Get a Twitter profile by username username: String
myProfile Get the authenticated user's profile check: Boolean
getTweet Get a specific tweet by ID tweetId: String
getUserTweets Get tweets from a Twitter user username: String, count?: Number
sendTweet Post a new tweet text: String, inReplyToId?: String
likeTweet Like a tweet tweetId: String
retweet Retweet a tweet tweetId: String
searchTweets Search for tweets query: String, count?: Number, searchMode?: String ('top', 'latest', 'photos', 'videos')
searchProfiles Search for Twitter profiles query: String, count?: Number
getFollowers Get a list of users following a Twitter user username: String, count?: Number
getFollowing Get a list of users that a Twitter user is following username: String, count?: Number
followUser Follow a Twitter user username: String

Usage

Running Locally

# Start the server with environment variables
TWITTER_USERNAME=your_username TWITTER_PASSWORD=your_password TWITTER_EMAIL=your_email@example.com npm start

Adding to Cursor

To add this MCP server to Cursor:

  1. In Cursor, go to Settings > MCP Servers
  2. Click "Add Server"
  3. Configure the server with the following settings:
    • Name: Twitter Client MCP (or any name you prefer)
    • Type: command
    • Command: node
    • Arguments: /path/to/twitter-client-mcp/dist/index.js (replace with your actual path)
    • Environment Variables:
      • TWITTER_USERNAME: Your Twitter username
      • TWITTER_PASSWORD: Your Twitter password
      • TWITTER_EMAIL: Your Twitter email
      • Any other variables you want to set
  4. Click "Save"

Using NPX (Recommended)

You can also use npx to run the MCP server directly from GitHub:

TWITTER_USERNAME=your_username TWITTER_PASSWORD=your_password TWITTER_EMAIL=your_email@example.com npx -y github:mzkrasner/twitter-client-mcp

Using Environment Variables in Cursor Configuration

For more security and ease of use, configure Cursor via the .cursor/mcp.json file in your home directory:

{
  "mcpServers": {
    "twitter-client-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "github:mzkrasner/twitter-client-mcp"
      ],
      "env": {
        "TWITTER_USERNAME": "your_username",
        "TWITTER_PASSWORD": "your_password",
        "TWITTER_EMAIL": "your_email@example.com"
      }
    }
  }
}

Development

Important Note for Development

When developing the MCP server, use console.error() instead of console.log() for all debugging and logging statements. The MCP protocol communicates with the client via stdout, so any console.log() statements will interfere with this communication.

License

MIT

相关推荐

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • Contraband Interactive
  • Emulating Dr. Jordan B. Peterson's style in providing life advice and insights.

  • rustassistant.com
  • Your go-to expert in the Rust ecosystem, specializing in precise code interpretation, up-to-date crate version checking, and in-depth source code analysis. I offer accurate, context-aware insights for all your Rust programming questions.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • modelcontextprotocol
  • 模型上下文协议服务器

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

  • n8n-io
  • 具有本机AI功能的公平代码工作流程自动化平台。将视觉构建与自定义代码,自宿主或云相结合,400+集成。

  • ravitemer
  • 一个功能强大的Neovim插件,用于管理MCP(模型上下文协议)服务器

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

  • patruff
  • Ollama和MCP服务器之间的桥梁,使本地LLMS可以使用模型上下文协议工具

    Reviews

    3 (1)
    Avatar
    user_RPRp8pII
    2025-04-18

    I've been using the twitter-client-mcp for a while now and it has exceeded my expectations. Created by mzkrasner, this tool seamlessly integrates with Twitter, making it easy to manage my account. The interface is intuitive and user-friendly. I highly recommend it to anyone looking for a reliable Twitter client. Check it out at https://github.com/mzkrasner/twitter-client-mcp.