twitter-mcp
by onurerdog4n
README.md
# 🐦 twitter-mcp
Playwright ile geliştirilmiş X (Twitter) tarayıcı otomasyon aracı. Birden fazla hesapla tweet atma, beğenme, retweet, yanıtlama ve daha fazlasını otomatikleştirin.
## ✨ Özellikler
- 🔐 Kalıcı oturumlarla çoklu hesap yönetimi
- 📝 Metin ve görsel ile tweet atma
- ❤️ Tweet beğenme
- 🔄 Retweet yapma
- 💬 Tweet'lere yanıt verme
- 🎯 Alıntı tweet atma
- 🚀 Otomasyon için REST API
- 🔔 Webhook bildirimleri
- 🌐 Tarayıcı tabanlı otomasyon (API anahtarı gerektirmez)
## 📋 Gereksinimler
- Node.js >= 20
- npm veya yarn
## 🚀 Hızlı Başlangıç
### Kurulum
```bash
npm install
```
### Kurulum
İlk profilinizi yapılandırmak için kurulum scriptini çalıştırın:
```bash
npm run setup
```
Bu komut, profil oluşturma ve X'e giriş yapma sürecinde size rehberlik edecektir.
### API Sunucusunu Başlatma
```bash
npm run server
```
Sunucu `http://localhost:4000` adresinde başlayacaktır.
## 🔧 API Endpoint'leri
### POST `/api/login`
Yeni profil oluştur ve giriş yap
```json
{
"username": "kullanici_adiniz",
"password": "sifreniz"
}
```
### GET `/api/profiles`
Tüm kimlik doğrulaması yapılmış profilleri listele
### POST `/api/retweet`
Birden fazla hesaptan retweet yap
```json
{
"tweetUrl": "https://x.com/user/status/123456",
"profiles": ["profil1", "profil2"]
}
```
### POST `/api/like`
Birden fazla hesaptan tweet beğen
```json
{
"tweetUrl": "https://x.com/user/status/123456",
"profiles": ["profil1", "profil2"]
}
```
### POST `/api/reply`
Birden fazla hesaptan tweet'e yanıt ver
```json
{
"tweetUrl": "https://x.com/user/status/123456",
"content": "Harika tweet!",
"profiles": ["profil1", "profil2"],
"imagePaths": ["resim/yolu/image.jpg"]
}
```
### DELETE `/api/profile/:name`
Profil sil
## 📜 Script'ler
Script'leri doğrudan da kullanabilirsiniz:
```bash
# Tweet at
echo '{"content":"Merhaba Dünya!","profile":"profilim"}' | npx tsx scripts/post.ts
# Tweet beğen
echo '{"tweetUrl":"https://x.com/user/status/123","profile":"profilim"}' | npx tsx scripts/like.ts
# Retweet yap
echo '{"tweetUrl":"https://x.com/user/status/123","profile":"profilim"}' | npx tsx scripts/retweet.ts
# Tweet'e yanıt ver
echo '{"tweetUrl":"https://x.com/user/status/123","content":"Güzel!","profile":"profilim"}' | npx tsx scripts/reply.ts
# Alıntı tweet at
echo '{"tweetUrl":"https://x.com/user/status/123","content":"Buna bakın","profile":"profilim"}' | npx tsx scripts/quote.ts
# Profilleri listele
npx tsx scripts/list-profiles.ts
```
## 🔔 Webhook Bildirimleri
Bildirim almak için `WEBHOOK_URL` ortam değişkenini ayarlayın:
```bash
export WEBHOOK_URL=https://webhook-url-iniz.com/endpoint
npm run server
```
Gönderilen olaylar:
- `login_success` / `login_failed`
- `retweet_completed`
- `like_completed`
- `reply_completed`
- `profile_deleted`
## 🗂️ Proje Yapısı
```
twitter-mcp/
├── api-server.ts # REST API sunucusu
├── scripts/
│ ├── setup.ts # İlk kurulum sihirbazı
│ ├── auto-login.ts # Otomatik giriş
│ ├── post.ts # Tweet atma
│ ├── like.ts # Tweet beğenme
│ ├── retweet.ts # Retweet yapma
│ ├── reply.ts # Tweet'e yanıt verme
│ ├── quote.ts # Alıntı tweet atma
│ └── list-profiles.ts # Tüm profilleri listele
├── lib/ # Paylaşılan yardımcı araçlar
└── data/
└── profiles/ # Kullanıcı profilleri (gitignore'da)
```
## 🔒 Güvenlik
- Tüm profil verileri yerel olarak `data/profiles/` dizininde saklanır
- Kimlik bilgileri ve çerezler asla git'e commit edilmez
- Hassas yapılandırma için ortam değişkenlerini kullanın
- Her profil izole tarayıcı oturumlarına sahiptir
## ⚙️ Ortam Değişkenleri
```bash
PORT=4000 # API sunucu portu
WEBHOOK_URL=https://webhook-url-iniz.com # Webhook endpoint'i
```
## 🛠️ Geliştirme
```bash
# Tip kontrolü
npm run typecheck
# İzleme modu (değişikliklerde otomatik yeniden başlatma)
npm run dev
```
## 📝 Lisans
MIT
## 🤖 MCP Server Kullanımı
Bu proje aynı zamanda bir MCP (Model Context Protocol) server olarak da çalışır. AI asistanları (Kiro, Claude Desktop, vb.) doğrudan Twitter işlemlerini yapabilir.
### MCP Server Kurulumu
1. Gerekli paketi yükle:
```bash
npm install
```
2. MCP config dosyasını düzenle (`.kiro/settings/mcp.json` veya `~/.kiro/settings/mcp.json`):
```json
{
"mcpServers": {
"twitter-automation": {
"command": "npx",
"args": ["tsx", "/tam/yol/twitter-mcp/mcp-server.ts"],
"env": {
"API_BASE_URL": "https://your-ngrok-url.ngrok-free.dev"
},
"disabled": false,
"autoApprove": []
}
}
}
```
3. Kiro'yu yeniden başlat veya MCP Server view'dan reconnect yap
### Kullanılabilir MCP Tool'ları
- `twitter_health_check` - API sunucu durumunu kontrol et
- `twitter_list_profiles` - Kayıtlı hesapları listele
- `twitter_add_account` - Yeni hesap ekle
- `twitter_retweet` - Retweet at
- `twitter_like` - Tweet beğen
- `twitter_reply` - Tweet'e yanıt ver
- `twitter_delete_profile` - Hesap sil
### Örnek Kullanım (AI ile)
```
Sen: "Twitter hesaplarımı listele"
AI: twitter_list_profiles tool'unu kullanır
Sen: "Bu tweet'i tüm hesaplarımdan retweet et: https://x.com/user/status/123"
AI: twitter_retweet tool'unu kullanır
Sen: "hesap1 ve hesap2 ile bu tweet'e 'Harika!' diye yanıt ver"
AI: twitter_reply tool'unu kullanır
```
## ⚠️ Sorumluluk Reddi
Bu araç eğitim amaçlıdır. Sorumlu bir şekilde ve X'in Hizmet Şartları'na uygun olarak kullanın. Otomatik işlemler platform politikalarını ihlal edebilir.