Mcp Server For 3x Ui

Created By
pyworkload2 months ago
MCP server for 3x-ui — an Xray/V2Ray proxy management panel. Exposes the 3x-ui HTTP API as MCP tools so LLMs can manage inbounds, clients, routing rules, Xray service, and server settings.
Overview

3x-ui MCP Server

CI Release Go Report Card License: MIT

MCP (Model Context Protocol) server for 3x-ui — an Xray/V2Ray proxy management panel. Exposes the 3x-ui HTTP API as MCP tools so LLMs can manage inbounds, clients, routing rules, Xray service, and server settings.

Features

  • 40 MCP tools covering the full 3x-ui API
  • Automatic session management with transparent re-authentication
  • Stdio transport for seamless LLM integration
  • Zero external dependencies beyond the MCP SDK

Usage

Add to your MCP config (claude_desktop_config.json or .mcp.json):

{
  "mcpServers": {
    "3x-ui": {
      "command": "go",
      "args": ["run", "github.com/pyworkload/3x-ui-mcp/cmd/xui-mcp@latest"],
      "env": {
        "XUI_HOST": "http://localhost:2053",
        "XUI_USERNAME": "admin",
        "XUI_PASSWORD": "your-password"
      }
    }
  }
}

Requires Go 1.23+. First run downloads and compiles automatically, subsequent runs use cache.

With pre-built binary

Download from Releases, then:

{
  "mcpServers": {
    "3x-ui": {
      "command": "/path/to/xui-mcp",
      "env": {
        "XUI_HOST": "http://localhost:2053",
        "XUI_USERNAME": "admin",
        "XUI_PASSWORD": "your-password"
      }
    }
  }
}

Configuration

VariableRequiredDescriptionExample
XUI_HOSTYesPanel URLhttp://localhost:2053
XUI_USERNAMEYesAdmin usernameadmin
XUI_PASSWORDYesAdmin passwordadmin
XUI_BASE_PATHNoPanel base path (default: /)/xui/
XUI_LOG_LEVELNoLog level (default: info)debug, info, warn, error

MCP Tools

Inbound Management (5 tools)

ToolDescription
list_inboundsList all inbound connections
get_inboundGet inbound by ID
create_inboundCreate a new inbound
update_inboundUpdate an existing inbound
delete_inboundDelete an inbound

Client Management (14 tools)

ToolDescription
add_clientAdd a client to an inbound
update_clientUpdate client configuration
delete_clientDelete a client by inbound ID and UUID
delete_client_by_emailDelete a client by email
get_client_trafficGet client traffic stats by email
get_client_traffic_by_idGet client traffic stats by UUID
get_client_ipsGet IPs used by a client
clear_client_ipsClear recorded client IPs
reset_client_trafficReset traffic counters for a client
reset_all_trafficsReset all inbound traffic counters
reset_all_client_trafficsReset all client traffic counters
delete_depleted_clientsDelete clients with exhausted traffic/expired
get_online_clientsList currently connected clients
update_client_trafficUpdate client traffic limits

Server Management (11 tools)

ToolDescription
server_statusGet server system status (CPU, RAM, disk, uptime)
restart_xrayRestart Xray service
stop_xrayStop Xray service
get_xray_configGet current Xray runtime configuration
get_xray_versionsList available Xray versions
install_xrayInstall a specific Xray version
get_logsGet panel service logs
get_xray_logsGet Xray core logs
get_settingsGet panel settings
get_default_xray_configGet default Xray configuration
restart_panelRestart the 3x-ui panel

Xray Configuration (10 tools)

ToolDescription
get_xray_templateGet Xray JSON template
update_xray_templateUpdate Xray JSON template
get_routing_rulesList all routing rules
add_routing_ruleAdd a routing rule
remove_routing_ruleRemove a routing rule by index
update_routing_ruleUpdate a routing rule by index
get_outboundsList all outbounds
get_outbounds_trafficGet outbound traffic statistics
reset_outbound_trafficReset traffic for an outbound tag
test_outboundTest connectivity of an outbound

Architecture

cmd/xui-mcp/main.go        Entry point, config loading, signal handling
internal/config/            Configuration from environment variables
internal/xui/              HTTP client with session management
internal/handler/          MCP tool definitions and request handlers

Development

make test       # Run tests
make lint       # Run linters
make fmt        # Format code
make build      # Build binary

License

MIT

Server Config

{
  "mcpServers": {
    "3x-ui": {
      "command": "go",
      "args": [
        "run",
        "github.com/pyworkload/3x-ui-mcp/cmd/xui-mcp@latest"
      ],
      "env": {
        "XUI_HOST": "http://localhost:2053",
        "XUI_USERNAME": "<your-username>",
        "XUI_PASSWORD": "<your-password>"
      }
    }
  }
}
Project Info
Created At
2 months ago
Updated At
2 months ago
Author Name
pyworkload
Star
-
Language
-
License
-
Category

Recommend Servers

View All
Bring your real authenticated browser session to AI coding agents. Local-first MCP server + Chrome MV3 extension. No cloud. No telemetry.
@Cubenest

peek records the user's actual logged-in browser (DOM via rrweb, console events, network metadata, optional response bodies via opt-in Deep capture) through a Chrome MV3 extension. The extension ships events through a native-messaging stdio bridge to a local MCP server (peek-mcp), which persists them to a SQLite database at ~/.peek/sessions.db. AI coding agents (Claude Code, Cursor, Cline, Windsurf) read sessions from the database via 10 MCP tools: Tool What it does list_recent_sessions List recently recorded sessions (id, origin, ts, event count). get_session_summary LLM-readable narrative summary of a session. get_session_console_errors Console errors recorded in a session. get_session_network_errors Failed/notable network requests in a session. get_user_action_before_error Last N user actions before a console error. generate_playwright_repro Generate a runnable Playwright test from a session. get_dom_snapshot Reconstruct the DOM at a given timestamp. query_dom_history Timeline of attribute/text changes for a selector. request_authorization Side-panel consent for write actions (Level 3). execute_action Dispatch a UI action (gated by permission level + destructive blocklist). Why local-first matters Every other "browser session for AI" tool ships to a vendor cloud. peek's SQLite + extension live on the user's machine — no remote endpoints, no telemetry. The privacy policy (docs/peek/PRIVACY_POLICY.md) is the source of truth. Install # 1. Add the MCP server to Claude Code claude mcp add peek -- npx -y @peekdev/mcp # 2. Install the Chrome extension from the Chrome Web Store # (link added once the CWS listing is approved)

a day ago