mcp-x-posting

reagent-systems/mcp-x-posting

3.2

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.

Tools
5
Resources
0
Prompts
0

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-instruct and 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

  1. Clone or Save the Script:

    • Save mcp_server.py from the provided code.
  2. Set Up Virtual Environment:

    python -m venv mcp-env
    # Activate:
    # Linux/Mac: source mcp-env/bin/activate
    # Windows: mcp-env\Scripts\activate
    
  3. Install Dependencies:

    pip install mcp[cli] openai pyautogui pillow gitpython pandas requests pytest-asyncio
    
    • Note: pyautogui may prompt for permissions on first run (e.g., screen recording on Mac).
  4. 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

  1. Start the MCP Server:

    python mcp_server.py
    
    • It will check LM Studio connectivity and run in stdio mode for Cursor.
  2. 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_changes for diffs only.
  3. Review Drafts:

    • Open ./x_post_drafts.csv in 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]"
  4. 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 pyautogui permissions. Increase asyncio.sleep(3) for slower loads. For headless: Swap to playwright (pip install; requires browser install).
  • No Git Repo: Script handles it—provide manual feature_desc in 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 pytest for unit tests (e.g., mock API calls).

Enhancements

  • Auto-Trigger: Add a Cursor task in .vscode/tasks.json to run on save.
  • Google Sheets: Integrate gspread for 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/.