mcpField
T
Twitter MCP Server

Twitter MCP Server

ローカル
github.com/gkydevソーシャルメディア1621 週間前に更新

Twitter MCP Server について

Twitter MCP Serverはtwikitを使った非公式のTwitter/X連携サーバーで、MCP経由でソーシャルアカウントを操作したい人向けです。Cookie認証に対応し、ツイート、ユーザー、トレンド、ダイレクトメッセージを扱います。

主な機能

  1. 01Cookie認証とセッションキャッシュ
  2. 02タイムライン、プロフィール、ツイートの取得
  3. 03ツイートの検索、投稿、いいね、リツイート
  4. 04ユーザーのフォローとトレンドの取得
  5. 05ダイレクトメッセージの送受信と管理

活用シーン

  1. 01ツイート検索とユーザー動向の確認
  2. 02ツイートの投稿やリアクション
  3. 03トレンドトピックの確認
  4. 04ダイレクトメッセージの送信と会話管理

MCP 対応

Twitter/Xのツイート、ユーザー、トレンド、ダイレクトメッセージ操作をMCPツールとして公開します。呼び出しにはct0とauth_tokenのCookieが必要です。

設定

ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。

インストール方法は未掲載です

このサーバーのパッケージやリモートエンドポイントはまだ取得できていません。プロジェクトの README の手順に従ってください。

リポジトリ

ツール

ツール一覧はまだ取得されていません

ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。

詳細

Twitter MCP サーバー

twikit ライブラリを使用して Twitter の機能を提供する Model Context Protocol(MCP)サーバーです。このサーバーを使うと、Cookie ベースの認証により、AI アシスタントが標準化されたプロトコルを通じて Twitter を操作できます。LLM モデルはツール呼び出しで ct0 と auth_token の Cookie を直接指定します。

機能

  • Cookie 認証:LLM モデルはツール呼び出しで ct0 と auth_token の Cookie を直接指定します
  • セッションキャッシュ:認証済みセッションを自動的にキャッシュし、効率化します
  • タイムラインへのアクセス:タイムラインからツイートを取得します
  • ユーザー情報:ユーザープロフィールや統計情報を取得します
  • ツイート検索:指定したクエリでツイートを検索します
  • ツイート管理:ツイートの投稿、いいね、リツイートを行います
  • ユーザーのツイート:特定のユーザーのツイートを取得します
  • ダイレクトメッセージ:DM の送信、DM 履歴の取得、メッセージへのリアクション、メッセージの削除を行います
  • 認証テスト:使用前に Cookie をテストします
  • ツイート操作:ツイートの投稿、いいね/いいね解除、リツイート/リツイート解除、ツイートのブックマークを行います
  • ツイートの取得:ID によるツイートの取得、ツイートの検索、ユーザーのタイムラインの取得、ツイートへの返信の取得を行います
  • ユーザー操作:ユーザーのフォロー/フォロー解除、ユーザー情報の取得、ユーザー検索を行います
  • トレンドトピック:さまざまなカテゴリ(トレンド、ニュース、スポーツ、エンターテインメント、おすすめ)のトレンドトピックを取得します

免責事項

このプロジェクトは、twikit ライブラリを通じて X(旧 Twitter)を操作するために、非公式 API を利用しています。認証とデータ取得に使用する方法は X/Twitter によって公式に承認されたものではなく、予告なく変更または提供終了となる場合があります。

このツールは、教育および実験のみを目的としています。ユーザーは、アカウントの制限や凍結など、非公式 API の使用に伴う潜在的なリスクを認識する必要があります。このプロジェクトの開発者は、ツールの誤用や使用によって生じるいかなる結果についても責任を負いません。

インストール

  1. このリポジトリをクローンします:
git clone <repository-url>
cd twitter-mcp
  1. 依存関係をインストールします:
pip install -r requirements.txt
  1. サーバーを起動します:
python server.py

認証

このサーバーでは、LLM モデルが各ツール呼び出しで ct0 と auth_token パラメーターを使って Twitter の Cookie を直接指定する必要があります。事前設定は不要です!

Twitter Cookie の取得

LLM モデルは Twitter の Cookie を両方とも指定する必要があります。取得方法は次のとおりです。

  1. ブラウザーを開き、Twitter/X にアクセスします
  2. アカウントにログインします
  3. 開発者ツールを開きます(F12)
  4. Application/Storage → Cookies → twitter.com(または x.com)に移動します
  5. 次の Cookie 値を見つけてコピーします:
    • ct0 - CSRF トークン Cookie
    • auth_token - 認証トークン Cookie

すべての操作で両方の Cookie が必要です。

使用方法

利用可能なツール
1. 認証

Cookie を使って認証をテストします:

{
  "tool": "authenticate",
  "arguments": {
    "ct0": "your_ct0_cookie_here",
    "auth_token": "your_auth_token_cookie_here"
  }
}
2. ツイート

新しいツイートを投稿します:

{
  "tool": "tweet",
  "arguments": {
    "text": "Hello from MCP! 🚀",
    "ct0": "your_ct0_cookie_here",
    "auth_token": "your_auth_token_cookie_here"
  }
}
3. ユーザー情報の取得

Twitter ユーザーの情報を取得します:

{
  "tool": "get_user_info",
  "arguments": {
    "username": "elonmusk",
    "ct0": "your_ct0_cookie_here",
    "auth_token": "your_auth_token_cookie_here"
  }
}
4. ツイートの検索

ツイートを検索します:

{
  "tool": "search_tweets",
  "arguments": {
    "query": "artificial intelligence",
    "count": 10,
    "ct0": "your_ct0_cookie_here",
    "auth_token": "your_auth_token_cookie_here"
  }
}
5. タイムラインの取得

タイムラインからツイートを取得します:

{
  "tool": "get_timeline",
  "arguments": {
    "count": 20,
    "ct0": "your_ct0_cookie_here",
    "auth_token": "your_auth_token_cookie_here"
  }
}
6. ツイートにいいね

ID で指定したツイートにいいねします:

{
  "tool": "like_tweet",
  "arguments": {
    "tweet_id": "1234567890123456789",
    "ct0": "your_ct0_cookie_here",
    "auth_token": "your_auth_token_cookie_here"
  }
}
7. リツイート

ID で指定したツイートをリツイートします:

{
  "tool": "retweet",
  "arguments": {
    "tweet_id": "1234567890123456789",
    "ct0": "your_ct0_cookie_here",
    "auth_token": "your_auth_token_cookie_here"
  }
}
8. ダイレクトメッセージの送信

ユーザーにダイレクトメッセージを送信します。

パラメーター:

  • recipient_username(string):メッセージの送信先のユーザー名(@ を除く。内部で自動的に user_id に変換されます)
  • text(string):メッセージの内容
  • ct0(string):Twitter の ct0 Cookie
  • auth_token(string):Twitter の auth_token Cookie
{
  "name": "send_dm",
  "arguments": {
    "recipient_username": "username",
    "text": "Hello from MCP!",
    "ct0": "your_ct0_token",
    "auth_token": "your_auth_token"
  }
}
9. DM 履歴の取得

特定のユーザーとのダイレクトメッセージ履歴を取得します。

パラメーター:

  • recipient_username(string):DM 履歴を取得する相手のユーザー名(@ を除く。内部で自動的に user_id に変換されます)
  • count(integer、任意):取得するメッセージ数(デフォルト:20、最大:100)
  • ct0(string):Twitter の ct0 Cookie
  • auth_token(string):Twitter の auth_token Cookie
{
  "name": "get_dm_history", 
  "arguments": {
    "recipient_username": "username",
    "count": 50,
    "ct0": "your_ct0_token",
    "auth_token": "your_auth_token"
  }
}
10. ダイレクトメッセージにリアクションする

ダイレクトメッセージに絵文字でリアクションします。

パラメーター:

  • message_id (string):リアクションするメッセージの ID
  • emoji (string):追加する絵文字(例:"👍"、"❤️"、"😀")
  • conversation_id (string):メッセージが含まれる会話の ID
  • ct0 (string):Twitter の ct0 Cookie
  • auth_token (string):Twitter の auth_token Cookie
{
  "name": "add_reaction_to_message",
  "arguments": {
    "message_id": "message_id_here", 
    "emoji": "👍",
    "conversation_id": "conversation_id_here",
    "ct0": "your_ct0_token",
    "auth_token": "your_auth_token"
  }
}
11. ダイレクトメッセージを削除する

ダイレクトメッセージを削除します。

{
  "tool": "delete_dm",
  "arguments": {
    "message_id": "1234567890123456789",
    "ct0": "your_ct0_cookie_here",
    "auth_token": "your_auth_token_cookie_here"
  }
}
get_tweet_replies

特定のツイートへの返信を取得します。

パラメーター:

  • tweet_id (string):返信を取得するツイートの ID
  • count (integer, optional):取得する返信の数(デフォルト:20)
  • ct0 (string):Twitter の ct0 Cookie
  • auth_token (string):Twitter の auth_token Cookie
{
  "name": "get_tweet_replies",
  "arguments": {
    "tweet_id": "1234567890",
    "count": 10,
    "ct0": "your_ct0_token",
    "auth_token": "your_auth_token"
  }
}
get_trends

Twitter のトレンドトピックを取得します。

パラメーター:

  • category (string, optional):取得するトレンドのカテゴリ(デフォルト:"trending")
    • 選択肢:"trending"、"for-you"、"news"、"sports"、"entertainment"
  • count (integer, optional):取得するトレンドの数(デフォルト:20、最大:50)
  • ct0 (string):Twitter の ct0 Cookie
  • auth_token (string):Twitter の auth_token Cookie
{
  "name": "get_trends",
  "arguments": {
    "category": "trending",
    "count": 20,
    "ct0": "your_ct0_token",
    "auth_token": "your_auth_token"
  }
}

例:

// Get general trending topics
{
  "name": "get_trends",
  "arguments": {
    "ct0": "your_ct0_token",
    "auth_token": "your_auth_token"
  }
}

// Get sports trends
{
  "name": "get_trends", 
  "arguments": {
    "category": "sports",
    "count": 10,
    "ct0": "your_ct0_token",
    "auth_token": "your_auth_token"
  }
}

// Get personalized trends
{
  "name": "get_trends",
  "arguments": {
    "category": "for-you",
    "ct0": "your_ct0_token", 
    "auth_token": "your_auth_token"
  }
}
利用可能なリソース

リソースにはアクセスできますが、TWITTER_CT0 が必要です。

コメント

MCP は初めてですか?

プロトコルの概要から最初のサーバーの導入まで、よくある疑問にまとめて答えます。

AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。