ecp-mcp-server 0.3.0 → 0.4.0

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/.env.sample CHANGED
@@ -1,6 +1,7 @@
1
- # Base URL of the target ECP instance's own API (ecp-go), NOT EHM-API.
2
- # e.g. https://haargodev.com:2324/api
3
- ECP_API_BASE_URL=
1
+ # Your ECP address. Any of these work: example.com, the panel address
2
+ # https://example.com:2323, or the API URL https://example.com:2324/api.
3
+ # (ECP_API_BASE_URL is the older name and still works.)
4
+ ECP_URL=
4
5
 
5
6
  # The hosting account this MCP server logs in as. One server = one account.
6
7
  ECP_ACCOUNT_USERNAME=
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0 — 2026-11-21
4
+
5
+ Ships with the ECP plugin for Claude (`plugin/`), which bundles this server.
6
+
7
+ ### Added
8
+ - `ECP_URL`: your ECP address in any form people actually have it - `example.com`, the panel address `https://example.com:2323`, or the API URL. `ECP_API_BASE_URL` still works.
9
+ - `ecp_asdf_recommend`: picks a runtime version for an app that doesn't pin one exactly (newest LTS within its declared constraints).
10
+ - `ecp_files_compress` takes an optional `format` (zip, tar, tar.gz, tar.bz2, tar.xz). Older ECP ignores it and makes a zip.
11
+ - `ecp_files_change_permission` takes `recursive`. `false` changes only the folder itself, not its contents. Omitting it keeps the old behaviour (the folder and everything inside). Needs the ECP release after 2.0.6; older ECP ignores `false`.
12
+
13
+ ### Changed
14
+ - Missing or invalid settings no longer stop the server at launch. It starts, and every tool replies with what's missing and where to set it, so the chat app shows a useful message instead of a failed server.
15
+ - Login errors say what went wrong in plain words: wrong username/password, or the ECP address can't be reached (with the cause).
16
+ - `ecp_system_update` is described as what it actually does: apply an ECP update by rebuilding the account's container (sites restart; files and databases kept). It never changed a password. `ecp_password` is now optional, as ECP doesn't use it.
17
+
3
18
  ## 0.3.0 — 2026-10-26
4
19
 
5
20
  Matches ECP 2.0.5 / EHM 2.0.8.
package/README.md CHANGED
@@ -24,6 +24,19 @@ It talks to ECP's own API (the same one ECP's web UI uses) as the hosting accoun
24
24
 
25
25
  **What it deliberately does *not* do:** start a local file backup or restore. Those need a live browser connection for progress; use ECP's own web UI.
26
26
 
27
+ ## Easiest: the ECP plugin for Claude
28
+
29
+ For people who just want to run their hosting from chat, without editing config files: install the **ECP plugin**, which bundles this server with step-by-step guides for websites, domains, HTTPS, databases, files and troubleshooting. In Claude Code:
30
+
31
+ ```
32
+ /plugin marketplace add EpicLabs23/ecp-mcp-server
33
+ /plugin install ecp@epiclabs23
34
+ ```
35
+
36
+ It asks for your ECP panel address, username and password (the password goes to your system's secure storage). See [`plugin/README.md`](./plugin/README.md).
37
+
38
+ The rest of this page is for using the server directly with any MCP client.
39
+
27
40
  ## Requirements
28
41
 
29
42
  - Node.js 18+
@@ -51,7 +64,7 @@ This server is configured entirely through environment variables — no config f
51
64
 
52
65
  | Variable | Required | Description |
53
66
  |---|---|---|
54
- | `ECP_API_BASE_URL` | yes | Your ECP instance's own API base URL, e.g. `https://yourdomain.com:2324/api` — **not** EHM's API. |
67
+ | `ECP_URL` | yes | Your ECP address: `yourdomain.com`, the panel address `https://yourdomain.com:2323`, or the API URL `https://yourdomain.com:2324/api` all work. (`ECP_API_BASE_URL` is the older name and still works.) |
55
68
  | `ECP_ACCOUNT_USERNAME` | yes | The hosting account to log in as. One server instance manages one account. |
56
69
  | `ECP_ACCOUNT_PASSWORD` | yes | That account's password. |
57
70
  | `ECP_REMEMBER` | no | `true` for a 30-day session instead of 24h. |
@@ -64,7 +77,7 @@ This server is configured entirely through environment variables — no config f
64
77
  ```bash
65
78
  claude mcp add ecp-mcp-server \
66
79
  --scope user \
67
- -e ECP_API_BASE_URL=https://yourdomain.com:2324/api \
80
+ -e ECP_URL=https://yourdomain.com:2323 \
68
81
  -e ECP_ACCOUNT_USERNAME=youraccount \
69
82
  -e ECP_ACCOUNT_PASSWORD=yourpassword \
70
83
  -- npx ecp-mcp-server
@@ -83,7 +96,7 @@ Add to your `claude_desktop_config.json`:
83
96
  "command": "npx",
84
97
  "args": ["ecp-mcp-server"],
85
98
  "env": {
86
- "ECP_API_BASE_URL": "https://yourdomain.com:2324/api",
99
+ "ECP_URL": "https://yourdomain.com:2323",
87
100
  "ECP_ACCOUNT_USERNAME": "youraccount",
88
101
  "ECP_ACCOUNT_PASSWORD": "yourpassword"
89
102
  }
@@ -117,6 +130,8 @@ npm run build
117
130
  npm run inspect # opens the MCP Inspector to test tools manually
118
131
  ```
119
132
 
133
+ Releasing the server and the plugin: see [`docs/RELEASE.md`](./docs/RELEASE.md).
134
+
120
135
  ## License
121
136
 
122
137
  MIT
package/dist/config.js ADDED
@@ -0,0 +1,73 @@
1
+ // Turns whatever the user typed as their ECP address into ecp-go's API base
2
+ // URL. People know the panel they log into (https://example.com:2323), not
3
+ // the API behind it, so all of these work:
4
+ // example.com
5
+ // https://example.com:2323 (the panel itself)
6
+ // https://example.com:2323/dashboard (a copied panel link)
7
+ // https://example.com:2324/api (the API, as older configs had it)
8
+ // ecp-go always serves the panel on 2323 and the API on 2324 of the same host.
9
+ export function normalizeApiBaseUrl(input) {
10
+ let raw = input.trim();
11
+ if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(raw))
12
+ raw = `https://${raw}`;
13
+ let url;
14
+ try {
15
+ url = new URL(raw);
16
+ }
17
+ catch {
18
+ throw new Error(`"${input}" isn't a web address. Use your ECP panel address, e.g. https://example.com:2323`);
19
+ }
20
+ if (url.protocol !== "https:" && url.protocol !== "http:") {
21
+ throw new Error(`"${input}" isn't a web address. Use your ECP panel address, e.g. https://example.com:2323`);
22
+ }
23
+ // An explicit API URL on a non-standard port is kept as given (a proxied
24
+ // or dev setup); everything else is mapped to <host>:2324/api.
25
+ const path = url.pathname.replace(/\/+$/, "");
26
+ if (/\/api$/.test(path) && url.port !== "2323") {
27
+ return `${url.origin}${path}`;
28
+ }
29
+ return `${url.protocol}//${url.hostname}:2324/api`;
30
+ }
31
+ /** The panel URL to send users to for anything this server can't do. */
32
+ export function panelUrlFromApiBase(apiBaseUrl) {
33
+ return apiBaseUrl.replace(/:2324\/api\/?$/, ":2323");
34
+ }
35
+ const read = (name) => process.env[name]?.trim() ?? "";
36
+ // ECP_URL is the friendly name; ECP_API_BASE_URL is kept for existing setups.
37
+ // Unexpanded "${...}" placeholders (a plugin option that was never filled in)
38
+ // count as empty.
39
+ const value = (name) => {
40
+ const v = read(name);
41
+ return /^\$\{[^}]*\}$/.test(v) ? "" : v;
42
+ };
43
+ export function loadConfig() {
44
+ const address = value("ECP_URL") || value("ECP_API_BASE_URL");
45
+ const username = value("ECP_ACCOUNT_USERNAME");
46
+ const password = value("ECP_ACCOUNT_PASSWORD");
47
+ let apiBaseUrl;
48
+ if (address) {
49
+ try {
50
+ apiBaseUrl = normalizeApiBaseUrl(address);
51
+ }
52
+ catch (err) {
53
+ return { ok: false, problem: err.message };
54
+ }
55
+ }
56
+ const missing = [
57
+ !address && "your ECP panel address",
58
+ !username && "your ECP username",
59
+ !password && "your ECP password",
60
+ ].filter(Boolean);
61
+ if (missing.length > 0 || !apiBaseUrl) {
62
+ return { ok: false, problem: `ECP isn't set up yet: missing ${missing.join(", ")}.`, apiBaseUrl };
63
+ }
64
+ return {
65
+ ok: true,
66
+ config: {
67
+ apiBaseUrl,
68
+ username,
69
+ password,
70
+ remember: value("ECP_REMEMBER").toLowerCase() === "true",
71
+ },
72
+ };
73
+ }
@@ -61,17 +61,30 @@ export class EcpClient {
61
61
  this.accessTokenExpiresAt = exp ? exp - 60_000 : Date.now() + 10 * 60_000;
62
62
  }
63
63
  async login() {
64
- const res = await fetch(`${this.baseUrl}/auth/login`, {
65
- method: "POST",
66
- headers: { "content-type": "application/json" },
67
- body: JSON.stringify({
68
- username: this.username,
69
- password: this.password,
70
- remember: this.remember,
71
- }),
72
- });
64
+ let res;
65
+ try {
66
+ res = await fetch(`${this.baseUrl}/auth/login`, {
67
+ method: "POST",
68
+ headers: { "content-type": "application/json" },
69
+ body: JSON.stringify({
70
+ username: this.username,
71
+ password: this.password,
72
+ remember: this.remember,
73
+ }),
74
+ });
75
+ }
76
+ catch (err) {
77
+ // fetch only throws for transport problems (DNS, refused, TLS), and its
78
+ // own message is just "fetch failed" - name the address and the cause.
79
+ const cause = err.cause;
80
+ const detail = cause?.code ?? cause?.message ?? err.message;
81
+ throw new Error(`Couldn't reach ECP at ${this.baseUrl} (${detail}). Check the panel address in the settings and that the server is online.`);
82
+ }
73
83
  if (!res.ok) {
74
84
  const text = await res.text().catch(() => "");
85
+ if (res.status === 400 || res.status === 401 || res.status === 403) {
86
+ throw new Error(`ECP didn't accept the username or password (${res.status}). Check them in the settings - they're the same ones you use to log into the ECP panel. ${text}`.trim());
87
+ }
75
88
  throw new Error(`ECP login failed (${res.status}): ${text}`);
76
89
  }
77
90
  this.captureRefreshCookie(res);
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import "dotenv/config";
3
3
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
4
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
5
  import { EcpClient } from "./ecp-client.js";
6
+ import { loadConfig, panelUrlFromApiBase } from "./config.js";
6
7
  import { auditLog } from "./audit-log.js";
7
8
  import { accountTools } from "./tools/account.js";
8
9
  import { appsTools } from "./tools/apps.js";
@@ -28,29 +29,33 @@ if ((process.env.ECP_TLS_INSECURE ?? "false").toLowerCase() === "true") {
28
29
  process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
29
30
  console.error("[ecp-mcp-server] WARNING: ECP_TLS_INSECURE=true - TLS certificate verification is disabled for this process.");
30
31
  }
31
- function requireEnv(name) {
32
- const value = process.env[name]?.trim();
33
- if (!value) {
34
- throw new Error(`Missing required env var ${name} (see .env.sample)`);
35
- }
36
- return value;
37
- }
38
32
  // Same relative path from src/ (tsx) and dist/ (built), and package.json
39
33
  // always ships in the npm tarball - keeps the handshake version in step with
40
34
  // the published one.
41
35
  const { version } = createRequire(import.meta.url)("../package.json");
42
- const apiBaseUrl = requireEnv("ECP_API_BASE_URL");
43
- const client = new EcpClient({
44
- baseUrl: apiBaseUrl,
45
- username: requireEnv("ECP_ACCOUNT_USERNAME"),
46
- password: requireEnv("ECP_ACCOUNT_PASSWORD"),
47
- remember: (process.env.ECP_REMEMBER ?? "false").toLowerCase() === "true",
48
- });
36
+ // A missing or bad setting doesn't stop the server: it still starts, and every
37
+ // tool answers with what's wrong. In a chat client a server that exits at
38
+ // launch just shows up as "failed", which tells a non-technical user nothing.
39
+ const configResult = loadConfig();
40
+ const client = configResult.ok
41
+ ? new EcpClient({
42
+ baseUrl: configResult.config.apiBaseUrl,
43
+ username: configResult.config.username,
44
+ password: configResult.config.password,
45
+ remember: configResult.config.remember,
46
+ })
47
+ : null;
48
+ const setupProblem = configResult.ok
49
+ ? null
50
+ : `${configResult.problem} Add the missing details in this MCP server's settings (in the ECP plugin: its options; otherwise the ECP_URL, ECP_ACCOUNT_USERNAME and ECP_ACCOUNT_PASSWORD environment variables), then restart the chat app.`;
51
+ if (setupProblem)
52
+ console.error(`[ecp-mcp-server] ${setupProblem}`);
49
53
  // ecp-go serves its browser UI on port 2323 and its API (what this server
50
54
  // talks to) on 2324, same host - derived here so the "go do this in ecp-ui"
51
55
  // guidance below points at a real, clickable URL instead of a vague
52
56
  // pointer.
53
- const ecpUiUrl = apiBaseUrl.replace(/:2324\/api\/?$/, ":2323");
57
+ const apiBaseUrl = configResult.ok ? configResult.config.apiBaseUrl : configResult.apiBaseUrl;
58
+ const ecpUiUrl = apiBaseUrl ? panelUrlFromApiBase(apiBaseUrl) : "your ECP panel (port 2323 of your domain)";
54
59
  const server = new McpServer({ name: "ecp-mcp-server", version }, {
55
60
  instructions: `This server manages one ECP hosting account's apps, domains, databases, files, PHP, SSL, and related settings.
56
61
 
@@ -95,6 +100,8 @@ const toolContext = {
95
100
  for (const tool of allTools) {
96
101
  server.registerTool(tool.name, { description: tool.description, inputSchema: tool.inputSchema }, async (args) => {
97
102
  try {
103
+ if (!client)
104
+ throw new Error(setupProblem ?? "ECP isn't set up yet.");
98
105
  const result = await tool.handler(args, client, toolContext);
99
106
  await auditLog({ tool: tool.name, args, result: "success" });
100
107
  return {
@@ -40,7 +40,7 @@ export const appsTools = [
40
40
  },
41
41
  {
42
42
  name: "ecp_apps_detect",
43
- description: "Inspect an app directory and detect its app root, tech stack (deploy_type + framework_hint), web root, whether it needs a database, its runtime (asdf_key + version), and suggested install/build/start commands. " +
43
+ description: "Inspect an app directory and detect its app root, tech stack (deploy_type + framework_hint), web root, whether it needs a database, its runtime (asdf_key + version, or runtime_constraints when there's no exact pin - feed those to ecp_asdf_recommend), and suggested install/build/start commands. " +
44
44
  "Read-only: it runs no commands and changes nothing, so it's safe to call before creating or deploying an app. app_dir is a folder name under ~/apps or an absolute path inside it. " +
45
45
  "If root_ambiguous is true, pick one of root_candidates and call this again with it.",
46
46
  inputSchema: { app_dir: z.string() },
@@ -30,6 +30,16 @@ export const asdfTools = [
30
30
  inputSchema: { name: z.string() },
31
31
  handler: async (args, client) => client.request("GET", `asdf/list-installed/${args.name}`),
32
32
  },
33
+ {
34
+ name: "ecp_asdf_recommend",
35
+ description: "Pick a runtime version for an app that doesn't pin one exactly (ecp_apps_detect returned no runtime_version). " +
36
+ "Pass runtime_constraints from ecp_apps_detect as constraints (or [] if there were none). Returns the newest LTS release " +
37
+ "(newest stable for tools with no LTS, like python) that satisfies all of them - e.g. engines.node \">=22\" gets the latest Node LTS, not 22. " +
38
+ "installed_match is an installed version on that line to use as-is; otherwise install `version`. relaxed=true means no release met every upper bound, so only minimums were applied. " +
39
+ "Prefer this over choosing a version yourself.",
40
+ inputSchema: { name: z.string(), constraints: z.array(z.string()).default([]) },
41
+ handler: async (args, client) => client.request("POST", "asdf/recommend", { body: { name: args.name, constraints: args.constraints } }),
42
+ },
33
43
  {
34
44
  name: "ecp_asdf_install",
35
45
  description: "Start installing a plugin version. Returns once the install STARTS - building can take minutes (python compiles from source). " +
@@ -96,29 +96,39 @@ export const filesTools = [
96
96
  },
97
97
  {
98
98
  name: "ecp_files_change_permission",
99
- description: "chmod a file (e.g. new_permission: '644').",
100
- inputSchema: { current_directory: z.string(), file_name: z.string(), new_permission: z.string() },
99
+ description: "chmod a file or folder (e.g. new_permission: '644'). For a folder, ECP applies the mode to the folder and everything inside it unless recursive is false.",
100
+ inputSchema: {
101
+ current_directory: z.string(),
102
+ file_name: z.string(),
103
+ new_permission: z.string(),
104
+ recursive: z
105
+ .boolean()
106
+ .optional()
107
+ .describe("Folders only. false changes just the folder itself; omitted or true also changes every file and subfolder to the same mode (files usually want 644, folders 755). Needs the ECP release after 2.0.6; older ECP ignores false and changes everything."),
108
+ },
101
109
  handler: async (args, client) => client.request("POST", "file-system/change-permission", { body: args }),
102
110
  },
103
111
  {
104
112
  name: "ecp_files_compress",
105
- description: "Compress one or more files/folders into an archive.",
113
+ description: "Compress one or more files/folders (paths relative to current_directory) into an archive in current_directory. Fails if the archive already exists.",
106
114
  inputSchema: {
107
115
  file_paths: z.array(z.string()),
108
116
  output_filename: z.string(),
109
117
  current_directory: z.string(),
118
+ format: z.enum(["zip", "tar", "tar.gz", "tar.bz2", "tar.xz"]).optional().describe("Archive format; default zip"),
110
119
  },
111
120
  handler: async (args, client) => client.request("POST", "file-system/compress", {
112
121
  body: {
113
122
  filePaths: args.file_paths,
114
123
  outputFilename: args.output_filename,
115
124
  currentDirectory: args.current_directory,
125
+ ...(args.format ? { format: args.format } : {}),
116
126
  },
117
127
  }),
118
128
  },
119
129
  {
120
130
  name: "ecp_files_extract",
121
- description: "Extract an archive into a destination directory.",
131
+ description: "Extract an archive (.zip, .tar, .tar.gz/.tgz, .tar.bz2, .tar.xz) into a destination directory.",
122
132
  inputSchema: { file_path: z.string(), destination: z.string() },
123
133
  handler: async (args, client) => client.request("POST", "file-system/extract", { body: args }),
124
134
  },
@@ -84,9 +84,9 @@ export const systemTools = [
84
84
  },
85
85
  {
86
86
  name: "ecp_system_update",
87
- description: "Update account/hosting settings (hosting_environment, hosting_version) or ECP password. Requires the account's own current password. Account-wide impact - review carefully.",
87
+ description: "Apply an ECP/hosting update (what ECP's own Update button does): EHM rebuilds this account's container on the current or given hosting environment/version, then restores logins, settings and site configs. Files and databases are kept, but every site restarts and is briefly offline. Check ecp_system_check_for_update first. It does not change any password.",
88
88
  inputSchema: {
89
- ecp_password: z.string(),
89
+ ecp_password: z.string().optional().describe("Not used by ECP; accepted for compatibility with older clients."),
90
90
  hosting_environment: z.string().optional(),
91
91
  hosting_version: z.string().optional(),
92
92
  confirm: z.literal(true),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecp-mcp-server",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "MCP server for ECP (Epic Control Panel) - manage a hosting account's apps, domains, databases, files, PHP, SSL and more conversationally through an MCP client like Claude Code or Claude Desktop.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {