@pyworkload/3x-ui-mcp 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # @pyworkload/3x-ui-mcp
2
+
3
+ MCP (Model Context Protocol) server for [3x-ui](https://github.com/MHSanaei/3x-ui) —
4
+ an Xray/V2Ray proxy management panel. It exposes the panel's HTTP API as 166 MCP
5
+ tools, so an LLM agent can manage inbounds, clients, routing rules, balancers,
6
+ nodes and the Xray service itself.
7
+
8
+ This package ships prebuilt binaries: nothing is compiled and nothing is
9
+ downloaded at install time. The Go toolchain is not required.
10
+
11
+ ## Use it
12
+
13
+ ```json
14
+ {
15
+ "mcpServers": {
16
+ "3x-ui": {
17
+ "command": "npx",
18
+ "args": ["-y", "@pyworkload/3x-ui-mcp"],
19
+ "env": {
20
+ "XUI_HOST": "http://localhost:2053",
21
+ "XUI_USERNAME": "admin",
22
+ "XUI_PASSWORD": "your-password"
23
+ }
24
+ }
25
+ }
26
+ }
27
+ ```
28
+
29
+ For Claude Code:
30
+
31
+ ```bash
32
+ claude mcp add 3x-ui \
33
+ --env XUI_HOST=http://localhost:2053 \
34
+ --env XUI_USERNAME=admin \
35
+ --env XUI_PASSWORD=your-password \
36
+ -- npx -y @pyworkload/3x-ui-mcp
37
+ ```
38
+
39
+ Provide either `XUI_USERNAME` + `XUI_PASSWORD` or `XUI_API_TOKEN`. Optional:
40
+ `XUI_BASE_PATH`, `XUI_LOG_LEVEL`, and `XUI_TOOLSETS` to load only the tool groups
41
+ you need instead of all 166.
42
+
43
+ Requires 3x-ui **v3.3.0+**. Some tools need newer panels; the
44
+ [main README](https://github.com/pyworkload/3x-ui-mcp#panel-versions) has the table.
45
+
46
+ ## Platforms
47
+
48
+ Linux, macOS and Windows on x64 and arm64. The binary is statically linked
49
+ (`CGO_ENABLED=0`), so the Linux build runs on glibc and musl alike.
50
+
51
+ The matching binary arrives as an optional dependency, one package per platform,
52
+ so an install pulls exactly one of them. Installing with `--omit=optional` skips
53
+ it and the CLI will say so rather than failing obscurely.
54
+
55
+ ## Documentation
56
+
57
+ Full tool reference, agent skills and panel-version notes:
58
+ <https://github.com/pyworkload/3x-ui-mcp>
59
+
60
+ MIT licensed.
package/bin/xui-mcp.js ADDED
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+ // Locates the prebuilt xui-mcp binary for this platform and hands the process
3
+ // over to it. The binary ships in a per-platform package pulled in through
4
+ // optionalDependencies, so nothing is downloaded or compiled at install time.
5
+ 'use strict';
6
+
7
+ const { spawnSync } = require('node:child_process');
8
+ const path = require('node:path');
9
+
10
+ // process.platform + process.arch -> the package carrying that build.
11
+ const PACKAGES = {
12
+ 'darwin arm64': '@pyworkload/3x-ui-mcp-darwin-arm64',
13
+ 'darwin x64': '@pyworkload/3x-ui-mcp-darwin-x64',
14
+ 'linux arm64': '@pyworkload/3x-ui-mcp-linux-arm64',
15
+ 'linux x64': '@pyworkload/3x-ui-mcp-linux-x64',
16
+ 'win32 arm64': '@pyworkload/3x-ui-mcp-win32-arm64',
17
+ 'win32 x64': '@pyworkload/3x-ui-mcp-win32-x64',
18
+ };
19
+
20
+ function fail(message) {
21
+ // stdout carries the MCP protocol, so diagnostics go to stderr only.
22
+ process.stderr.write(`3x-ui-mcp: ${message}\n`);
23
+ process.exit(1);
24
+ }
25
+
26
+ function resolveBinary() {
27
+ const target = `${process.platform} ${process.arch}`;
28
+ const pkg = PACKAGES[target];
29
+ if (!pkg) {
30
+ fail(
31
+ `no prebuilt binary for ${target}. Supported: ${Object.keys(PACKAGES).join(', ')}. ` +
32
+ 'Build from source instead: go install github.com/pyworkload/3x-ui-mcp/cmd/xui-mcp@latest',
33
+ );
34
+ }
35
+
36
+ const exe = process.platform === 'win32' ? 'xui-mcp.exe' : 'xui-mcp';
37
+ try {
38
+ // Resolve through package.json: the binary itself is not a module, and this
39
+ // works no matter how the installer laid the tree out (nested or hoisted).
40
+ return path.join(path.dirname(require.resolve(`${pkg}/package.json`)), 'bin', exe);
41
+ } catch {
42
+ fail(
43
+ `the platform package ${pkg} is missing. It installs automatically as an optional ` +
44
+ 'dependency, so this usually means installation ran with --no-optional or ' +
45
+ '--omit=optional. Reinstall with optional dependencies enabled.',
46
+ );
47
+ }
48
+ }
49
+
50
+ const binary = resolveBinary();
51
+
52
+ // stdio: 'inherit' gives the Go process the real file descriptors, which the MCP
53
+ // stdio transport needs — anything piped through Node here would add buffering
54
+ // between the client and the server.
55
+ const result = spawnSync(binary, process.argv.slice(2), {
56
+ stdio: 'inherit',
57
+ windowsHide: true,
58
+ });
59
+
60
+ if (result.error) {
61
+ if (result.error.code === 'ENOENT') {
62
+ fail(`binary not found at ${binary}. Reinstall the package.`);
63
+ }
64
+ if (result.error.code === 'EACCES') {
65
+ fail(`binary at ${binary} is not executable. Reinstall the package.`);
66
+ }
67
+ fail(`failed to start ${binary}: ${result.error.message}`);
68
+ }
69
+
70
+ // Report a signal death the way a shell would, so a supervisor sees the real cause.
71
+ if (result.signal) {
72
+ process.kill(process.pid, result.signal);
73
+ }
74
+
75
+ process.exit(result.status === null ? 1 : result.status);
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@pyworkload/3x-ui-mcp",
3
+ "version": "0.4.3",
4
+ "description": "MCP server for the 3x-ui Xray/V2Ray proxy panel: manage inbounds, clients, routing, nodes and Xray itself from an LLM agent.",
5
+ "keywords": [
6
+ "mcp",
7
+ "model-context-protocol",
8
+ "3x-ui",
9
+ "xray",
10
+ "v2ray",
11
+ "vless",
12
+ "reality",
13
+ "proxy",
14
+ "vpn"
15
+ ],
16
+ "homepage": "https://github.com/pyworkload/3x-ui-mcp#readme",
17
+ "bugs": "https://github.com/pyworkload/3x-ui-mcp/issues",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/pyworkload/3x-ui-mcp.git"
21
+ },
22
+ "license": "MIT",
23
+ "author": "pyworkload",
24
+ "type": "commonjs",
25
+ "bin": {
26
+ "3x-ui-mcp": "bin/xui-mcp.js",
27
+ "xui-mcp": "bin/xui-mcp.js"
28
+ },
29
+ "files": [
30
+ "bin/xui-mcp.js",
31
+ "README.md"
32
+ ],
33
+ "engines": {
34
+ "node": ">=16"
35
+ },
36
+ "optionalDependencies": {
37
+ "@pyworkload/3x-ui-mcp-darwin-arm64": "0.4.3",
38
+ "@pyworkload/3x-ui-mcp-darwin-x64": "0.4.3",
39
+ "@pyworkload/3x-ui-mcp-linux-arm64": "0.4.3",
40
+ "@pyworkload/3x-ui-mcp-linux-x64": "0.4.3",
41
+ "@pyworkload/3x-ui-mcp-win32-arm64": "0.4.3",
42
+ "@pyworkload/3x-ui-mcp-win32-x64": "0.4.3"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ }
47
+ }