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.
Badge for your README
Markdown
[](/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
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
- {
- "$schema": "https://json.schemastore.org/claude-code-marketplace.json",
- "name": "x-use",
- "version": "1.0.0",
- "description": "Claude Code plugins for browser-native X workflows.",
- "owner": {
- "name": "Huzaifa Shoukat"
- },
- "plugins": [
- {
- "name": "x-use",
- "source": "./plugins/x-use",
- "description": "Connect Claude Code to x-use MCP for research, inbox reads, reviewed outreach, campaigns, posts, and threads.",
- "version": "3.3.0",
- "category": "productivity"
- }
- ]
- }
README.md · README · 210 lines
- # x-use — MCP server for X (Twitter)
- <!-- mcp-name: io.github.ihuzaifashoukat/x-use -->
- [](https://github.com/ihuzaifashoukat/x-use)
- **Connect your AI client to X research, inbox reads, and reviewed publishing.**
- 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.
- [](https://pypi.org/project/x-use-mcp/)
- [](https://pypi.org/project/x-use-mcp/)
- [](https://github.com/ihuzaifashoukat/x-use/actions/workflows/ci.yml)
- [](https://github.com/ihuzaifashoukat/x-use/blob/main/LICENSE)
- [](https://github.com/ihuzaifashoukat/x-use/stargazers)
- [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)
- ## What can you do with x-use?
- - **Research before replying:** search X, inspect a profile, read posts and bounded thread context, and prepare a relevant reply.
- - **Work through your inbox:** inspect visible conversations, unread messages, requests and notifications; prepare individual messages and supported conversation actions for review.
- - **Publish with context:** stage posts or multi-post threads, inspect the exact text, and approve the draft when it is ready.
- - **Organize outreach locally:** maintain leads, opt-outs and campaign drafts with per-account limits and delivery tracking.
- 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.
- ## Quickstart
- 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
- ```bash
- python -m pip install --upgrade x-use-mcp
- python -m patchright install chromium
- ```
- ### 2. Choose a private data directory and initialize
- Windows PowerShell:
- ```powershell
- $env:X_USE_HOME = "$env:LOCALAPPDATA\x-use"
- x-use init
- x-use doctor
- ```
- macOS / Linux:
- ```bash
- 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:
- ```json
- {
- "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>
- ```bash
- 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:
- ```bash
- 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>
- ## Capabilities
- | Workflow | Representative tools | Details |
- |---|---|---|
- | Profile and post research | `get_profile_context`, `search_profile`, `search_tweets`, `get_tweet`, `get_thread` | Visible profile, post, media and bounded thread evidence |
- | Inbox and notifications | `get_inbox`, `search_conversations`, `get_conversation`, `get_notifications` | Inbox/request folders, read-state evidence and partial message history |
- | 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) |
- | Reviewed publishing | `post_tweet`, `reply_to_tweet`, `prepare_thread`, `approve_draft` | Persistent drafts and resumable thread progress |
- | Individual outreach | `prepare_outreach`, `send_message`, `follow_profile` | Message and follow drafts require individual approval |
- | Leads and campaigns | `upsert_lead`, `create_campaign`, `prepare_campaign_messages`, `opt_out_lead` | Local records, suppression and bounded batches |
- | 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 |
- | Scheduling and recovery | `queue_post`, `process_queue`, `get_account_health`, `resolve_action_outcome` | Durable budgets, explicit recovery and uncertain-outcome tracking |
- **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.
- 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.
- For a uvx client, use `uvx x-use-mcp` or pin the release with
- `uvx x-use-mcp==3.3.0`. The `x-use-mcp` executable starts MCP without arguments;
- the existing `x-use mcp` command remains supported. Clients pinned to 3.0.0
- must use `uvx --from x-use-mcp==3.0.0 x-use mcp`.
- ## How execution works
- 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.
- 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.
- 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.
- 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.
- ## Limits to understand
- - Browser reads are bounded by visible X content. Followers, inboxes and threads are not complete exports; unavailable evidence remains unknown.
- - Opening conversations or notifications can change their native read state.
- - Encrypted inboxes may need the account owner's PIN again after a browser-context restart.
- - Analytics currently reports availability and the observed Premium gate; it does not provide a complete analytics dashboard.
- - X layout changes, expired sessions, account challenges and platform limits can interrupt work. Local controls do not guarantee protection from account restrictions.
- - 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.
- 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).
- ## Frequently asked questions
- ### Does x-use require an X API key?
- 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.
- ### Which MCP clients can use x-use?
- 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.
- ### Does x-use automatically send every drafted message?
- 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.
- ### Can I manage multiple X accounts?
- 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.
- ### Can I edit posts or manage my X inbox?
- 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.
- ### Is x-use free and open source?
- The project is MIT licensed with no project license fee. AI-client subscriptions, optional model providers, proxies and hosting may have their own costs.
- ### Is x-use affiliated with X?
- No. x-use is an independent community project. X and Twitter are names used to identify the platform it works with.
- ### Was this project called twitter-automation-ai?
- 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.
- ## Documentation and community
- 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.
- 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.
- 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.
- ## Star history
- <a href="https://www.star-history.com/?repos=ihuzaifashoukat%2Fx-use&type=date&legend=top-left">
- <picture>
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=ihuzaifashoukat/x-use&type=date&legend=top-left&theme=dark" />
- <img alt="Live star history for x-use" src="https://api.star-history.com/svg?repos=ihuzaifashoukat/x-use&type=date&legend=top-left" />
- </picture>
- </a>
- ## License
- [MIT](https://github.com/ihuzaifashoukat/x-use/blob/main/LICENSE).
install.ps1 · Bundled script · 167 lines · 1 finding marked
- <#
- .SYNOPSIS
- One-click installer for x-use on Windows.
- .DESCRIPTION
- 1. Preflight: git and Python >= 3.11 must be present.
- 2. Clone the repo (or reuse/update an existing clone, or install in
- place when run from inside the repo).
- 3. Bootstrap uv locally when needed and synchronize .venv from uv.lock.
- 4. Install Chromium for the configured Patchright or Playwright backend.
- 5. Create missing sample config and run doctor; existing config is retained.
- Re-running reuses the checkout and environment. No global Python packages
- or administrator changes are required.
- .EXAMPLE
- powershell -ExecutionPolicy Bypass -File install.ps1
- .EXAMPLE
- iex "& { $(irm https://raw.githubusercontent.com/ihuzaifashoukat/x-use/main/install.ps1) }"
- .EXAMPLE
- .\install.ps1 -Dir C:\tools\x-use -Dev -Update
- #>
- [CmdletBinding()]
- param(
- # Install directory. Defaults to .\x-use, or the current directory when
- # run from inside the repo. Env: XUSE_INSTALL_DIR (used by irm|iex).
- Note: Runs a downloaded PowerShell script (iex / Invoke-Expression)
- Line 28 on GitHub
- [string]$Dir = $(if ($env:XUSE_INSTALL_DIR) { $env:XUSE_INSTALL_DIR } else { "" }),
- # Install with dev extras (pytest) for contributors.
- [switch]$Dev,
- # Reuse a browser already installed for the selected browser-driver version.
- [switch]$SkipBrowser,
- # git pull --ff-only an existing checkout before installing.
- [switch]$Update,
- # Show usage and exit.
- [switch]$Help
- )
- Set-StrictMode -Version Latest
- $ErrorActionPreference = 'Stop'
- $RepoUrl = if ($env:XUSE_REPO_URL) { $env:XUSE_REPO_URL } else { "https://github.com/ihuzaifashoukat/x-use.git" }
- $MinPythonMajor = 3
- $MinPythonMinor = 11
- function Write-Info([string]$Msg) { Write-Host "==> $Msg" -ForegroundColor Green }
- function Write-Warn([string]$Msg) { Write-Host "warn: $Msg" -ForegroundColor Yellow }
- function Fail([string]$Msg) { Write-Host "error: $Msg" -ForegroundColor Red; exit 1 }
- # Native commands do not throw on failure; check the exit code ourselves.
- function Invoke-Native([string]$File, [string[]]$CmdArgs, [string]$What) {
- & $File @CmdArgs
- if ($LASTEXITCODE -ne 0) { Fail "$What failed (exit code $LASTEXITCODE)." }
- }
- if ($Help) {
- Get-Help $MyInvocation.MyCommand.Path
- exit 0
- }
- # --- preflight ------------------------------------------------------------------
- if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
- Fail "git is not installed (or not on PATH). Get it from https://git-scm.com/download/win"
- }
- $Python = $null
- $candidates = @()
- if (Get-Command py -ErrorAction SilentlyContinue) { $candidates += , @("py", @("-3")) }
- if (Get-Command python -ErrorAction SilentlyContinue) { $candidates += , @("python", @()) }
- foreach ($candidate in $candidates) {
- $exe = $candidate[0]; $exeArgs = $candidate[1]
- & $exe @exeArgs -c "import sys; raise SystemExit(0 if sys.version_info >= ($MinPythonMajor, $MinPythonMinor) else 1)" 2>$null
- if ($LASTEXITCODE -eq 0) { $Python = $candidate; break }
- }
- if (-not $Python) {
- Fail "Python $MinPythonMajor.$MinPythonMinor+ not found. Install it from https://www.python.org/downloads/ (tick 'Add python.exe to PATH') and re-run."
- }
- $pyExe = $Python[0]; $pyArgs = $Python[1]
- # No embedded double quotes in -c strings: PowerShell strips them when
- # passing arguments to native commands.
- $pyVersion = (& $pyExe @pyArgs -c 'import sys; print(sys.version.split()[0])')
- $gitVersion = (git --version) -replace '^git version ', ''
- Write-Info "git $gitVersion, python $pyVersion - preflight OK."
- # --- repo: clone / update / in-place ---------------------------------------------
- function Test-XUseCheckout([string]$Path) {
- $pyproject = Join-Path $Path "pyproject.toml"
- if (-not (Test-Path $pyproject)) { return $false }
- return [bool](Select-String -Path $pyproject -Pattern '^name = "x-use' -Quiet)
- }
- if (-not $Dir -and (Test-XUseCheckout (Get-Location).Path)) {
- # Running from inside the repo: install in place.
- $Dir = (Get-Location).Path
- }
- if (-not $Dir) { $Dir = "x-use" }
- if (Test-XUseCheckout $Dir) {
- if ($Update) {
- Write-Info "Updating existing clone in $Dir ..."
- git -C $Dir pull --ff-only
- if ($LASTEXITCODE -ne 0) { Fail "git pull failed; the existing checkout was not updated." }
- } else {
- Write-Info "Existing x-use checkout found in $Dir - reusing it (pass -Update to pull latest)."
- }
- } else {
- if (Test-Path $Dir) {
- Fail "'$Dir' exists but is not an x-use checkout. Pick another -Dir or remove it."
- }
- Write-Info "Cloning $RepoUrl -> $Dir ..."
- Invoke-Native git @("clone", "--depth", "1", $RepoUrl, $Dir) "git clone"
- if (-not (Test-XUseCheckout $Dir)) {
- 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."
- }
- }
- $Dir = (Resolve-Path $Dir).Path
- if (-not $env:X_USE_HOME) {
- if (-not $env:LOCALAPPDATA) { Fail "LOCALAPPDATA is unavailable; set X_USE_HOME to an absolute data directory." }
- $env:X_USE_HOME = Join-Path $env:LOCALAPPDATA "x-use"
- }
- $dataHome = $env:X_USE_HOME
- # --- shared uv/browser setup -----------------------------------------------------------
- $setupScript = Join-Path $Dir "scripts\setup_uv.py"
- if (-not (Test-Path -LiteralPath $setupScript)) { Fail "the checkout is missing scripts\setup_uv.py." }
- $setupArgs = $pyArgs + @($setupScript)
- if ($Dev) { $setupArgs += "--dev" }
- if ($SkipBrowser) { $setupArgs += "--skip-browser" }
- Write-Info "Setting up uv, x-use and the configured browser ..."
- Invoke-Native $pyExe $setupArgs "x-use setup"
- $binDir = Join-Path $Dir ".venv\Scripts"
- $xuseBin = Join-Path $binDir "x-use.exe"
- if (-not (Test-Path -LiteralPath $xuseBin)) { Fail "setup finished but x-use.exe was not found in $binDir." }
- # --- done -------------------------------------------------------------------------------
- Write-Host ""
- Write-Host "x-use is installed." -ForegroundColor White
- $quotedDir = $Dir.Replace("'", "''")
- $quotedBin = $xuseBin.Replace("'", "''")
- $configScript = Join-Path $Dir "scripts\mcp_config.py"
- $configArgs = $pyArgs + @($configScript, $xuseBin, $dataHome)
- $mcpConfig = (& $pyExe @configArgs | Out-String).Trim()
- if ($LASTEXITCODE -ne 0 -or -not $mcpConfig) { Fail "could not render the MCP client configuration." }
- $quotedDataHome = $dataHome.Replace("'", "''")
- Write-Host @"
- Next steps:
- 1. Set-Location -LiteralPath '$quotedDir'
- 2. `$env:X_USE_HOME = '$quotedDataHome'
- 3. & '$quotedBin' init # interactive wizard: account, cookies, LLM keys
- 4. & '$quotedBin' doctor # re-check until every row is PASS/SKIP
- 5. & '$quotedBin' run # or connect an MCP client (below)
- MCP client config (claude_desktop_config.json):
- $mcpConfig
- Docs: README.md, BEST_PRACTICES.md, docs\CONFIG_REFERENCE.md
- "@
- # Exit 0 explicitly: doctor's non-zero exit (unconfigured setup is expected on
- # first install) must not make a successful install look failed to callers.
- exit 0
install.sh · Bundled script · 182 lines · 2 findings marked
- #!/usr/bin/env bash
- #
- # install.sh - one-click installer for x-use.
- #
- # Usage:
- # 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
- # ./install.sh [--dir PATH] [--dev] [--update] [--skip-browser] [--with-system-deps]
- #
- # What it does:
- # 1. Preflight: git and Python >= 3.11 must be present.
- # 2. Clone the repo (or reuse/update an existing clone, or install in
- # place when run from inside the repo).
- # 3. Bootstrap uv locally if needed and synchronize .venv from uv.lock.
- # 4. Install Chromium for the configured Patchright or Playwright backend.
- # 5. Create missing sample config and run doctor without overwriting config.
- #
- # The script is idempotent: re-running it reuses the clone and the venv.
- # Administrator changes are opt-in with --with-system-deps on Linux. uv and
- # browser drivers use their normal user caches; no global Python packages change.
- set -euo pipefail
- # XUSE_REPO_URL overrides the clone source (forks, mirrors, testing).
- readonly REPO_URL="${XUSE_REPO_URL:-https://github.com/ihuzaifashoukat/x-use.git}"
- readonly DEFAULT_DIR="x-use"
- readonly MIN_PYTHON_MAJOR=3
- readonly MIN_PYTHON_MINOR=11
- INSTALL_DIR=""
- DEV_INSTALL=0
- UPDATE=0
- SKIP_BROWSER=0
- WITH_SYSTEM_DEPS=0
- # --- output helpers -----------------------------------------------------------
- if [[ -t 1 && -z "${NO_COLOR:-}" ]]; then
- C_RESET=$'\033[0m'; C_BOLD=$'\033[1m'
- C_GREEN=$'\033[32m'; C_YELLOW=$'\033[33m'; C_RED=$'\033[31m'
- else
- C_RESET=""; C_BOLD=""; C_GREEN=""; C_YELLOW=""; C_RED=""
- fi
- info() { printf '%s==>%s %s\n' "${C_GREEN}" "${C_RESET}" "$*"; }
- warn() { printf '%swarn:%s %s\n' "${C_YELLOW}" "${C_RESET}" "$*" >&2; }
- die() { printf '%serror:%s %s\n' "${C_RED}" "${C_RESET}" "$*" >&2; exit 1; }
- trap 'die "installation failed at line ${LINENO} - re-run with bash -x install.sh for a trace."' ERR
- usage() {
- cat <<'EOF'
- install.sh - one-click installer for x-use.
- Usage:
- 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
- ./install.sh [--dir PATH] [--dev] [--update] [--skip-browser] [--with-system-deps]
- Options:
- --dir PATH Install into PATH instead of ./x-use
- --dev Install with dev extras (pytest) for contributors
- --update git pull --ff-only an existing checkout before installing
- --skip-browser Reuse an already-installed matching browser
- --with-system-deps Allow Linux OS-package installation (may request sudo)
- -h, --help Show this help
- EOF
- exit "${1:-0}"
- }
- # --- arguments ----------------------------------------------------------------
- while [[ $# -gt 0 ]]; do
- case "$1" in
- --dir)
- [[ $# -ge 2 ]] || die "--dir requires a path argument."
- INSTALL_DIR="$2"; shift 2 ;;
- --dir=*)
- INSTALL_DIR="${1#*=}"; shift ;;
- --dev)
- DEV_INSTALL=1; shift ;;
- --update)
- UPDATE=1; shift ;;
- --skip-browser)
- SKIP_BROWSER=1; shift ;;
- --with-system-deps)
- WITH_SYSTEM_DEPS=1; shift ;;
- -h|--help)
- usage 0 ;;
- *)
- die "unknown option '$1' (try --help)." ;;
- esac
- done
- # --- preflight ------------------------------------------------------------------
- command -v git >/dev/null 2>&1 || die "git is not installed (or not on PATH)."
- PYTHON=""
- for candidate in python3 python; do
- command -v "${candidate}" >/dev/null 2>&1 || continue
- if "${candidate}" -c "import sys; raise SystemExit(0 if sys.version_info >= (${MIN_PYTHON_MAJOR}, ${MIN_PYTHON_MINOR}) else 1)" 2>/dev/null; then
- PYTHON="${candidate}"
- break
- fi
- done
- [[ -n "${PYTHON}" ]] || die "Python ${MIN_PYTHON_MAJOR}.${MIN_PYTHON_MINOR}+ not found. Install it from https://www.python.org/downloads/ and re-run."
- PY_VERSION="$("${PYTHON}" -c 'import sys; print("%d.%d.%d" % sys.version_info[:3])')"
- info "git $(git --version | awk '{print $3}'), python ${PY_VERSION} - preflight OK."
- # --- repo: clone / update / in-place ---------------------------------------------
- if [[ -z "${INSTALL_DIR}" && -f "pyproject.toml" ]] && grep -q '^name = "x-use' pyproject.toml 2>/dev/null; then
- # Running from inside the repo: install in place.
- INSTALL_DIR="$(pwd)"
- fi
- INSTALL_DIR="${INSTALL_DIR:-${DEFAULT_DIR}}"
- if [[ -f "${INSTALL_DIR}/pyproject.toml" ]] && grep -q '^name = "x-use' "${INSTALL_DIR}/pyproject.toml" 2>/dev/null; then
- if [[ "${UPDATE}" -eq 1 ]]; then
- info "Updating existing clone in ${INSTALL_DIR} ..."
- git -C "${INSTALL_DIR}" pull --ff-only || die "git pull failed; the existing checkout was not updated."
- else
- info "Existing x-use checkout found in ${INSTALL_DIR} - reusing it (pass --update to pull latest)."
- fi
- else
- if [[ -e "${INSTALL_DIR}" ]]; then
- die "'${INSTALL_DIR}' exists but is not an x-use checkout. Pick another --dir or remove it."
- fi
- info "Cloning ${REPO_URL} -> ${INSTALL_DIR} ..."
- git clone --depth 1 "${REPO_URL}" "${INSTALL_DIR}"
- [[ -f "${INSTALL_DIR}/pyproject.toml" ]] && grep -q '^name = "x-use' "${INSTALL_DIR}/pyproject.toml" 2>/dev/null \
- || 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."
- fi
- # --- shared uv/browser setup -----------------------------------------------------------
- INSTALL_DIR="$(cd "${INSTALL_DIR}" && pwd)"
- if [[ -z "${X_USE_HOME:-}" ]]; then
- DATA_BASE="${XDG_DATA_HOME:-${HOME:?HOME is required to choose a data directory}/.local/share}"
- X_USE_HOME="${DATA_BASE%/}/x-use"
- fi
- if command -v cygpath >/dev/null 2>&1; then
- X_USE_HOME="$(cygpath -w "${X_USE_HOME}")"
- fi
- export X_USE_HOME
- SETUP_SCRIPT="${INSTALL_DIR}/scripts/setup_uv.py"
- [[ -f "${SETUP_SCRIPT}" ]] || die "the checkout is missing scripts/setup_uv.py."
- SETUP_ARGS=("${SETUP_SCRIPT}")
- [[ "${DEV_INSTALL}" -eq 0 ]] || SETUP_ARGS+=(--dev)
- [[ "${SKIP_BROWSER}" -eq 0 ]] || SETUP_ARGS+=(--skip-browser)
- [[ "${WITH_SYSTEM_DEPS}" -eq 0 ]] || SETUP_ARGS+=(--with-system-deps)
- info "Setting up uv, x-use and the configured browser ..."
- "${PYTHON}" "${SETUP_ARGS[@]}"
- BIN_DIR="${INSTALL_DIR}/.venv/bin"
- [[ -x "${BIN_DIR}/x-use" ]] || BIN_DIR="${INSTALL_DIR}/.venv/Scripts"
- XUSE_BIN="${BIN_DIR}/x-use"
- [[ -x "${XUSE_BIN}" ]] || XUSE_BIN="${BIN_DIR}/x-use.exe"
- [[ -x "${XUSE_BIN}" ]] || die "setup finished but the x-use command was not found in ${BIN_DIR}."
- # --- done -------------------------------------------------------------------------------
- # Claude Desktop on Windows needs a C:\... path; cygpath converts when available.
- MCP_BIN="$(cygpath -w "${XUSE_BIN}" 2>/dev/null || printf '%s' "${XUSE_BIN}")"
- MCP_CONFIG="$("${PYTHON}" "${INSTALL_DIR}/scripts/mcp_config.py" "${MCP_BIN}" "${X_USE_HOME}")"
- INSTALL_DIR_Q="$(printf '%q' "${INSTALL_DIR}")"
- DATA_HOME_Q="$(printf '%q' "${X_USE_HOME}")"
- printf '\n%sx-use is installed.%s\n' "${C_BOLD}" "${C_RESET}"
- cat <<EOF
- Next steps:
- 1. cd -- ${INSTALL_DIR_Q}
- 2. export X_USE_HOME=${DATA_HOME_Q}
- 3. "${XUSE_BIN}" init # interactive wizard: account, cookies, LLM keys
- 4. "${XUSE_BIN}" doctor # re-check until every row is PASS/SKIP
- 5. "${XUSE_BIN}" run # or connect an MCP client (below)
- MCP client config (e.g. claude_desktop_config.json):
- ${MCP_CONFIG}
- Docs: README.md, BEST_PRACTICES.md, docs/CONFIG_REFERENCE.md
- EOF
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.