
x go
一个基于 Go 的库和 HTTP 服务,用于通过 twitter-scraper 包与 Twitter/X 进行交互。
Repository Info
About This Server
一个基于 Go 的库和 HTTP 服务,用于通过 twitter-scraper 包与 Twitter/X 进行交互。
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
X-Go
A Go library and HTTP server for interacting with Twitter/X using the github.com/imperatrona/twitter-scraper package.
Account Management
The library supports managing multiple Twitter accounts with cookie persistence. Here's how it works:
-
Create an
accounts.jsonfile in the XGO path (default:$HOME/x-go) with your Twitter accounts:[ { "username": "your_twitter_username", "password": "your_twitter_password" } ] -
When the server starts:
- It checks for existing cookies in the
cookiesdirectory - If cookies exist, it tries to use them for authentication
- If cookies are invalid or don't exist, it logs in using the credentials from
accounts.json - After successful login, it saves the cookies to
cookies/{username}.json
- It checks for existing cookies in the
Environment Variables
XGO_PATH: Path to the X-Go directory (default:$HOME/x-go)
API Endpoints
Public Endpoints (No Login Required)
GET /api/user/{username}/tweets- Get user tweetsGET /api/user/{username}/profile- Get user profileGET /api/tweet/{id}- Get tweet by ID
Authenticated Endpoints (Login Required)
GET /api/search?q={query}- Search tweetsPOST /api/follow/{id}- Follow userPOST /api/unfollow/{id}- Unfollow userPOST /api/tweet- Create tweetPOST /api/tweet/{id}/like- Like tweetPOST /api/tweet/{id}/unlike- Unlike tweetPOST /api/tweet/{id}/retweet- Retweet
MCP Server
The project implements a Multi-Agent Communication Protocol (MCP) server that provides programmatic access to Twitter functionality through standardized agent communication.
MCP Server Features
- Manages multiple Twitter agents with session persistence
- Provides tool-based interaction with Twitter API
- Supports middleware for request handling
- Includes logging and recovery capabilities
Environment Variables
XGO_PATH: Path to the X-Go directory (default:$HOME/x-go) - Required for agent management and cookie storage
Running as MCP Server
- Ensure
XGO_PATHenvironment variable is set - Configure your Twitter accounts in
accounts.json - Run the MCP server:
go run main.go
The server will start and handle MCP protocol communication through stdin/stdout.
Building and Running Servers
This project supports two server modes: HTTP API server and MCP server.
Building the Servers
-
Build the HTTP server:
go build -o x-go-http cmd/httpserver/main.go -
Build the MCP server:
go build -o x-go-mcp main.go
Running HTTP Server
- Copy
accounts.json.exampletoaccounts.jsonand add your Twitter accounts - Set environment variables:
export XGO_PATH=$HOME/x-go - Run the server:
./x-go-http
The HTTP server will start on port 8080.
Running MCP Server
- Ensure
accounts.jsonis configured with your Twitter accounts - Set environment variables:
export XGO_PATH=$HOME/x-go - Run the server:
./x-go-mcp
The MCP server will handle communication through stdin/stdout using the MCP protocol.
Docker Support
You can also run the servers using Docker. Both servers use a Docker volume to persist data and configurations.
-
Build HTTP server image:
docker build -f Dockerfile.http -t x-go-http . -
Build MCP server image:
docker build -f Dockerfile.mcp -t x-go-mcp . -
Create a Docker volume for data persistence (optional):
docker volume create x-go-data -
Run HTTP server container:
# Using a named volume docker run -p 8080:8080 \ -v x-go-data:/x-go \ x-go-http # OR using a local directory docker run -p 8080:8080 \ -v $HOME/x-go:/x-go \ x-go-http -
Run MCP server container:
# Using a named volume docker run -i \ -v x-go-data:/x-go \ x-go-mcp # OR using a local directory docker run -i \ -v $HOME/x-go:/x-go \ x-go-mcp
The volume at /x-go contains:
accounts.json: Twitter account credentialscookies/: Directory storing authentication cookies- Other persistent data generated by the application
Note:
- The
-vflag mounts the volume to persist data between container restarts - Using a named volume (
x-go-data) is recommended for production - Using a local directory mount is useful for development
- The same volume can be shared between HTTP and MCP servers if needed
Quick Start
Clone the repository
git clone https://github.com/asabya/x-goInstall dependencies
cd x-go
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.