Anthropic
Server for Posting Tweets from X (Twitter) Using a Google Sheet as a source
claude mcp add --transport stdio codersoumya007-anthropic-mcp-server node server.js \ --env GOOGLE_SHEET_ID="Your Google Sheet ID containing tweet sources" \ --env TWITTER_API_KEY="Twitter/X API key" \ --env ANTHROPIC_API_KEY="Anthropic API key (if used for content generation)" \ --env TWITTER_API_SECRET="Twitter/X API secret" \ --env TWITTER_ACCESS_TOKEN="Twitter/X access token" \ --env GOOGLE_SHEETS_CREDENTIALS="Path to Google Sheets service account credentials or JSON content" \ --env TWITTER_ACCESS_TOKEN_SECRET="Twitter/X access token secret"
How to use
This Anthropic MCP Server automates posting tweets from X (Twitter) using a Google Sheet as the source of content. The server reads rows from the configured Google Sheet, where each row can define tweet text, optional media, and scheduling metadata. It then publishes tweets to X on your behalf, optionally leveraging content generation or refinement via the Anthropic API if configured. Use the included tools to authorize Google Sheets access, provide your Twitter/X credentials, and (optionally) enable Anthropic-based content generation to create or polish tweet content before posting.
How to install
Prerequisites:
- Node.js installed on your system (v14+ recommended)
- Google Cloud service account with Sheets API enabled and a credentials file
- Twitter/X API keys and tokens
- Optional: Anthropic API key if you plan to use content generation
Installation steps:
- Clone the repository or download the MCP server files.
- Install dependencies: npm install
- Place your Google Sheets credentials and sheet ID in a secure location and note their values.
- Create or edit a config file or environment to supply required credentials (see mcp_config env section below).
- Run the server: node server.js
- Verify the server starts without errors and check logs for connection status to Google Sheets and Twitter/X.
Note: If you deploy in a production environment, consider using a process manager (e.g., pm2) and securing environment variables via a vault or secret manager.
Additional notes
Tips and considerations:
- Ensure the Google Sheet is accessible with the service account used by the server (proper sharing permissions required).
- Keep Twitter/X API credentials secure; rotate keys regularly and avoid embedding in code.
- If enabling Anthropic content generation, monitor usage to stay within rate limits and API quotas.
- Use the Google Sheet as a source of truth for tweet content; you can include columns for content, scheduled_time, media_url, and status.
- Logs can help diagnose authentication issues with Google Sheets or X; ensure verbose logging is enabled during setup.
- For reliability, implement error handling for network interruptions and retries for failed postings.