ecp-mcp-server 0.1.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 ADDED
@@ -0,0 +1,21 @@
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=
4
+
5
+ # The hosting account this MCP server logs in as. One server = one account.
6
+ ECP_ACCOUNT_USERNAME=
7
+ ECP_ACCOUNT_PASSWORD=
8
+
9
+ # If true, requests a 30-day refresh token instead of the 24h default.
10
+ ECP_REMEMBER=false
11
+
12
+ # Where the local append-only audit log (every tool call) is written.
13
+ # Defaults to ./audit.log next to this file if unset.
14
+ ECP_MCP_AUDIT_LOG_PATH=
15
+
16
+ # Dev-only escape hatch: disables TLS certificate verification for this
17
+ # process (e.g. a self-signed dev ECP instance). Leave unset/false for any
18
+ # real account - this affects every outgoing HTTPS request the process
19
+ # makes, so never point a server configured this way at anything you
20
+ # haven't deliberately chosen to trust.
21
+ ECP_TLS_INSECURE=false
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Epic Labs 23
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,118 @@
1
+ # ecp-mcp-server
2
+
3
+ An [MCP](https://modelcontextprotocol.io) server for [ECP](https://github.com/EpicLabs23) (Epic Control Panel) — manage a hosting account's apps, domains, databases, files, PHP, SSL, and more conversationally through Claude Code, Claude Desktop, or any other MCP-compatible client.
4
+
5
+ It talks to ECP's own API (the same one ECP's web UI uses) as the hosting account you configure it with — nothing about this project modifies EHM or ECP themselves.
6
+
7
+ ## What it can do
8
+
9
+ ~190 tools across:
10
+
11
+ - **Apps** — deploy, create from git/upload, manage domains, tail logs, custom commands
12
+ - **Domains / DNS / Nginx** — add/remove domains and subdomains, DNS records, raw nginx config, redirects
13
+ - **Files** — browse, read/write, move/copy/rename/delete, compress/extract
14
+ - **Databases** — MySQL, MongoDB, MSSQL, and PostgreSQL: create/delete DBs and users, privileges, browse/edit rows or documents, backups
15
+ - **PHP / SSL / System** — PHP versions and `php.ini`, Let's Encrypt/self-signed certificates, disk usage, account settings
16
+ - **Supervisor / Crontab** — manage long-running processes and scheduled jobs
17
+ - **asdf** — language runtime version management
18
+ - **Git integrations** — connect GitHub/GitLab/Bitbucket, browse repos, manage per-app deploy webhooks
19
+ - **One-click installers** — WordPress and other blueprint scaffolding
20
+ - **Resource monitoring / notifications**
21
+ - **storage.bd** — backup config and job status
22
+
23
+ **What it deliberately does *not* do:** run arbitrary shell commands. ECP's own command-execution primitives are either broken for non-interactive callers (they silently drop output) or don't fit a single request/response tool call (an interactive terminal). Rather than build something unsafe or blind, this server tells the connecting AI to send you to ECP's own browser terminal for anything that genuinely needs a shell.
24
+
25
+ ## Requirements
26
+
27
+ - Node.js 18+
28
+ - An ECP hosting account (username + password)
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ npx ecp-mcp-server
34
+ ```
35
+
36
+ or install globally:
37
+
38
+ ```bash
39
+ npm install -g ecp-mcp-server
40
+ ```
41
+
42
+ You don't need to do either manually if you're adding it to an MCP client below — the client runs it for you.
43
+
44
+ ## Configure
45
+
46
+ This server is configured entirely through environment variables — no config file needed. See [`.env.sample`](./.env.sample) for the full list. The essentials:
47
+
48
+ | Variable | Required | Description |
49
+ |---|---|---|
50
+ | `ECP_API_BASE_URL` | yes | Your ECP instance's own API base URL, e.g. `https://yourdomain.com:2324/api` — **not** EHM's API. |
51
+ | `ECP_ACCOUNT_USERNAME` | yes | The hosting account to log in as. One server instance manages one account. |
52
+ | `ECP_ACCOUNT_PASSWORD` | yes | That account's password. |
53
+ | `ECP_REMEMBER` | no | `true` for a 30-day session instead of 24h. |
54
+ | `ECP_TLS_INSECURE` | no | Dev-only escape hatch for a self-signed ECP instance. Never set this for a real account — see the comment in `.env.sample`. |
55
+
56
+ ## Use it
57
+
58
+ ### Claude Code
59
+
60
+ ```bash
61
+ claude mcp add ecp-mcp-server \
62
+ --scope user \
63
+ -e ECP_API_BASE_URL=https://yourdomain.com:2324/api \
64
+ -e ECP_ACCOUNT_USERNAME=youraccount \
65
+ -e ECP_ACCOUNT_PASSWORD=yourpassword \
66
+ -- npx ecp-mcp-server
67
+ ```
68
+
69
+ Restart Claude Code (MCP servers load at session start), then just ask — "list my apps," "check disk usage," "show me the last few notifications."
70
+
71
+ ### Claude Desktop
72
+
73
+ Add to your `claude_desktop_config.json`:
74
+
75
+ ```json
76
+ {
77
+ "mcpServers": {
78
+ "ecp": {
79
+ "command": "npx",
80
+ "args": ["ecp-mcp-server"],
81
+ "env": {
82
+ "ECP_API_BASE_URL": "https://yourdomain.com:2324/api",
83
+ "ECP_ACCOUNT_USERNAME": "youraccount",
84
+ "ECP_ACCOUNT_PASSWORD": "yourpassword"
85
+ }
86
+ }
87
+ }
88
+ }
89
+ ```
90
+
91
+ ### Other MCP clients
92
+
93
+ This is a standard stdio MCP server (`@modelcontextprotocol/sdk`) — any compliant client can spawn `npx ecp-mcp-server` with the env vars above and use it.
94
+
95
+ ## Security notes
96
+
97
+ Worth understanding before you point this at an account you care about:
98
+
99
+ - **Scope**: one server instance = one hosting account, authenticated exactly as that account (same permissions, same rate limits as logging into ECP's web UI yourself). It cannot reach any other account.
100
+ - **Destructive/security-sensitive actions require `confirm: true`** as an explicit tool argument (dropping a table, deleting a file, granting privileges, etc.) — this makes the intent unambiguous in both your MCP client's approval prompt and the audit log below. Don't run this with your client's "auto-approve all tools" setting on.
101
+ - **Local audit log**: every tool call is appended to a local file (`ECP_MCP_AUDIT_LOG_PATH`, defaults to `audit.log` next to the installed package) with secrets redacted — since ECP itself doesn't currently keep a durable record of actions taken this way.
102
+ - **Credentials** live only in the environment variables you provide and in-process memory — never written to disk beyond what you configure.
103
+ - **No shell command execution** — see "What it deliberately does not do" above.
104
+
105
+ ## Development
106
+
107
+ ```bash
108
+ git clone https://github.com/EpicLabs23/ecp-mcp-server.git
109
+ cd ecp-mcp-server
110
+ npm install
111
+ cp .env.sample .env # fill in your own values
112
+ npm run build
113
+ npm run inspect # opens the MCP Inspector to test tools manually
114
+ ```
115
+
116
+ ## License
117
+
118
+ MIT
@@ -0,0 +1,39 @@
1
+ import { appendFile } from "node:fs/promises";
2
+ import { fileURLToPath } from "node:url";
3
+ import path from "node:path";
4
+ // No durable server-side record exists today for actions taken through an
5
+ // account JWT (see ehm-api's IntegrationAuditLog, which only covers
6
+ // /integration/* callers) - this file is the only audit trail this tool's
7
+ // actions get, so every tool call is logged here, not just destructive ones.
8
+ const defaultPath = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "audit.log");
9
+ const logPath = process.env.ECP_MCP_AUDIT_LOG_PATH?.trim() || defaultPath;
10
+ // Several tools (DB row/document browsing, importDatabase's SQL body, etc.)
11
+ // take real secrets or bulk payloads as arguments - these must never land in
12
+ // a plaintext file on disk. Redact by key name (covers every engine's
13
+ // browseRows/insertRow/updateRow/deleteRow, which all use "password") rather
14
+ // than per-tool, so a new tool with a sensitive field is covered by default.
15
+ const REDACT_KEYS = new Set([
16
+ "password",
17
+ "sql_content",
18
+ "file_content",
19
+ "repo_password",
20
+ "db_pass",
21
+ "admin_pass",
22
+ "ecp_password",
23
+ "client_secret",
24
+ ]);
25
+ function redact(value) {
26
+ if (Array.isArray(value))
27
+ return value.map(redact);
28
+ if (value && typeof value === "object") {
29
+ return Object.fromEntries(Object.entries(value).map(([key, val]) => [
30
+ key,
31
+ REDACT_KEYS.has(key) ? "[redacted]" : redact(val),
32
+ ]));
33
+ }
34
+ return value;
35
+ }
36
+ export async function auditLog(entry) {
37
+ const line = JSON.stringify({ timestamp: new Date().toISOString(), ...entry, args: redact(entry.args) });
38
+ await appendFile(logPath, line + "\n", "utf8");
39
+ }
@@ -0,0 +1,165 @@
1
+ // Client for ECP's own API (ecp-go), never EHM-API directly - see the plan
2
+ // doc for why. Mirrors ecp-ui's own auth.js: log in once, hold the
3
+ // refresh_token httpOnly cookie ourselves (there's no browser to do it for
4
+ // us), refresh proactively before the access token expires or reactively on
5
+ // a 401.
6
+ function decodeJwtExpMs(token) {
7
+ const parts = token.split(".");
8
+ if (parts.length !== 3)
9
+ return null;
10
+ try {
11
+ const payload = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8"));
12
+ return typeof payload.exp === "number" ? payload.exp * 1000 : null;
13
+ }
14
+ catch {
15
+ return null;
16
+ }
17
+ }
18
+ function extractRefreshCookie(setCookieHeaders) {
19
+ for (const header of setCookieHeaders) {
20
+ const match = header.match(/^refresh_token=([^;]*)/);
21
+ if (match)
22
+ return match[1];
23
+ }
24
+ return null;
25
+ }
26
+ function safeJsonParse(text) {
27
+ try {
28
+ return JSON.parse(text);
29
+ }
30
+ catch {
31
+ return text;
32
+ }
33
+ }
34
+ export class EcpClient {
35
+ baseUrl;
36
+ username;
37
+ password;
38
+ remember;
39
+ accessToken = null;
40
+ accessTokenExpiresAt = 0;
41
+ refreshCookie = null;
42
+ constructor(opts) {
43
+ this.baseUrl = opts.baseUrl.replace(/\/+$/, "");
44
+ this.username = opts.username;
45
+ this.password = opts.password;
46
+ this.remember = opts.remember ?? false;
47
+ }
48
+ captureRefreshCookie(res) {
49
+ const headers = res.headers;
50
+ const cookies = typeof headers.getSetCookie === "function"
51
+ ? headers.getSetCookie()
52
+ : (res.headers.get("set-cookie") ? [res.headers.get("set-cookie")] : []);
53
+ const value = extractRefreshCookie(cookies);
54
+ if (value)
55
+ this.refreshCookie = value;
56
+ }
57
+ setAccessToken(token) {
58
+ this.accessToken = token;
59
+ const exp = decodeJwtExpMs(token);
60
+ // Refresh a bit early so a request never races the token's own expiry.
61
+ this.accessTokenExpiresAt = exp ? exp - 60_000 : Date.now() + 10 * 60_000;
62
+ }
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
+ });
73
+ if (!res.ok) {
74
+ const text = await res.text().catch(() => "");
75
+ throw new Error(`ECP login failed (${res.status}): ${text}`);
76
+ }
77
+ this.captureRefreshCookie(res);
78
+ const data = (await res.json());
79
+ this.setAccessToken(data.access_token);
80
+ }
81
+ async refresh() {
82
+ if (!this.refreshCookie) {
83
+ await this.login();
84
+ return;
85
+ }
86
+ const res = await fetch(`${this.baseUrl}/auth/refresh`, {
87
+ method: "POST",
88
+ headers: { cookie: `refresh_token=${this.refreshCookie}` },
89
+ });
90
+ if (!res.ok) {
91
+ // Refresh token expired/invalid server-side - fall back to a fresh login.
92
+ this.refreshCookie = null;
93
+ await this.login();
94
+ return;
95
+ }
96
+ this.captureRefreshCookie(res);
97
+ const data = (await res.json());
98
+ this.setAccessToken(data.access_token);
99
+ }
100
+ async ensureAccessToken() {
101
+ if (!this.accessToken) {
102
+ await this.login();
103
+ }
104
+ else if (Date.now() >= this.accessTokenExpiresAt) {
105
+ await this.refresh();
106
+ }
107
+ return this.accessToken;
108
+ }
109
+ /** Request against ecp-go's own API, e.g. request("GET", "user/profile"). */
110
+ async request(method, path, opts = {}) {
111
+ const token = await this.ensureAccessToken();
112
+ const url = new URL(`${this.baseUrl}/${path.replace(/^\/+/, "")}`);
113
+ if (opts.query) {
114
+ for (const [key, value] of Object.entries(opts.query)) {
115
+ if (value !== undefined && value !== null)
116
+ url.searchParams.set(key, String(value));
117
+ }
118
+ }
119
+ const doFetch = (bearer) => fetch(url, {
120
+ method,
121
+ headers: {
122
+ authorization: `Bearer ${bearer}`,
123
+ ...(opts.body !== undefined ? { "content-type": "application/json" } : {}),
124
+ },
125
+ body: opts.body !== undefined ? JSON.stringify(opts.body) : undefined,
126
+ });
127
+ let res = await doFetch(token);
128
+ if (res.status === 401) {
129
+ await this.refresh();
130
+ res = await doFetch(this.accessToken);
131
+ }
132
+ const text = await res.text();
133
+ const data = text ? safeJsonParse(text) : undefined;
134
+ if (!res.ok) {
135
+ throw new Error(`ECP API ${method} ${path} failed (${res.status}): ${text}`);
136
+ }
137
+ return data;
138
+ }
139
+ /** multipart/form-data POST, e.g. for importDatabase's file upload. */
140
+ async requestMultipart(path, fields, file) {
141
+ const token = await this.ensureAccessToken();
142
+ const url = new URL(`${this.baseUrl}/${path.replace(/^\/+/, "")}`);
143
+ const buildForm = () => {
144
+ const form = new FormData();
145
+ for (const [key, value] of Object.entries(fields)) {
146
+ if (value !== undefined && value !== null)
147
+ form.set(key, String(value));
148
+ }
149
+ form.set(file.fieldName, new Blob([file.content], { type: file.contentType ?? "application/octet-stream" }), file.fileName);
150
+ return form;
151
+ };
152
+ const doFetch = (bearer) => fetch(url, { method: "POST", headers: { authorization: `Bearer ${bearer}` }, body: buildForm() });
153
+ let res = await doFetch(token);
154
+ if (res.status === 401) {
155
+ await this.refresh();
156
+ res = await doFetch(this.accessToken);
157
+ }
158
+ const text = await res.text();
159
+ const data = text ? safeJsonParse(text) : undefined;
160
+ if (!res.ok) {
161
+ throw new Error(`ECP API POST ${path} failed (${res.status}): ${text}`);
162
+ }
163
+ return data;
164
+ }
165
+ }
package/dist/index.js ADDED
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env node
2
+ import "dotenv/config";
3
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
+ import { EcpClient } from "./ecp-client.js";
6
+ import { auditLog } from "./audit-log.js";
7
+ import { accountTools } from "./tools/account.js";
8
+ import { appsTools } from "./tools/apps.js";
9
+ import { domainTools } from "./tools/domains.js";
10
+ import { filesTools } from "./tools/files.js";
11
+ import { databaseTools } from "./tools/database.js";
12
+ import { mongodbTools } from "./tools/mongodb.js";
13
+ import { mssqlTools, postgresTools } from "./tools/relational-engines.js";
14
+ import { systemTools } from "./tools/system.js";
15
+ import { asdfTools } from "./tools/asdf.js";
16
+ import { oneclickTools } from "./tools/oneclick.js";
17
+ import { gitIntegrationTools } from "./tools/git-integrations.js";
18
+ import { resourceMonitorTools } from "./tools/resource-monitor.js";
19
+ import { storageBdTools } from "./tools/storage-bd.js";
20
+ import { backupTools } from "./tools/backup.js";
21
+ // Dev-only escape hatch for a self-signed target (see .env.sample). Process-
22
+ // wide and opt-in only - never the default, since it weakens every HTTPS
23
+ // request this process makes, not just ones to the configured ECP host.
24
+ if ((process.env.ECP_TLS_INSECURE ?? "false").toLowerCase() === "true") {
25
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
26
+ console.error("[ecp-mcp-server] WARNING: ECP_TLS_INSECURE=true - TLS certificate verification is disabled for this process.");
27
+ }
28
+ function requireEnv(name) {
29
+ const value = process.env[name]?.trim();
30
+ if (!value) {
31
+ throw new Error(`Missing required env var ${name} (see .env.sample)`);
32
+ }
33
+ return value;
34
+ }
35
+ const apiBaseUrl = requireEnv("ECP_API_BASE_URL");
36
+ const client = new EcpClient({
37
+ baseUrl: apiBaseUrl,
38
+ username: requireEnv("ECP_ACCOUNT_USERNAME"),
39
+ password: requireEnv("ECP_ACCOUNT_PASSWORD"),
40
+ remember: (process.env.ECP_REMEMBER ?? "false").toLowerCase() === "true",
41
+ });
42
+ // ecp-go serves its browser UI on port 2323 and its API (what this server
43
+ // talks to) on 2324, same host - derived here so the "go do this in ecp-ui"
44
+ // guidance below points at a real, clickable URL instead of a vague
45
+ // pointer.
46
+ const ecpUiUrl = apiBaseUrl.replace(/:2324\/api\/?$/, ":2323");
47
+ const server = new McpServer({ name: "ecp-mcp-server", version: "0.1.0" }, {
48
+ instructions: `This server manages one ECP hosting account's apps, domains, databases, files, PHP, SSL, and related settings.
49
+
50
+ No arbitrary shell command execution is available through any tool here - by design, not oversight. ecp-go's own command-execution routes (custom-command/execute, oneclick's run-cmd, the interactive terminal) are either fire-and-forget with no way to see output, or don't fit a single tool-call shape at all. Do not try to route around this by improvising a command through another tool (e.g. stuffing a shell command into a deploy step's install/build fields expecting to see its output back - those have the identical blind-execution problem).
51
+
52
+ For the same reason, triggering a local file backup or restore isn't available either (ecp_backup_list_snapshots is - listing is fine) - starting one requires the same fire-and-forget, no-visible-outcome mechanism.
53
+
54
+ When a task genuinely needs a shell command or a backup/restore trigger this server has no tool for, tell the user to do it themselves in ECP's own UI in the browser: ${ecpUiUrl} - don't guess at a workaround.`,
55
+ });
56
+ const allTools = [
57
+ ...accountTools,
58
+ ...appsTools,
59
+ ...domainTools,
60
+ ...filesTools,
61
+ ...databaseTools,
62
+ ...mongodbTools,
63
+ ...mssqlTools,
64
+ ...postgresTools,
65
+ ...systemTools,
66
+ ...asdfTools,
67
+ ...oneclickTools,
68
+ ...gitIntegrationTools,
69
+ ...resourceMonitorTools,
70
+ ...storageBdTools,
71
+ ...backupTools,
72
+ ];
73
+ for (const tool of allTools) {
74
+ server.registerTool(tool.name, { description: tool.description, inputSchema: tool.inputSchema }, async (args) => {
75
+ try {
76
+ const result = await tool.handler(args, client);
77
+ await auditLog({ tool: tool.name, args, result: "success" });
78
+ return {
79
+ content: [{ type: "text", text: JSON.stringify(result ?? null, null, 2) }],
80
+ };
81
+ }
82
+ catch (err) {
83
+ const message = err instanceof Error ? err.message : String(err);
84
+ await auditLog({ tool: tool.name, args, result: "error", detail: message });
85
+ return {
86
+ content: [{ type: "text", text: `Error calling ${tool.name}: ${message}` }],
87
+ isError: true,
88
+ };
89
+ }
90
+ });
91
+ }
92
+ async function main() {
93
+ const transport = new StdioServerTransport();
94
+ await server.connect(transport);
95
+ }
96
+ main().catch((err) => {
97
+ console.error("Fatal error starting ecp-mcp-server:", err);
98
+ process.exit(1);
99
+ });
@@ -0,0 +1,13 @@
1
+ // GET /api/user/profile -> ecp-go proxies to EHM's ecp/user-profile, which
2
+ // returns the full account profile (not just decoded JWT claims, unlike
3
+ // /api/user/me) - the richest single call to confirm the whole auth chain
4
+ // (login -> access token -> refresh_token cookie -> authenticated request)
5
+ // actually works end to end.
6
+ export const accountTools = [
7
+ {
8
+ name: "ecp_whoami",
9
+ description: "Get the profile of the hosting account this MCP server is authenticated as.",
10
+ inputSchema: {},
11
+ handler: async (_args, client) => client.request("GET", "user/profile"),
12
+ },
13
+ ];
@@ -0,0 +1,120 @@
1
+ import { z } from "zod";
2
+ // Maps to router/apps.go. A few caveats worth carrying into the tool
3
+ // descriptions, discovered by reading the actual ecp-go handlers rather than
4
+ // assumed from the route list:
5
+ //
6
+ // - create-from-git's `git clone` step runs via ecp-go's fire-and-forget
7
+ // ExecRto helper (same primitive as the blocked custom-command/execute,
8
+ // see the plan's "Command execution" section) - the app row is created in
9
+ // EHM immediately after the clone STARTS, not after it finishes. A large
10
+ // repo may still be cloning when this tool returns success.
11
+ // - deploy's "install"/"build" actions use the same fire-and-forget ExecRto
12
+ // path - there is no way to retrieve their command output via this API
13
+ // (ecp-go only streams it to a live browser socket). "configure" runs
14
+ // synchronously but also returns no output. Only "start"/"stop"/"restart"/
15
+ // "remove" give a real synchronous result (they go through supervisor).
16
+ export const appsTools = [
17
+ {
18
+ name: "ecp_apps_list",
19
+ description: "List all apps on this hosting account.",
20
+ inputSchema: {},
21
+ handler: async (_args, client) => client.request("GET", "apps/"),
22
+ },
23
+ {
24
+ name: "ecp_apps_get",
25
+ description: "Get one app's details by id.",
26
+ inputSchema: { id: z.union([z.string(), z.number()]) },
27
+ handler: async (args, client) => client.request("GET", `apps/${args.id}`),
28
+ },
29
+ {
30
+ name: "ecp_apps_directory_tree",
31
+ description: "Browse the account's directory tree (used to pick a location for a new app, or to sanity-check where a git clone landed).",
32
+ inputSchema: { directory: z.string().optional() },
33
+ handler: async (args, client) => client.request("GET", "apps/directory-tree", { query: { directory: args.directory } }),
34
+ },
35
+ {
36
+ name: "ecp_apps_create_from_upload",
37
+ description: "Register an app whose files were already uploaded to app_dir.",
38
+ inputSchema: {
39
+ app_name: z.string(),
40
+ app_dir: z.string(),
41
+ deploy_type: z.string().optional(),
42
+ domain: z.string().optional(),
43
+ },
44
+ handler: async (args, client) => client.request("POST", "apps/create-from-upload", { body: args }),
45
+ },
46
+ {
47
+ name: "ecp_apps_create_from_git",
48
+ description: "Create an app by cloning a git repo. Either set provider+repo_full_name (clone via a connected git account, see ecp_git_* tools) or repo_url (+ optional repo_username/repo_password for a private repo). " +
49
+ "Note: the clone runs in the background - this tool returns once the clone STARTS, not once it finishes. For a large repo, check ecp_apps_directory_tree afterward before assuming the files are all there.",
50
+ inputSchema: {
51
+ app_name: z.string(),
52
+ app_dir: z.string(),
53
+ deploy_type: z.string().optional(),
54
+ branch: z.string().optional(),
55
+ provider: z.string().optional(),
56
+ repo_full_name: z.string().optional(),
57
+ repo_url: z.string().optional(),
58
+ repo_username: z.string().optional(),
59
+ repo_password: z.string().optional(),
60
+ },
61
+ handler: async (args, client) => client.request("POST", "apps/create-from-git", { body: args }),
62
+ },
63
+ {
64
+ name: "ecp_apps_delete",
65
+ description: "Delete an app: stops its supervisor process (if any) and removes its files. Irreversible.",
66
+ inputSchema: { id: z.union([z.string(), z.number()]), confirm: z.literal(true) },
67
+ handler: async (args, client) => client.request("DELETE", `apps/${args.id}`),
68
+ },
69
+ {
70
+ name: "ecp_apps_update_domain",
71
+ description: "Point an app at a domain: creates the nginx server block and updates the app's domain record.",
72
+ inputSchema: { id: z.union([z.string(), z.number()]), domain: z.string() },
73
+ handler: async (args, client) => client.request("PATCH", `apps/update-domain/${args.id}`, { body: { domain: args.domain } }),
74
+ },
75
+ {
76
+ name: "ecp_apps_update_static_domain",
77
+ description: "Point a static-site app at a domain: creates the nginx static block and updates the app's domain record.",
78
+ inputSchema: { id: z.union([z.string(), z.number()]), domain: z.string() },
79
+ handler: async (args, client) => client.request("PATCH", `apps/update-static-domain/${args.id}`, { body: { domain: args.domain } }),
80
+ },
81
+ {
82
+ name: "ecp_apps_deploy_step",
83
+ description: "Run one step of an app's deploy lifecycle. action='start'|'stop'|'restart'|'remove' manage the app's supervisor process and return a real result. " +
84
+ "action='install'|'build' run a command in the background via app_root_directory (install_command/build_command) but this tool CANNOT show you their output - check ecp_apps_tail_logs or the app's own state afterward. " +
85
+ "action='configure' pins an asdf runtime version (stack_version) for the app and also returns no output.",
86
+ inputSchema: {
87
+ action: z.enum(["configure", "install", "build", "start", "stop", "restart", "remove"]),
88
+ app_name: z.string(),
89
+ app_id: z.number().optional(),
90
+ app_root_directory: z.string(),
91
+ deploy_type: z.string().optional(),
92
+ stack_version: z.string().optional(),
93
+ install_command: z.string().optional(),
94
+ build_command: z.string().optional(),
95
+ start_command: z.string().optional(),
96
+ env_file_path: z.string().optional(),
97
+ },
98
+ handler: async (args, client) => client.request("POST", "apps/deploy", { body: args }),
99
+ },
100
+ {
101
+ name: "ecp_apps_tail_logs",
102
+ description: "Tail an app's supervisor-managed process log (only meaningful after a 'start' deploy step).",
103
+ inputSchema: { app_name: z.string(), byte_count: z.number().optional() },
104
+ handler: async (args, client) => client.request("GET", "apps/logs", {
105
+ query: { app_name: args.app_name, byte_count: args.byte_count },
106
+ }),
107
+ },
108
+ {
109
+ name: "ecp_apps_flush_logs",
110
+ description: "Clear an app's supervisor-managed process log.",
111
+ inputSchema: { app_name: z.string() },
112
+ handler: async (args, client) => client.request("GET", "apps/flush-logs", { query: { app_name: args.app_name } }),
113
+ },
114
+ {
115
+ name: "ecp_apps_save_custom_command",
116
+ description: "Save a named custom command for an app (does not run it - see the blocked command-execution phase in the plan for why 'run' isn't exposed yet).",
117
+ inputSchema: { app_id: z.number(), commands: z.array(z.object({ title: z.string().optional(), command: z.string() })) },
118
+ handler: async (args, client) => client.request("POST", "apps/custom-command", { body: args }),
119
+ },
120
+ ];
@@ -0,0 +1,51 @@
1
+ import { z } from "zod";
2
+ // Maps to router/asdf.go - language runtime version management (node,
3
+ // python, etc. via the asdf version manager). install/uninstall use the
4
+ // same fire-and-forget ExecRto primitive as PHP install/uninstall (see
5
+ // tools/system.ts) - no output, verify via list-installed afterward.
6
+ // global runs synchronously (utils.Exec) but still doesn't return output,
7
+ // just a clean error if it fails.
8
+ export const asdfTools = [
9
+ {
10
+ name: "ecp_asdf_plugin_list_all",
11
+ description: "List all asdf plugins available to install (e.g. nodejs, python, ruby).",
12
+ inputSchema: {},
13
+ handler: async (_args, client) => client.request("GET", "asdf/plugin-list-all"),
14
+ },
15
+ {
16
+ name: "ecp_asdf_plugin_list",
17
+ description: "List asdf plugins currently installed on this account's container.",
18
+ inputSchema: {},
19
+ handler: async (_args, client) => client.request("GET", "asdf/plugin-list"),
20
+ },
21
+ {
22
+ name: "ecp_asdf_list_all_versions",
23
+ description: "List all available versions for a plugin (e.g. nodejs).",
24
+ inputSchema: { name: z.string() },
25
+ handler: async (args, client) => client.request("GET", `asdf/list-all/${args.name}`),
26
+ },
27
+ {
28
+ name: "ecp_asdf_list_installed_versions",
29
+ description: "List installed versions for a plugin.",
30
+ inputSchema: { name: z.string() },
31
+ handler: async (args, client) => client.request("GET", `asdf/list-installed/${args.name}`),
32
+ },
33
+ {
34
+ name: "ecp_asdf_install",
35
+ description: "Install a plugin version (takes time). This tool cannot show install output - check ecp_asdf_list_installed_versions afterward to confirm it succeeded.",
36
+ inputSchema: { name: z.string(), version: z.string(), confirm: z.literal(true) },
37
+ handler: async (args, client) => client.request("POST", "asdf/install", { body: { name: args.name, version: args.version } }),
38
+ },
39
+ {
40
+ name: "ecp_asdf_uninstall",
41
+ description: "Uninstall a plugin version. Breaks anything still configured to use it. This tool cannot show output - check ecp_asdf_list_installed_versions afterward.",
42
+ inputSchema: { name: z.string(), version: z.string(), confirm: z.literal(true) },
43
+ handler: async (args, client) => client.request("POST", "asdf/uninstall", { body: { name: args.name, version: args.version } }),
44
+ },
45
+ {
46
+ name: "ecp_asdf_set_global",
47
+ description: "Set the global default version for a plugin.",
48
+ inputSchema: { name: z.string(), version: z.string() },
49
+ handler: async (args, client) => client.request("POST", "asdf/global", { body: args }),
50
+ },
51
+ ];