Skip to content
Back to search

x-use

Claude Code plugins for browser-native X workflows.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/ihuzaifashoukat--x-use/badge.svg)](/listings/ihuzaifashoukat--x-use)

HTML

<a href="/listings/ihuzaifashoukat--x-use"><img src="/api/listings/ihuzaifashoukat--x-use/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Requires Python 3.11.5+ and Chromium. The CI matrix covers Python 3.11–3.14 on Windows, macOS and Linux.

**Version 3.3.0 provides 82 tools** for research, inbox management, reviewed publishing and account operations. Upgrade the package and restart your MCP client to load the current tools.

1. Install the server and browser

python -m pip install --upgrade x-use-mcp
python -m patchright install chromium

2. Choose a private data directory and initialize

Windows PowerShell:

$env:X_USE_HOME = "$env:LOCALAPPDATA\x-use"
x-use init
x-use doctor

macOS / Linux:

export X_USE_HOME="$HOME/.local/share/x-use"
x-use init
x-use doctor

The wizard configures your account and imports your own X session cookies from a local JSON export. Keep cookies and inbox PINs private. Use the same absolute data directory in your client configuration below; shell environment settings alone do not configure a desktop client.

3. Connect your MCP client

Use this stdio configuration in clients that accept an `mcpServers` object, such as Claude Desktop:

{
  "mcpServers": {
    "x-use": {
      "command": "/absolute/path/to/x-use",
      "args": ["mcp"],
      "env": {
        "X_USE_HOME": "/absolute/path/to/x-use-data"
      }
    }
  }
}

Replace both paths. On Windows, use the installed `x-use.exe` path and forward slashes in JSON, for example `C:/Users/you/AppData/Local/x-use` for the data directory. Locate the executable with `Get-Command x-use` in PowerShell or `command -v x-use` on macOS/Linux.

Claude Code, Codex, Cursor and Windsurf have their own registration locations or commands. Follow the [client setup instructions](https://github.com/ihuzaifashoukat/x-use/blob/main/SKILL.md), then reload the client if required. Ask it to call `list_accounts` before starting browser work.

4. Try a first workflow

With draft mode enabled, ask your client:

> Check my account health, research the profile I specify, and summarize its recent visible posts. Prepare one relevant reply draft and show me its ID and exact text. Wait for my approval before publishing.

The flow is `get_account_health` → `get_profile_context` → `prepare_reply` → `reply_to_tweet` → `get_draft`. The reply tool stages a draft under the default policy; `prepare_reply` supplies context. Use `approve_draft` only when authorized.

[More workflow examples](https://github.com/ihuzaifashoukat/x-use/blob/main/docs/WORKFLOWS.md) cover inbox triage, outreach and threads.

<details> <summary>Install from source or let your agent handle setup</summary>

git clone https://github.com/ihuzaifashoukat/x-use.git
cd x-use
python scripts/setup_uv.py --dev

On Windows you can use `py -3 scripts/setup_uv.py --dev`; on macOS/Linux use `python3` if needed. Setup installs uv when missing, synchronizes locked dependencies into `.venv`, installs matching Chromium, creates missing sample configuration and runs diagnostics. Activate the environment or use its executable directly. Then initialize your account.

For assisted installation, use the [setup prompt](https://github.com/ihuzaifashoukat/x-use/blob/main/docs/SETUP_PROMPT.md) or install the root setup skill:

npx skills add ihuzaifashoukat/x-use

The [Claude Code plugin](https://github.com/ihuzaifashoukat/x-use/blob/main/plugins/x-use/README.md) includes the bundled skills and MCP configuration guidance.

</details>

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json · Manifest · 18 lines
  1. {
  2. "$schema": "https://json.schemastore.org/claude-code-marketplace.json",
  3. "name": "x-use",
  4. "version": "1.0.0",
  5. "description": "Claude Code plugins for browser-native X workflows.",
  6. "owner": {
  7. "name": "Huzaifa Shoukat"
  8. },
  9. "plugins": [
  10. {
  11. "name": "x-use",
  12. "source": "./plugins/x-use",
  13. "description": "Connect Claude Code to x-use MCP for research, inbox reads, reviewed outreach, campaigns, posts, and threads.",
  14. "version": "3.3.0",
  15. "category": "productivity"
  16. }
  17. ]
  18. }
README.md · README · 210 lines
  1. # x-use — MCP server for X (Twitter)
  2. <!-- mcp-name: io.github.ihuzaifashoukat/x-use -->
  3. [![x-use logo — research, draft, review and publish with an MCP server for X (Twitter)](https://raw.githubusercontent.com/ihuzaifashoukat/x-use/efb9500d4edd0d1482688d1a11b9b39239aa9bc0/assets/x-use-social-preview.jpg)](https://github.com/ihuzaifashoukat/x-use)
  4. **Connect your AI client to X research, inbox reads, and reviewed publishing.**
  5. x-use is an open-source Python Model Context Protocol (MCP) server and CLI for X (Twitter). Connect Claude, Codex, Cursor or another local MCP client to profile research, inbox management and reviewed publishing. It uses your authenticated browser session, supports multiple accounts and runs locally without official X API credentials.
  6. [![PyPI](https://img.shields.io/pypi/v/x-use-mcp)](https://pypi.org/project/x-use-mcp/)
  7. [![Python](https://img.shields.io/pypi/pyversions/x-use-mcp)](https://pypi.org/project/x-use-mcp/)
  8. [![CI](https://github.com/ihuzaifashoukat/x-use/actions/workflows/ci.yml/badge.svg)](https://github.com/ihuzaifashoukat/x-use/actions/workflows/ci.yml)
  9. [![MIT license](https://img.shields.io/badge/license-MIT-blue)](https://github.com/ihuzaifashoukat/x-use/blob/main/LICENSE)
  10. [![GitHub stars](https://img.shields.io/github/stars/ihuzaifashoukat/x-use?style=flat)](https://github.com/ihuzaifashoukat/x-use/stargazers)
  11. [Quickstart](#quickstart) · [Documentation](https://github.com/ihuzaifashoukat/x-use/blob/main/docs/README.md) · [Tool reference](https://github.com/ihuzaifashoukat/x-use/blob/main/docs/MCP_GUIDE.md) · [Discussions](https://github.com/ihuzaifashoukat/x-use/discussions) · [Contribute](https://github.com/ihuzaifashoukat/x-use/blob/main/CONTRIBUTING.md)
  12. ## What can you do with x-use?
  13. - **Research before replying:** search X, inspect a profile, read posts and bounded thread context, and prepare a relevant reply.
  14. - **Work through your inbox:** inspect visible conversations, unread messages, requests and notifications; prepare individual messages and supported conversation actions for review.
  15. - **Publish with context:** stage posts or multi-post threads, inspect the exact text, and approve the draft when it is ready.
  16. - **Organize outreach locally:** maintain leads, opt-outs and campaign drafts with per-account limits and delivery tracking.
  17. Your AI client supplies the reasoning and text. An optional OpenAI-compatible LLM configuration supports server-side generation; ordinary explicit-text MCP workflows do not need that extra key.
  18. ## Quickstart
  19. Requires Python 3.11.5+ and Chromium. The CI matrix covers Python 3.11–3.14 on Windows, macOS and Linux.
  20. **Version 3.3.0 provides 82 tools** for research, inbox management, reviewed publishing and account operations. Upgrade the package and restart your MCP client to load the current tools.
  21. ### 1. Install the server and browser
  22. ```bash
  23. python -m pip install --upgrade x-use-mcp
  24. python -m patchright install chromium
  25. ```
  26. ### 2. Choose a private data directory and initialize
  27. Windows PowerShell:
  28. ```powershell
  29. $env:X_USE_HOME = "$env:LOCALAPPDATA\x-use"
  30. x-use init
  31. x-use doctor
  32. ```
  33. macOS / Linux:
  34. ```bash
  35. export X_USE_HOME="$HOME/.local/share/x-use"
  36. x-use init
  37. x-use doctor
  38. ```
  39. The wizard configures your account and imports your own X session cookies from a local JSON export. Keep cookies and inbox PINs private. Use the same absolute data directory in your client configuration below; shell environment settings alone do not configure a desktop client.
  40. ### 3. Connect your MCP client
  41. Use this stdio configuration in clients that accept an `mcpServers` object, such as Claude Desktop:
  42. ```json
  43. {
  44. "mcpServers": {
  45. "x-use": {
  46. "command": "/absolute/path/to/x-use",
  47. "args": ["mcp"],
  48. "env": {
  49. "X_USE_HOME": "/absolute/path/to/x-use-data"
  50. }
  51. }
  52. }
  53. }
  54. ```
  55. Replace both paths. On Windows, use the installed `x-use.exe` path and forward slashes in JSON, for example `C:/Users/you/AppData/Local/x-use` for the data directory. Locate the executable with `Get-Command x-use` in PowerShell or `command -v x-use` on macOS/Linux.
  56. Claude Code, Codex, Cursor and Windsurf have their own registration locations or commands. Follow the [client setup instructions](https://github.com/ihuzaifashoukat/x-use/blob/main/SKILL.md), then reload the client if required. Ask it to call `list_accounts` before starting browser work.
  57. ### 4. Try a first workflow
  58. With draft mode enabled, ask your client:
  59. > Check my account health, research the profile I specify, and summarize its recent visible posts. Prepare one relevant reply draft and show me its ID and exact text. Wait for my approval before publishing.
  60. The flow is `get_account_health` → `get_profile_context` → `prepare_reply` → `reply_to_tweet` → `get_draft`. The reply tool stages a draft under the default policy; `prepare_reply` supplies context. Use `approve_draft` only when authorized.
  61. [More workflow examples](https://github.com/ihuzaifashoukat/x-use/blob/main/docs/WORKFLOWS.md) cover inbox triage, outreach and threads.
  62. <details>
  63. <summary>Install from source or let your agent handle setup</summary>
  64. ```bash
  65. git clone https://github.com/ihuzaifashoukat/x-use.git
  66. cd x-use
  67. python scripts/setup_uv.py --dev
  68. ```
  69. On Windows you can use `py -3 scripts/setup_uv.py --dev`; on macOS/Linux use `python3` if needed. Setup installs uv when missing, synchronizes locked dependencies into `.venv`, installs matching Chromium, creates missing sample configuration and runs diagnostics. Activate the environment or use its executable directly. Then initialize your account.
  70. For assisted installation, use the [setup prompt](https://github.com/ihuzaifashoukat/x-use/blob/main/docs/SETUP_PROMPT.md) or install the root setup skill:
  71. ```bash
  72. npx skills add ihuzaifashoukat/x-use
  73. ```
  74. The [Claude Code plugin](https://github.com/ihuzaifashoukat/x-use/blob/main/plugins/x-use/README.md) includes the bundled skills and MCP configuration guidance.
  75. </details>
  76. ## Capabilities
  77. | Workflow | Representative tools | Details |
  78. |---|---|---|
  79. | Profile and post research | `get_profile_context`, `search_profile`, `search_tweets`, `get_tweet`, `get_thread` | Visible profile, post, media and bounded thread evidence |
  80. | Inbox and notifications | `get_inbox`, `search_conversations`, `get_conversation`, `get_notifications` | Inbox/request folders, read-state evidence and partial message history |
  81. | Publishing and inbox controls (3.1.0) | `get_bookmarks`, `edit_tweet`, `delete_tweet`, `unfollow_profile`, `manage_conversation` | Reviewed changes; [supported controls and limitations](https://github.com/ihuzaifashoukat/x-use/blob/main/docs/CONTROLS.md) |
  82. | Reviewed publishing | `post_tweet`, `reply_to_tweet`, `prepare_thread`, `approve_draft` | Persistent drafts and resumable thread progress |
  83. | Individual outreach | `prepare_outreach`, `send_message`, `follow_profile` | Message and follow drafts require individual approval |
  84. | Leads and campaigns | `upsert_lead`, `create_campaign`, `prepare_campaign_messages`, `opt_out_lead` | Local records, suppression and bounded batches |
  85. | Account readiness (3.1.0) | `get_account_health`, `get_session_status`, `test_proxy` | [Operational score, evidence and recovery advice](https://github.com/ihuzaifashoukat/x-use/blob/main/docs/ACCOUNT_HEALTH.md), plus explicit proxy connectivity checks |
  86. | Scheduling and recovery | `queue_post`, `process_queue`, `get_account_health`, `resolve_action_outcome` | Durable budgets, explicit recovery and uncertain-outcome tracking |
  87. **Version 3.3.0 includes 82 tools, seven prompts, four resource patterns and seven bundled skills.** 3.1.0 added runtime diagnostics, campaign previews, bookmarks, reviewed post edits/deletions, engagement reversal and inbox controls to the 70 tools in 3.0.0; 3.3.0 adds quote posts to `post_tweet` and keeps the same tool set. See [publishing and inbox controls](https://github.com/ihuzaifashoukat/x-use/blob/main/docs/CONTROLS.md) for supported layouts and testing limits.
  88. The [MCP guide](https://github.com/ihuzaifashoukat/x-use/blob/main/docs/MCP_GUIDE.md) documents every tool, prompt and resource. [Validation evidence](https://github.com/ihuzaifashoukat/x-use/blob/main/docs/TOOL_VALIDATION.md) separates local protocol checks, synthetic browser fixtures and authorized live-account checks.
  89. For a uvx client, use `uvx x-use-mcp` or pin the release with
  90. `uvx x-use-mcp==3.3.0`. The `x-use-mcp` executable starts MCP without arguments;
  91. the existing `x-use mcp` command remains supported. Clients pinned to 3.0.0
  92. must use `uvx --from x-use-mcp==3.0.0 x-use mcp`.
  93. ## How execution works
  94. The current MCP runtime uses async Patchright Chromium with separate account contexts. Your configuration, cookies, drafts, queue and action journals live under `X_USE_HOME`. AI-client and optional model-provider data handling depends on the client and provider you choose.
  95. The protocol implementation uses the MCP Python SDK v2 line (`mcp>=2.3,<3`). It negotiates handshake protocol versions 2024-11-05 through 2025-11-25 with existing clients.
  96. Draft mode is enabled by default for ordinary publishing. Messages, follows and thread starts require draft approval. Direct publishing mode, explicit queue processing, opt-in auto-drain and the legacy batch runner have separate execution paths. Review the [configuration reference](https://github.com/ihuzaifashoukat/x-use/blob/main/docs/CONFIG_REFERENCE.md) before changing these settings.
  97. The development checkout allows one MCP server process per `X_USE_HOME`, preventing concurrent servers from using stale draft and queue state. Close the existing connection before opening the same data directory in another client.
  98. ## Limits to understand
  99. - Browser reads are bounded by visible X content. Followers, inboxes and threads are not complete exports; unavailable evidence remains unknown.
  100. - Opening conversations or notifications can change their native read state.
  101. - Encrypted inboxes may need the account owner's PIN again after a browser-context restart.
  102. - Analytics currently reports availability and the observed Premium gate; it does not provide a complete analytics dashboard.
  103. - X layout changes, expired sessions, account challenges and platform limits can interrupt work. Local controls do not guarantee protection from account restrictions.
  104. - The legacy Selenium batch engine (`x-use run` / `run_cycle`) executes separately from MCP draft review. Community posting is not currently verified in the async runtime.
  105. See [browser behavior and recovery](https://github.com/ihuzaifashoukat/x-use/blob/main/docs/BROWSER_RUNTIME.md) and [responsible-use guidance](https://github.com/ihuzaifashoukat/x-use/blob/main/docs/BEST_PRACTICES.md).
  106. ## Frequently asked questions
  107. ### Does x-use require an X API key?
  108. No. It operates visible X pages through a browser authenticated with your session cookies. It does not require official X API credentials. Optional server-side text generation may require an LLM provider key.
  109. ### Which MCP clients can use x-use?
  110. Clients that launch local stdio MCP servers can use x-use. Setup examples cover Claude Desktop, Claude Code, Codex, Cursor and Windsurf. Client-specific discovery and reload behavior varies.
  111. ### Does x-use automatically send every drafted message?
  112. No. Message drafts require individual approval. Other write behavior depends on draft mode, queue execution and the legacy runner; check the configured policy before requesting actions.
  113. ### Can I manage multiple X accounts?
  114. Yes. Accounts have separate cookies, browser contexts and policy settings, with optional proxy routes. Browser capacity is bounded and depends on your host and configuration.
  115. ### Can I edit posts or manage my X inbox?
  116. Version 3.1.0 added reviewed edits and deletion of your own posts, bookmarks, unfollowing, and supported conversation request, mute/unmute and deletion actions. X determines edit eligibility. Inbox history is partial, and per-message editing/deletion, attachment sending and group administration are not implemented. See the [controls guide](https://github.com/ihuzaifashoukat/x-use/blob/main/docs/CONTROLS.md) for exact arguments and limits.
  117. ### Is x-use free and open source?
  118. The project is MIT licensed with no project license fee. AI-client subscriptions, optional model providers, proxies and hosting may have their own costs.
  119. ### Is x-use affiliated with X?
  120. No. x-use is an independent community project. X and Twitter are names used to identify the platform it works with.
  121. ### Was this project called twitter-automation-ai?
  122. Yes. The project was renamed to x-use during the v2 relaunch. See the [changelog](https://github.com/ihuzaifashoukat/x-use/blob/main/CHANGELOG.md) for its history.
  123. ## Documentation and community
  124. Start with the [documentation index](https://github.com/ihuzaifashoukat/x-use/blob/main/docs/README.md). It links setup, workflows, tools, configuration, presets, architecture and troubleshooting. X-Use is maintained by [Huzaifa Shoukat](https://github.com/ihuzaifashoukat) and welcomes community contributions.
  125. Found a reproducible problem? [Report a bug](https://github.com/ihuzaifashoukat/x-use/issues/new/choose). Have a workflow to share? [Start a discussion](https://github.com/ihuzaifashoukat/x-use/discussions). Useful first contributions include clearer setup instructions, fictional browser fixtures, platform fixes and example presets.
  126. See [CONTRIBUTING](https://github.com/ihuzaifashoukat/x-use/blob/main/CONTRIBUTING.md), the [Code of Conduct](https://github.com/ihuzaifashoukat/x-use/blob/main/CODE_OF_CONDUCT.md) and [security policy](https://github.com/ihuzaifashoukat/x-use/blob/main/SECURITY.md). If x-use helps your work, a GitHub star helps other developers discover it.
  127. ## Star history
  128. <a href="https://www.star-history.com/?repos=ihuzaifashoukat%2Fx-use&amp;type=date&amp;legend=top-left">
  129. <picture>
  130. <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=ihuzaifashoukat/x-use&amp;type=date&amp;legend=top-left&amp;theme=dark" />
  131. <img alt="Live star history for x-use" src="https://api.star-history.com/svg?repos=ihuzaifashoukat/x-use&amp;type=date&amp;legend=top-left" />
  132. </picture>
  133. </a>
  134. ## License
  135. [MIT](https://github.com/ihuzaifashoukat/x-use/blob/main/LICENSE).
install.ps1 · Bundled script · 167 lines · 1 finding marked
  1. <#
  2. .SYNOPSIS
  3. One-click installer for x-use on Windows.
  4. .DESCRIPTION
  5. 1. Preflight: git and Python >= 3.11 must be present.
  6. 2. Clone the repo (or reuse/update an existing clone, or install in
  7. place when run from inside the repo).
  8. 3. Bootstrap uv locally when needed and synchronize .venv from uv.lock.
  9. 4. Install Chromium for the configured Patchright or Playwright backend.
  10. 5. Create missing sample config and run doctor; existing config is retained.
  11. Re-running reuses the checkout and environment. No global Python packages
  12. or administrator changes are required.
  13. .EXAMPLE
  14. powershell -ExecutionPolicy Bypass -File install.ps1
  15. .EXAMPLE
  16. iex "& { $(irm https://raw.githubusercontent.com/ihuzaifashoukat/x-use/main/install.ps1) }"
  17. .EXAMPLE
  18. .\install.ps1 -Dir C:\tools\x-use -Dev -Update
  19. #>
  20. [CmdletBinding()]
  21. param(
  22. # Install directory. Defaults to .\x-use, or the current directory when
  23. # run from inside the repo. Env: XUSE_INSTALL_DIR (used by irm|iex).
  24. [string]$Dir = $(if ($env:XUSE_INSTALL_DIR) { $env:XUSE_INSTALL_DIR } else { "" }),
  25. # Install with dev extras (pytest) for contributors.
  26. [switch]$Dev,
  27. # Reuse a browser already installed for the selected browser-driver version.
  28. [switch]$SkipBrowser,
  29. # git pull --ff-only an existing checkout before installing.
  30. [switch]$Update,
  31. # Show usage and exit.
  32. [switch]$Help
  33. )
  34. Set-StrictMode -Version Latest
  35. $ErrorActionPreference = 'Stop'
  36. $RepoUrl = if ($env:XUSE_REPO_URL) { $env:XUSE_REPO_URL } else { "https://github.com/ihuzaifashoukat/x-use.git" }
  37. $MinPythonMajor = 3
  38. $MinPythonMinor = 11
  39. function Write-Info([string]$Msg) { Write-Host "==> $Msg" -ForegroundColor Green }
  40. function Write-Warn([string]$Msg) { Write-Host "warn: $Msg" -ForegroundColor Yellow }
  41. function Fail([string]$Msg) { Write-Host "error: $Msg" -ForegroundColor Red; exit 1 }
  42. # Native commands do not throw on failure; check the exit code ourselves.
  43. function Invoke-Native([string]$File, [string[]]$CmdArgs, [string]$What) {
  44. & $File @CmdArgs
  45. if ($LASTEXITCODE -ne 0) { Fail "$What failed (exit code $LASTEXITCODE)." }
  46. }
  47. if ($Help) {
  48. Get-Help $MyInvocation.MyCommand.Path
  49. exit 0
  50. }
  51. # --- preflight ------------------------------------------------------------------
  52. if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
  53. Fail "git is not installed (or not on PATH). Get it from https://git-scm.com/download/win"
  54. }
  55. $Python = $null
  56. $candidates = @()
  57. if (Get-Command py -ErrorAction SilentlyContinue) { $candidates += , @("py", @("-3")) }
  58. if (Get-Command python -ErrorAction SilentlyContinue) { $candidates += , @("python", @()) }
  59. foreach ($candidate in $candidates) {
  60. $exe = $candidate[0]; $exeArgs = $candidate[1]
  61. & $exe @exeArgs -c "import sys; raise SystemExit(0 if sys.version_info >= ($MinPythonMajor, $MinPythonMinor) else 1)" 2>$null
  62. if ($LASTEXITCODE -eq 0) { $Python = $candidate; break }
  63. }
  64. if (-not $Python) {
  65. Fail "Python $MinPythonMajor.$MinPythonMinor+ not found. Install it from https://www.python.org/downloads/ (tick 'Add python.exe to PATH') and re-run."
  66. }
  67. $pyExe = $Python[0]; $pyArgs = $Python[1]
  68. # No embedded double quotes in -c strings: PowerShell strips them when
  69. # passing arguments to native commands.
  70. $pyVersion = (& $pyExe @pyArgs -c 'import sys; print(sys.version.split()[0])')
  71. $gitVersion = (git --version) -replace '^git version ', ''
  72. Write-Info "git $gitVersion, python $pyVersion - preflight OK."
  73. # --- repo: clone / update / in-place ---------------------------------------------
  74. function Test-XUseCheckout([string]$Path) {
  75. $pyproject = Join-Path $Path "pyproject.toml"
  76. if (-not (Test-Path $pyproject)) { return $false }
  77. return [bool](Select-String -Path $pyproject -Pattern '^name = "x-use' -Quiet)
  78. }
  79. if (-not $Dir -and (Test-XUseCheckout (Get-Location).Path)) {
  80. # Running from inside the repo: install in place.
  81. $Dir = (Get-Location).Path
  82. }
  83. if (-not $Dir) { $Dir = "x-use" }
  84. if (Test-XUseCheckout $Dir) {
  85. if ($Update) {
  86. Write-Info "Updating existing clone in $Dir ..."
  87. git -C $Dir pull --ff-only
  88. if ($LASTEXITCODE -ne 0) { Fail "git pull failed; the existing checkout was not updated." }
  89. } else {
  90. Write-Info "Existing x-use checkout found in $Dir - reusing it (pass -Update to pull latest)."
  91. }
  92. } else {
  93. if (Test-Path $Dir) {
  94. Fail "'$Dir' exists but is not an x-use checkout. Pick another -Dir or remove it."
  95. }
  96. Write-Info "Cloning $RepoUrl -> $Dir ..."
  97. Invoke-Native git @("clone", "--depth", "1", $RepoUrl, $Dir) "git clone"
  98. if (-not (Test-XUseCheckout $Dir)) {
  99. Fail "the clone does not look like x-use v2 (missing pyproject.toml). The default branch may predate the v2 merge - clone the right branch or set XUSE_REPO_URL."
  100. }
  101. }
  102. $Dir = (Resolve-Path $Dir).Path
  103. if (-not $env:X_USE_HOME) {
  104. if (-not $env:LOCALAPPDATA) { Fail "LOCALAPPDATA is unavailable; set X_USE_HOME to an absolute data directory." }
  105. $env:X_USE_HOME = Join-Path $env:LOCALAPPDATA "x-use"
  106. }
  107. $dataHome = $env:X_USE_HOME
  108. # --- shared uv/browser setup -----------------------------------------------------------
  109. $setupScript = Join-Path $Dir "scripts\setup_uv.py"
  110. if (-not (Test-Path -LiteralPath $setupScript)) { Fail "the checkout is missing scripts\setup_uv.py." }
  111. $setupArgs = $pyArgs + @($setupScript)
  112. if ($Dev) { $setupArgs += "--dev" }
  113. if ($SkipBrowser) { $setupArgs += "--skip-browser" }
  114. Write-Info "Setting up uv, x-use and the configured browser ..."
  115. Invoke-Native $pyExe $setupArgs "x-use setup"
  116. $binDir = Join-Path $Dir ".venv\Scripts"
  117. $xuseBin = Join-Path $binDir "x-use.exe"
  118. if (-not (Test-Path -LiteralPath $xuseBin)) { Fail "setup finished but x-use.exe was not found in $binDir." }
  119. # --- done -------------------------------------------------------------------------------
  120. Write-Host ""
  121. Write-Host "x-use is installed." -ForegroundColor White
  122. $quotedDir = $Dir.Replace("'", "''")
  123. $quotedBin = $xuseBin.Replace("'", "''")
  124. $configScript = Join-Path $Dir "scripts\mcp_config.py"
  125. $configArgs = $pyArgs + @($configScript, $xuseBin, $dataHome)
  126. $mcpConfig = (& $pyExe @configArgs | Out-String).Trim()
  127. if ($LASTEXITCODE -ne 0 -or -not $mcpConfig) { Fail "could not render the MCP client configuration." }
  128. $quotedDataHome = $dataHome.Replace("'", "''")
  129. Write-Host @"
  130. Next steps:
  131. 1. Set-Location -LiteralPath '$quotedDir'
  132. 2. `$env:X_USE_HOME = '$quotedDataHome'
  133. 3. & '$quotedBin' init # interactive wizard: account, cookies, LLM keys
  134. 4. & '$quotedBin' doctor # re-check until every row is PASS/SKIP
  135. 5. & '$quotedBin' run # or connect an MCP client (below)
  136. MCP client config (claude_desktop_config.json):
  137. $mcpConfig
  138. Docs: README.md, BEST_PRACTICES.md, docs\CONFIG_REFERENCE.md
  139. "@
  140. # Exit 0 explicitly: doctor's non-zero exit (unconfigured setup is expected on
  141. # first install) must not make a successful install look failed to callers.
  142. exit 0
install.sh · Bundled script · 182 lines · 2 findings marked
  1. #!/usr/bin/env bash
  2. #
  3. # install.sh - one-click installer for x-use.
  4. #
  5. # Usage:
  6. # curl -fsSL https://raw.githubusercontent.com/ihuzaifashoukat/x-use/main/install.sh | bash
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 6 on GitHub
  7. # ./install.sh [--dir PATH] [--dev] [--update] [--skip-browser] [--with-system-deps]
  8. #
  9. # What it does:
  10. # 1. Preflight: git and Python >= 3.11 must be present.
  11. # 2. Clone the repo (or reuse/update an existing clone, or install in
  12. # place when run from inside the repo).
  13. # 3. Bootstrap uv locally if needed and synchronize .venv from uv.lock.
  14. # 4. Install Chromium for the configured Patchright or Playwright backend.
  15. # 5. Create missing sample config and run doctor without overwriting config.
  16. #
  17. # The script is idempotent: re-running it reuses the clone and the venv.
  18. # Administrator changes are opt-in with --with-system-deps on Linux. uv and
  19. # browser drivers use their normal user caches; no global Python packages change.
  20. set -euo pipefail
  21. # XUSE_REPO_URL overrides the clone source (forks, mirrors, testing).
  22. readonly REPO_URL="${XUSE_REPO_URL:-https://github.com/ihuzaifashoukat/x-use.git}"
  23. readonly DEFAULT_DIR="x-use"
  24. readonly MIN_PYTHON_MAJOR=3
  25. readonly MIN_PYTHON_MINOR=11
  26. INSTALL_DIR=""
  27. DEV_INSTALL=0
  28. UPDATE=0
  29. SKIP_BROWSER=0
  30. WITH_SYSTEM_DEPS=0
  31. # --- output helpers -----------------------------------------------------------
  32. if [[ -t 1 && -z "${NO_COLOR:-}" ]]; then
  33. C_RESET=$'\033[0m'; C_BOLD=$'\033[1m'
  34. C_GREEN=$'\033[32m'; C_YELLOW=$'\033[33m'; C_RED=$'\033[31m'
  35. else
  36. C_RESET=""; C_BOLD=""; C_GREEN=""; C_YELLOW=""; C_RED=""
  37. fi
  38. info() { printf '%s==>%s %s\n' "${C_GREEN}" "${C_RESET}" "$*"; }
  39. warn() { printf '%swarn:%s %s\n' "${C_YELLOW}" "${C_RESET}" "$*" >&2; }
  40. die() { printf '%serror:%s %s\n' "${C_RED}" "${C_RESET}" "$*" >&2; exit 1; }
  41. trap 'die "installation failed at line ${LINENO} - re-run with bash -x install.sh for a trace."' ERR
  42. usage() {
  43. cat <<'EOF'
  44. install.sh - one-click installer for x-use.
  45. Usage:
  46. curl -fsSL https://raw.githubusercontent.com/ihuzaifashoukat/x-use/main/install.sh | bash
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 55 on GitHub
  47. ./install.sh [--dir PATH] [--dev] [--update] [--skip-browser] [--with-system-deps]
  48. Options:
  49. --dir PATH Install into PATH instead of ./x-use
  50. --dev Install with dev extras (pytest) for contributors
  51. --update git pull --ff-only an existing checkout before installing
  52. --skip-browser Reuse an already-installed matching browser
  53. --with-system-deps Allow Linux OS-package installation (may request sudo)
  54. -h, --help Show this help
  55. EOF
  56. exit "${1:-0}"
  57. }
  58. # --- arguments ----------------------------------------------------------------
  59. while [[ $# -gt 0 ]]; do
  60. case "$1" in
  61. --dir)
  62. [[ $# -ge 2 ]] || die "--dir requires a path argument."
  63. INSTALL_DIR="$2"; shift 2 ;;
  64. --dir=*)
  65. INSTALL_DIR="${1#*=}"; shift ;;
  66. --dev)
  67. DEV_INSTALL=1; shift ;;
  68. --update)
  69. UPDATE=1; shift ;;
  70. --skip-browser)
  71. SKIP_BROWSER=1; shift ;;
  72. --with-system-deps)
  73. WITH_SYSTEM_DEPS=1; shift ;;
  74. -h|--help)
  75. usage 0 ;;
  76. *)
  77. die "unknown option '$1' (try --help)." ;;
  78. esac
  79. done
  80. # --- preflight ------------------------------------------------------------------
  81. command -v git >/dev/null 2>&1 || die "git is not installed (or not on PATH)."
  82. PYTHON=""
  83. for candidate in python3 python; do
  84. command -v "${candidate}" >/dev/null 2>&1 || continue
  85. if "${candidate}" -c "import sys; raise SystemExit(0 if sys.version_info >= (${MIN_PYTHON_MAJOR}, ${MIN_PYTHON_MINOR}) else 1)" 2>/dev/null; then
  86. PYTHON="${candidate}"
  87. break
  88. fi
  89. done
  90. [[ -n "${PYTHON}" ]] || die "Python ${MIN_PYTHON_MAJOR}.${MIN_PYTHON_MINOR}+ not found. Install it from https://www.python.org/downloads/ and re-run."
  91. PY_VERSION="$("${PYTHON}" -c 'import sys; print("%d.%d.%d" % sys.version_info[:3])')"
  92. info "git $(git --version | awk '{print $3}'), python ${PY_VERSION} - preflight OK."
  93. # --- repo: clone / update / in-place ---------------------------------------------
  94. if [[ -z "${INSTALL_DIR}" && -f "pyproject.toml" ]] && grep -q '^name = "x-use' pyproject.toml 2>/dev/null; then
  95. # Running from inside the repo: install in place.
  96. INSTALL_DIR="$(pwd)"
  97. fi
  98. INSTALL_DIR="${INSTALL_DIR:-${DEFAULT_DIR}}"
  99. if [[ -f "${INSTALL_DIR}/pyproject.toml" ]] && grep -q '^name = "x-use' "${INSTALL_DIR}/pyproject.toml" 2>/dev/null; then
  100. if [[ "${UPDATE}" -eq 1 ]]; then
  101. info "Updating existing clone in ${INSTALL_DIR} ..."
  102. git -C "${INSTALL_DIR}" pull --ff-only || die "git pull failed; the existing checkout was not updated."
  103. else
  104. info "Existing x-use checkout found in ${INSTALL_DIR} - reusing it (pass --update to pull latest)."
  105. fi
  106. else
  107. if [[ -e "${INSTALL_DIR}" ]]; then
  108. die "'${INSTALL_DIR}' exists but is not an x-use checkout. Pick another --dir or remove it."
  109. fi
  110. info "Cloning ${REPO_URL} -> ${INSTALL_DIR} ..."
  111. git clone --depth 1 "${REPO_URL}" "${INSTALL_DIR}"
  112. [[ -f "${INSTALL_DIR}/pyproject.toml" ]] && grep -q '^name = "x-use' "${INSTALL_DIR}/pyproject.toml" 2>/dev/null \
  113. || die "the clone does not look like x-use v2 (missing pyproject.toml). The default branch may predate the v2 merge - clone the right branch or set XUSE_REPO_URL."
  114. fi
  115. # --- shared uv/browser setup -----------------------------------------------------------
  116. INSTALL_DIR="$(cd "${INSTALL_DIR}" && pwd)"
  117. if [[ -z "${X_USE_HOME:-}" ]]; then
  118. DATA_BASE="${XDG_DATA_HOME:-${HOME:?HOME is required to choose a data directory}/.local/share}"
  119. X_USE_HOME="${DATA_BASE%/}/x-use"
  120. fi
  121. if command -v cygpath >/dev/null 2>&1; then
  122. X_USE_HOME="$(cygpath -w "${X_USE_HOME}")"
  123. fi
  124. export X_USE_HOME
  125. SETUP_SCRIPT="${INSTALL_DIR}/scripts/setup_uv.py"
  126. [[ -f "${SETUP_SCRIPT}" ]] || die "the checkout is missing scripts/setup_uv.py."
  127. SETUP_ARGS=("${SETUP_SCRIPT}")
  128. [[ "${DEV_INSTALL}" -eq 0 ]] || SETUP_ARGS+=(--dev)
  129. [[ "${SKIP_BROWSER}" -eq 0 ]] || SETUP_ARGS+=(--skip-browser)
  130. [[ "${WITH_SYSTEM_DEPS}" -eq 0 ]] || SETUP_ARGS+=(--with-system-deps)
  131. info "Setting up uv, x-use and the configured browser ..."
  132. "${PYTHON}" "${SETUP_ARGS[@]}"
  133. BIN_DIR="${INSTALL_DIR}/.venv/bin"
  134. [[ -x "${BIN_DIR}/x-use" ]] || BIN_DIR="${INSTALL_DIR}/.venv/Scripts"
  135. XUSE_BIN="${BIN_DIR}/x-use"
  136. [[ -x "${XUSE_BIN}" ]] || XUSE_BIN="${BIN_DIR}/x-use.exe"
  137. [[ -x "${XUSE_BIN}" ]] || die "setup finished but the x-use command was not found in ${BIN_DIR}."
  138. # --- done -------------------------------------------------------------------------------
  139. # Claude Desktop on Windows needs a C:\... path; cygpath converts when available.
  140. MCP_BIN="$(cygpath -w "${XUSE_BIN}" 2>/dev/null || printf '%s' "${XUSE_BIN}")"
  141. MCP_CONFIG="$("${PYTHON}" "${INSTALL_DIR}/scripts/mcp_config.py" "${MCP_BIN}" "${X_USE_HOME}")"
  142. INSTALL_DIR_Q="$(printf '%q' "${INSTALL_DIR}")"
  143. DATA_HOME_Q="$(printf '%q' "${X_USE_HOME}")"
  144. printf '\n%sx-use is installed.%s\n' "${C_BOLD}" "${C_RESET}"
  145. cat <<EOF
  146. Next steps:
  147. 1. cd -- ${INSTALL_DIR_Q}
  148. 2. export X_USE_HOME=${DATA_HOME_Q}
  149. 3. "${XUSE_BIN}" init # interactive wizard: account, cookies, LLM keys
  150. 4. "${XUSE_BIN}" doctor # re-check until every row is PASS/SKIP
  151. 5. "${XUSE_BIN}" run # or connect an MCP client (below)
  152. MCP client config (e.g. claude_desktop_config.json):
  153. ${MCP_CONFIG}
  154. Docs: README.md, BEST_PRACTICES.md, docs/CONFIG_REFERENCE.md
  155. EOF

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.