reagent-systems/mcp-x-posting
If you are the rightful owner of mcp-x-posting and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The X Post Generator MCP Server is a Python-based server that integrates with Cursor to generate draft X (Twitter) posts based on coding progress, using local AI models and maintaining privacy.
X Post Generator MCP Server
A standalone Python-based Model Context Protocol (MCP) server that integrates with Cursor to automatically generate draft X (Twitter) posts based on your coding progress. It captures screenshots of your browser preview, analyzes recent git changes, and uses a local AI model in LM Studio to craft engaging posts. Drafts are saved to a local CSV for easy review and editing.
This keeps your workflow private and local—no cloud services or extensions required.
Features
- Screenshot Capture: Automatically opens your app preview URL in the browser and takes a screenshot using
pyautogui. - Git Change Analysis: Pulls recent code diffs to understand features you're working on.
- Local AI Generation: Leverages LM Studio (with a vision model) to create concise, hashtag-filled X posts under 280 characters.
- CSV Storage: Saves drafts with timestamps, summaries, posts, and screenshot paths for spreadsheet import.
- MCP Integration: Seamless invocation from Cursor's chat or Composer (e.g.,
@x-post-generator create_x_post_draft). - Cross-Platform: Works on Windows, Mac, and Linux.
Prerequisites
- Cursor: Download from cursor.com. No extensions needed—MCP is built-in.
- LM Studio: Download from lmstudio.ai. Load a vision-capable model like
llama-3.2-vision-instructand start the local server (default:http://localhost:1234). - Python 3.10+: With pip.
- Git: For change detection (optional; falls back gracefully if not present).
- Browser: Default system browser for preview screenshots (assumes your dev server runs at
http://localhost:3000—configurable).
Installation
-
Clone or Save the Script:
- Save
mcp_server.pyfrom the provided code.
- Save
-
Set Up Virtual Environment:
python -m venv mcp-env # Activate: # Linux/Mac: source mcp-env/bin/activate # Windows: mcp-env\Scripts\activate -
Install Dependencies:
pip install mcp[cli] openai pyautogui pillow gitpython pandas requests pytest-asyncio- Note:
pyautoguimay prompt for permissions on first run (e.g., screen recording on Mac).
- Note:
-
Configure MCP in Cursor:
- Open Cursor Settings (Cmd/Ctrl + ,) > Search "MCP".
- Add this to your settings JSON (under
"mcpServers"):{ "mcpServers": { "x-post-generator": { "command": "python", "args": ["/absolute/path/to/mcp_server.py"], "env": {} } } } - Restart Cursor.
Configuration
Edit the top of mcp_server.py:
LM_STUDIO_URL: Your LM Studio server (default:http://localhost:1234/v1).MODEL_NAME: Loaded model (e.g.,llama-3.2-vision-instruct).BROWSER_URL: Your app preview (default:http://localhost:3000).DRAFTS_FILE: Output CSV path (default:./x_post_drafts.csv).
Usage
-
Start the MCP Server:
python mcp_server.py- It will check LM Studio connectivity and run in stdio mode for Cursor.
-
In Cursor:
- Open Chat or Composer.
- Prompt:
@x-post-generator create_x_post_draft("Implemented user login feature")- This triggers the full workflow: screenshot → analysis → generation → save.
- Or use sub-tools:
@x-post-generator get_recent_changesfor diffs only.
-
Review Drafts:
- Open
./x_post_drafts.csvin Excel, Google Sheets, etc. - Columns:
Timestamp,Feature Summary,Draft Post,Screenshot Path. - Example Draft: "🚀 Just nailed user auth in my app! Seamless login with OAuth. Check the clean UI below. #BuildInPublic #IndieDev [Screenshot desc]"
- Open
-
Workflow Example:
- Code → Save/Commit in Cursor.
- Prompt for draft.
- Edit/post manually on X.
Available Tools
From Cursor, you can call:
create_x_post_draft(feature_desc): Full pipeline (default: "latest work").get_recent_changes(): Git diff summary.take_screenshot(): Capture and return path/base64.generate_post(feature_summary, screenshot_path, screenshot_b64): AI post creation.save_draft(feature_summary, draft_post, screenshot_path): Append to CSV.
Troubleshooting
- LM Studio Not Connecting: Ensure server is running and model loaded. Test with
curl http://localhost:1234/v1/models. - Screenshot Fails: Grant
pyautoguipermissions. Increaseasyncio.sleep(3)for slower loads. For headless: Swap toplaywright(pip install; requires browser install). - No Git Repo: Script handles it—provide manual
feature_descin prompts. - MCP Not Found in Cursor: Double-check settings JSON path and restart.
- Long Prompts: Truncates diffs to 2000 chars; adjust in code.
- Testing: Add
pytestfor unit tests (e.g., mock API calls).
Enhancements
- Auto-Trigger: Add a Cursor task in
.vscode/tasks.jsonto run on save. - Google Sheets: Integrate
gspreadfor cloud sync. - Direct Posting: Extend with X API (add
tweepy; requires keys—not included for privacy).
License
MIT License—feel free to fork and improve!
Built with ❤️ for indie devs sharing their journey. Questions? Open an issue or ping on X at https://www.x.com/reagent-systems/.