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.
@@ -0,0 +1,135 @@
1
+ import { z } from "zod";
2
+ // Maps to router/mongodb.go -> ehm-api's ecp-mongodb controller. Document-
3
+ // shaped (collections/documents), not table/row-shaped like the other three
4
+ // engines, so it's hand-written rather than run through sql-engine-factory.
5
+ //
6
+ // exportDatabase/importDatabase are NOT exposed: Mongo's dump format is a
7
+ // binary .archive (application/octet-stream), unlike the other engines'
8
+ // plain-text .sql - doesn't fit an MCP tool response/input well, same
9
+ // reasoning as the file-system direct-download/upload punt. Use
10
+ // ecp_mongo_backup_to_storage_bd / restore_from_storage_bd instead.
11
+ const rowCredsShape = { db_name: z.string(), collection_name: z.string(), db_username: z.string(), password: z.string() };
12
+ export const mongodbTools = [
13
+ {
14
+ name: "ecp_mongo_create_database",
15
+ description: "Create a MongoDB database. db_name gets the account's own prefix applied automatically. db_username must already exist (see ecp_mongo_create_user).",
16
+ inputSchema: { db_name: z.string(), db_username: z.string() },
17
+ handler: async (args, client) => client.request("POST", "mongodb/createDatabase", { body: args }),
18
+ },
19
+ {
20
+ name: "ecp_mongo_delete_database",
21
+ description: "Delete a MongoDB database. Irreversible.",
22
+ inputSchema: { db_name: z.string(), confirm: z.literal(true) },
23
+ handler: async (args, client) => client.request("POST", "mongodb/deleteDatabase", { body: { db_name: args.db_name } }),
24
+ },
25
+ {
26
+ name: "ecp_mongo_list_databases",
27
+ description: "List this account's MongoDB databases.",
28
+ inputSchema: {},
29
+ handler: async (_args, client) => client.request("GET", "mongodb/getDatabaseByUser"),
30
+ },
31
+ {
32
+ name: "ecp_mongo_database_sizes",
33
+ description: "Get size of each MongoDB database.",
34
+ inputSchema: {},
35
+ handler: async (_args, client) => client.request("GET", "mongodb/getDatabaseSizes"),
36
+ },
37
+ {
38
+ name: "ecp_mongo_list_collections",
39
+ description: "List collections in a database (metadata only, no document data).",
40
+ inputSchema: { db_name: z.string() },
41
+ handler: async (args, client) => client.request("GET", "mongodb/listCollections", { query: { db_name: args.db_name } }),
42
+ },
43
+ {
44
+ name: "ecp_mongo_create_collection",
45
+ description: "Create a collection in a database.",
46
+ inputSchema: { db_name: z.string(), collection_name: z.string() },
47
+ handler: async (args, client) => client.request("POST", "mongodb/createCollection", { body: args }),
48
+ },
49
+ {
50
+ name: "ecp_mongo_drop_collection",
51
+ description: "Drop (delete) a collection entirely. Irreversible.",
52
+ inputSchema: { db_name: z.string(), collection_name: z.string(), confirm: z.literal(true) },
53
+ handler: async (args, client) => client.request("POST", "mongodb/dropCollection", { body: { db_name: args.db_name, collection_name: args.collection_name } }),
54
+ },
55
+ {
56
+ name: "ecp_mongo_browse_documents",
57
+ description: "Browse documents in a collection. Connects as the given db_username/password, which must be a user this account owns.",
58
+ inputSchema: {
59
+ ...rowCredsShape,
60
+ page: z.number().optional(),
61
+ page_size: z.number().optional(),
62
+ sort_field: z.string().optional(),
63
+ sort_direction: z.enum(["asc", "desc"]).optional(),
64
+ filter: z.record(z.string(), z.unknown()).optional(),
65
+ },
66
+ handler: async (args, client) => client.request("POST", "mongodb/browseDocuments", { body: args }),
67
+ },
68
+ {
69
+ name: "ecp_mongo_insert_document",
70
+ description: "Insert a document into a collection.",
71
+ inputSchema: { ...rowCredsShape, document: z.record(z.string(), z.unknown()), confirm: z.literal(true) },
72
+ handler: async (args, client) => client.request("POST", "mongodb/insertDocument", { body: args }),
73
+ },
74
+ {
75
+ name: "ecp_mongo_update_document",
76
+ description: "Update a document, identified by id.",
77
+ inputSchema: { ...rowCredsShape, id: z.string(), values: z.record(z.string(), z.unknown()), confirm: z.literal(true) },
78
+ handler: async (args, client) => client.request("POST", "mongodb/updateDocument", { body: args }),
79
+ },
80
+ {
81
+ name: "ecp_mongo_delete_document",
82
+ description: "Delete a document, identified by id. Irreversible.",
83
+ inputSchema: { ...rowCredsShape, id: z.string(), confirm: z.literal(true) },
84
+ handler: async (args, client) => client.request("POST", "mongodb/deleteDocument", { body: args }),
85
+ },
86
+ {
87
+ name: "ecp_mongo_backup_to_storage_bd",
88
+ description: "Back up a MongoDB database to the account's storage.bd tenant.",
89
+ inputSchema: { db_name: z.string() },
90
+ handler: async (args, client) => client.request("POST", "mongodb/backup-to-storage-bd", { body: { db_name: args.db_name } }),
91
+ },
92
+ {
93
+ name: "ecp_mongo_restore_from_storage_bd",
94
+ description: "Restore a MongoDB database from a storage.bd snapshot, overwriting its current content. Irreversible.",
95
+ inputSchema: { db_name: z.string(), snapshot_id: z.string(), confirm: z.literal(true) },
96
+ handler: async (args, client) => client.request("POST", "mongodb/restore-from-storage-bd", { body: { db_name: args.db_name, snapshot_id: args.snapshot_id } }),
97
+ },
98
+ // Users
99
+ {
100
+ name: "ecp_mongo_list_users",
101
+ description: "List additional MongoDB users on this account.",
102
+ inputSchema: {},
103
+ handler: async (_args, client) => client.request("GET", "mongodb/getUserList"),
104
+ },
105
+ {
106
+ name: "ecp_mongo_create_user",
107
+ description: "Create a MongoDB user. db_username gets the account's own prefix applied automatically. Grants readWrite on this account's default database - MongoDB here has no read-only role option, unlike MySQL/Postgres's granular privilege grants.",
108
+ inputSchema: { db_username: z.string(), password: z.string() },
109
+ handler: async (args, client) => client.request("POST", "mongodb/create-user", { body: args }),
110
+ },
111
+ {
112
+ name: "ecp_mongo_delete_user",
113
+ description: "Delete a MongoDB user. Irreversible.",
114
+ inputSchema: { db_username: z.string(), confirm: z.literal(true) },
115
+ handler: async (args, client) => client.request("POST", "mongodb/deleteUser", { body: { db_username: args.db_username } }),
116
+ },
117
+ {
118
+ name: "ecp_mongo_update_user_password",
119
+ description: "Change a MongoDB user's password.",
120
+ inputSchema: { db_username: z.string(), password: z.string() },
121
+ handler: async (args, client) => client.request("POST", "mongodb/updateUserPassword", { body: args }),
122
+ },
123
+ {
124
+ name: "ecp_mongo_assign_user_to_database",
125
+ description: "Grant a MongoDB user readWrite access to a database (both must already belong to this account). MongoDB only supports whole-database readWrite here - no read-only or per-collection grants like MySQL/Postgres. Security-sensitive - review carefully before confirming.",
126
+ inputSchema: { db_name: z.string(), db_username: z.string(), confirm: z.literal(true) },
127
+ handler: async (args, client) => client.request("POST", "mongodb/assignUserToDatabase", { body: args }),
128
+ },
129
+ ];
130
+ // There is no ecp_mongo_grant_new_db tool: the endpoint it would have
131
+ // wrapped (ehm-api's mongodb/grantNewDb) had no caller anywhere in ecp-ui or
132
+ // ecp-go, used a mismatched {username, dbname} body shape, and skipped the
133
+ // identifier validation its sibling assignUserToDatabase applies - it was
134
+ // removed from ehm-api and ecp-go entirely rather than left as dead/unsafe
135
+ // code. assignUserToDatabase above is the one real way to grant access.
@@ -0,0 +1,45 @@
1
+ import { z } from "zod";
2
+ // Maps to apps.go's oneclick/WordPress routes. ecp_oneclick_run_cmd is
3
+ // deliberately NOT exposed: oneclick.RunCmd (handler/apps/oneclick/oneclick.go)
4
+ // runs a caller-supplied `command` string through the same fire-and-forget
5
+ // ExecRto shell primitive as custom-command/execute - it's meant to carry a
6
+ // blueprint's own predefined install steps, but nothing stops the MCP
7
+ // caller from putting anything there. Same risk class as the blocked
8
+ // Phase 7 command execution, so it stays out until that's resolved.
9
+ // Consequence: ecp_oneclick_install_wordpress only scaffolds the app
10
+ // directory + nginx block + wp-config.php HTTPS fix - it does NOT actually
11
+ // run the WordPress installer (that's normally a run-cmd call using the
12
+ // blueprint's cmdSteps). Fetch the blueprint with ecp_oneclick_get_blueprint
13
+ // to see what commands would need to run, and use ecp_files_* / your own
14
+ // terminal to run them manually for now.
15
+ export const oneclickTools = [
16
+ {
17
+ name: "ecp_oneclick_blueprint_apps",
18
+ description: "List available one-click app blueprints (fetched from the public EH blueprints catalog).",
19
+ inputSchema: {},
20
+ handler: async (_args, client) => client.request("GET", "apps/oneclick/blueprint-apps"),
21
+ },
22
+ {
23
+ name: "ecp_oneclick_get_blueprint",
24
+ description: "Get a blueprint's definition, including the install commands it expects to run (for you to review/run yourself - see note on why this MCP server doesn't run them automatically).",
25
+ inputSchema: { name: z.string(), version: z.string() },
26
+ handler: async (args, client) => client.request("GET", `apps/oneclick/blueprint/${args.name}/${args.version}`),
27
+ },
28
+ {
29
+ name: "ecp_oneclick_install_wordpress",
30
+ description: "Scaffold a WordPress app: creates the app directory, nginx server block, and patches wp-config.php for HTTPS. Does NOT install WordPress itself - see ecp_oneclick_get_blueprint and run its install commands yourself afterward.",
31
+ inputSchema: {
32
+ app_name: z.string(),
33
+ app_dir: z.string(),
34
+ domain: z.string(),
35
+ php_version: z.string(),
36
+ },
37
+ handler: async (args, client) => client.request("POST", "apps/oneclick/wordpress", { body: args }),
38
+ },
39
+ {
40
+ name: "ecp_oneclick_create_database",
41
+ description: "Create a MySQL user + database in one step, for use during a one-click app install. If user creation fails (e.g. already exists), database creation is still attempted - check ecp_mysql_list_db_users/ecp_mysql_list_databases afterward if unsure.",
42
+ inputSchema: { db_name: z.string(), db_user: z.string(), db_pass: z.string() },
43
+ handler: async (args, client) => client.request("POST", "apps/oneclick/create-database", { body: args }),
44
+ },
45
+ ];
@@ -0,0 +1,21 @@
1
+ import { makeSqlEngineTools } from "./sql-engine-factory.js";
2
+ export const mssqlTools = makeSqlEngineTools({
3
+ key: "mssql",
4
+ label: "MSSQL",
5
+ routePrefix: "database/mssql",
6
+ createDatabaseNeedsPassword: true,
7
+ hasExportImport: false,
8
+ // Exact allowlist from ehm-api's MSSQL_GRANTABLE_TABLE_PERMISSIONS.
9
+ grantablePrivileges: ["SELECT", "INSERT", "UPDATE", "DELETE", "REFERENCES"],
10
+ privilegeScopeNote: "Note: MSSQL's privilege model here is coarser than MySQL/Postgres - only these 5 DML permissions, applied schema-wide (SCHEMA::dbo), not per-table.",
11
+ });
12
+ export const postgresTools = makeSqlEngineTools({
13
+ key: "postgres",
14
+ label: "Postgres",
15
+ routePrefix: "database/postgres",
16
+ createDatabaseNeedsPassword: false,
17
+ hasExportImport: true,
18
+ // Exact allowlist from ehm-api's POSTGRES_GRANTABLE_TABLE_PRIVILEGES.
19
+ grantablePrivileges: ["SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER"],
20
+ privilegeScopeNote: "Applied per-table (all tables in the public schema) plus default privileges for future tables.",
21
+ });
@@ -0,0 +1,48 @@
1
+ import { z } from "zod";
2
+ // Maps to router/resource-monitor.go - account resource/quota status and
3
+ // notifications. All read-only or low-risk state changes (dismiss/mark
4
+ // read) - nothing here is destructive to app/data state.
5
+ export const resourceMonitorTools = [
6
+ {
7
+ name: "ecp_resource_status",
8
+ description: "Get this account's resource/quota status (e.g. disk or CPU pressure, suspension warnings).",
9
+ inputSchema: {},
10
+ handler: async (_args, client) => client.request("GET", "resource-status"),
11
+ },
12
+ {
13
+ name: "ecp_resource_status_dismiss",
14
+ description: "Dismiss a resource-status warning banner.",
15
+ inputSchema: { resource_type: z.string() },
16
+ handler: async (args, client) => client.request("PATCH", `resource-status/${args.resource_type}/dismiss`),
17
+ },
18
+ {
19
+ name: "ecp_notifications_list",
20
+ description: "List this account's notifications.",
21
+ inputSchema: { unread: z.boolean().optional() },
22
+ handler: async (args, client) => client.request("GET", "notifications", { query: { unread: args.unread } }),
23
+ },
24
+ {
25
+ name: "ecp_notifications_mark_read",
26
+ description: "Mark one notification read.",
27
+ inputSchema: { id: z.union([z.string(), z.number()]) },
28
+ handler: async (args, client) => client.request("PATCH", `notifications/${args.id}/read`),
29
+ },
30
+ {
31
+ name: "ecp_notifications_mark_all_read",
32
+ description: "Mark all notifications read.",
33
+ inputSchema: {},
34
+ handler: async (_args, client) => client.request("PATCH", "notifications/read-all"),
35
+ },
36
+ {
37
+ name: "ecp_notifications_delete",
38
+ description: "Delete one notification. Irreversible.",
39
+ inputSchema: { id: z.union([z.string(), z.number()]), confirm: z.literal(true) },
40
+ handler: async (args, client) => client.request("DELETE", `notifications/${args.id}`),
41
+ },
42
+ {
43
+ name: "ecp_notifications_clear_all",
44
+ description: "Delete all notifications. Irreversible.",
45
+ inputSchema: { confirm: z.literal(true) },
46
+ handler: async (_args, client) => client.request("DELETE", "notifications"),
47
+ },
48
+ ];
@@ -0,0 +1,177 @@
1
+ import { z } from "zod";
2
+ const rowCredsShape = { db_name: z.string(), table_name: z.string(), db_username: z.string(), password: z.string() };
3
+ export function makeSqlEngineTools(cfg) {
4
+ const p = (path) => `${cfg.routePrefix}/${path}`;
5
+ const name = (suffix) => `ecp_${cfg.key}_${suffix}`;
6
+ const privilegesShape = {
7
+ db_name: z.string(),
8
+ db_username: z.string(),
9
+ privileges: z.array(z.enum(cfg.grantablePrivileges)),
10
+ };
11
+ const createDatabaseSchema = {
12
+ db_name: z.string(),
13
+ db_username: z.string(),
14
+ ...(cfg.createDatabaseNeedsPassword ? { password: z.string() } : {}),
15
+ };
16
+ const tools = [
17
+ {
18
+ name: name("create_database"),
19
+ description: `Create a ${cfg.label} database. db_name gets the account's own prefix applied automatically.${cfg.createDatabaseNeedsPassword ? " Creates the login together with the database." : " db_username must already exist (see " + name("create_database_user") + ")."}`,
20
+ inputSchema: createDatabaseSchema,
21
+ handler: async (args, client) => client.request("POST", p("createDatabase"), { body: args }),
22
+ },
23
+ {
24
+ name: name("delete_database"),
25
+ description: `Delete a ${cfg.label} database. Irreversible.`,
26
+ inputSchema: { db_name: z.string(), confirm: z.literal(true) },
27
+ handler: async (args, client) => client.request("POST", p("deleteDatabase"), { body: { db_name: args.db_name } }),
28
+ },
29
+ {
30
+ name: name("list_databases"),
31
+ description: `List this account's ${cfg.label} databases.`,
32
+ inputSchema: {},
33
+ handler: async (_args, client) => client.request("GET", p("getDatabaseByUser")),
34
+ },
35
+ {
36
+ name: name("database_sizes"),
37
+ description: `Get size of each ${cfg.label} database.`,
38
+ inputSchema: {},
39
+ handler: async (_args, client) => client.request("GET", p("getDatabaseSizes")),
40
+ },
41
+ {
42
+ name: name("table_sizes"),
43
+ description: `Get size of each table in a ${cfg.label} database.`,
44
+ inputSchema: { db_name: z.string() },
45
+ handler: async (args, client) => client.request("GET", p("getTableSizes"), { query: { db_name: args.db_name } }),
46
+ },
47
+ {
48
+ name: name("list_columns"),
49
+ description: "List a table's columns (metadata only, no row data).",
50
+ inputSchema: { db_name: z.string(), table_name: z.string() },
51
+ handler: async (args, client) => client.request("GET", p("listColumns"), { query: { db_name: args.db_name, table_name: args.table_name } }),
52
+ },
53
+ {
54
+ name: name("truncate_table"),
55
+ description: "Delete all rows from a table. Irreversible.",
56
+ inputSchema: { db_name: z.string(), table_name: z.string(), confirm: z.literal(true) },
57
+ handler: async (args, client) => client.request("POST", p("truncateTable"), { body: { db_name: args.db_name, table_name: args.table_name } }),
58
+ },
59
+ {
60
+ name: name("drop_table"),
61
+ description: "Drop (delete) a table entirely. Irreversible.",
62
+ inputSchema: { db_name: z.string(), table_name: z.string(), confirm: z.literal(true) },
63
+ handler: async (args, client) => client.request("POST", p("dropTable"), { body: { db_name: args.db_name, table_name: args.table_name } }),
64
+ },
65
+ {
66
+ name: name("browse_rows"),
67
+ description: "Browse rows in a table. Connects as the given db_username/password, which must be a user this account owns.",
68
+ inputSchema: {
69
+ ...rowCredsShape,
70
+ page: z.number().optional(),
71
+ page_size: z.number().optional(),
72
+ sort_column: z.string().optional(),
73
+ sort_direction: z.enum(["asc", "desc"]).optional(),
74
+ filters: z.record(z.string(), z.unknown()).optional(),
75
+ },
76
+ handler: async (args, client) => client.request("POST", p("browseRows"), { body: args }),
77
+ },
78
+ {
79
+ name: name("insert_row"),
80
+ description: "Insert a row into a table.",
81
+ inputSchema: { ...rowCredsShape, values: z.record(z.string(), z.unknown()), confirm: z.literal(true) },
82
+ handler: async (args, client) => client.request("POST", p("insertRow"), { body: args }),
83
+ },
84
+ {
85
+ name: name("update_row"),
86
+ description: "Update a row in a table, identified by primary_key.",
87
+ inputSchema: {
88
+ ...rowCredsShape,
89
+ primary_key: z.record(z.string(), z.unknown()),
90
+ values: z.record(z.string(), z.unknown()),
91
+ confirm: z.literal(true),
92
+ },
93
+ handler: async (args, client) => client.request("POST", p("updateRow"), { body: args }),
94
+ },
95
+ {
96
+ name: name("delete_row"),
97
+ description: "Delete a row from a table, identified by primary_key. Irreversible.",
98
+ inputSchema: { ...rowCredsShape, primary_key: z.record(z.string(), z.unknown()), confirm: z.literal(true) },
99
+ handler: async (args, client) => client.request("POST", p("deleteRow"), { body: args }),
100
+ },
101
+ {
102
+ name: name("backup_to_storage_bd"),
103
+ description: `Back up a ${cfg.label} database to the account's storage.bd tenant.`,
104
+ inputSchema: { db_name: z.string() },
105
+ handler: async (args, client) => client.request("POST", p("backup-to-storage-bd"), { body: { db_name: args.db_name } }),
106
+ },
107
+ {
108
+ name: name("restore_from_storage_bd"),
109
+ description: `Restore a ${cfg.label} database from a storage.bd snapshot, overwriting its current content. Irreversible.`,
110
+ inputSchema: { db_name: z.string(), snapshot_id: z.string(), confirm: z.literal(true) },
111
+ handler: async (args, client) => client.request("POST", p("restore-from-storage-bd"), {
112
+ body: { db_name: args.db_name, snapshot_id: args.snapshot_id },
113
+ }),
114
+ },
115
+ {
116
+ name: name("list_db_users"),
117
+ description: `List additional ${cfg.label} users on this account.`,
118
+ inputSchema: {},
119
+ handler: async (_args, client) => client.request("GET", p("getDbUserList")),
120
+ },
121
+ {
122
+ name: name("create_database_user"),
123
+ description: `Create an additional ${cfg.label} user. db_username gets the account's own prefix applied automatically.`,
124
+ inputSchema: { db_username: z.string(), password: z.string() },
125
+ handler: async (args, client) => client.request("POST", p("createDatabaseUser"), { body: args }),
126
+ },
127
+ {
128
+ name: name("delete_user"),
129
+ description: `Delete a ${cfg.label} user. Irreversible.`,
130
+ inputSchema: { db_username: z.string(), confirm: z.literal(true) },
131
+ handler: async (args, client) => client.request("POST", p("deleteUser"), { body: { db_username: args.db_username } }),
132
+ },
133
+ {
134
+ name: name("change_database_owner"),
135
+ description: "Change a database's owning user (both must already belong to this account).",
136
+ inputSchema: { db_name: z.string(), db_username: z.string() },
137
+ handler: async (args, client) => client.request("POST", p("changeDatabaseOwner"), { body: args }),
138
+ },
139
+ {
140
+ name: name("list_privileges"),
141
+ description: `List a ${cfg.label} user's privileges on a database. ${cfg.privilegeScopeNote}`,
142
+ inputSchema: { db_name: z.string(), db_username: z.string() },
143
+ handler: async (args, client) => client.request("GET", p("listPrivileges"), { query: args }),
144
+ },
145
+ {
146
+ name: name("grant_privileges"),
147
+ description: `Grant privileges to a user on a database. ${cfg.privilegeScopeNote} Security-sensitive - review carefully before confirming.`,
148
+ inputSchema: { ...privilegesShape, confirm: z.literal(true) },
149
+ handler: async (args, client) => client.request("POST", p("grantPrivileges"), { body: args }),
150
+ },
151
+ {
152
+ name: name("revoke_privileges"),
153
+ description: `Revoke privileges from a user on a database. ${cfg.privilegeScopeNote}`,
154
+ inputSchema: { ...privilegesShape, confirm: z.literal(true) },
155
+ handler: async (args, client) => client.request("POST", p("revokePrivileges"), { body: args }),
156
+ },
157
+ ];
158
+ if (cfg.hasExportImport) {
159
+ tools.push({
160
+ name: name("export_database"),
161
+ description: `Export a ${cfg.label} database as a .sql dump (returned as text - large databases will produce a large result, consider ${name("backup_to_storage_bd")} instead for anything beyond a quick look).`,
162
+ inputSchema: { db_name: z.string() },
163
+ handler: async (args, client) => client.request("GET", p("exportDatabase"), { query: { db_name: args.db_name } }),
164
+ }, {
165
+ name: name("import_database"),
166
+ description: `Import a .sql dump into an existing ${cfg.label} database, overwriting its content. Irreversible - pass the full SQL as text.`,
167
+ inputSchema: { db_name: z.string(), sql_content: z.string(), confirm: z.literal(true) },
168
+ handler: async (args, client) => client.requestMultipart(p("importDatabase"), { db_name: args.db_name }, {
169
+ fieldName: "file",
170
+ fileName: `${args.db_name}.sql`,
171
+ content: String(args.sql_content),
172
+ contentType: "application/sql",
173
+ }),
174
+ });
175
+ }
176
+ return tools;
177
+ }
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ // Maps to router/storage_bd.go - config get/set and job status only. Per
3
+ // the plan, the job-lock protocol endpoints (job/claim, job/:id/complete,
4
+ // config/secret) are NOT exposed here - ecp-go's own router never calls
5
+ // them either (they're internal, triggered by the browser-facing /backup
6
+ // websocket routes), confirming they're not part of ECP's real API surface.
7
+ export const storageBdTools = [
8
+ {
9
+ name: "ecp_storage_bd_get_config",
10
+ description: "Get this account's storage.bd backup config (client_id only - the secret is never returned).",
11
+ inputSchema: {},
12
+ handler: async (_args, client) => client.request("GET", "storage-bd/config"),
13
+ },
14
+ {
15
+ name: "ecp_storage_bd_set_config",
16
+ description: "Set this account's storage.bd backup credentials (client_id as '<tenant_id>.<install_id>', client_secret).",
17
+ inputSchema: { client_id: z.string(), client_secret: z.string(), confirm: z.literal(true) },
18
+ handler: async (args, client) => client.request("PATCH", "storage-bd/config", { body: args }),
19
+ },
20
+ {
21
+ name: "ecp_storage_bd_job_status",
22
+ description: "Check whether a storage.bd backup/restore job is currently running for this account.",
23
+ inputSchema: {},
24
+ handler: async (_args, client) => client.request("GET", "storage-bd/job/status"),
25
+ },
26
+ ];
@@ -0,0 +1,198 @@
1
+ import { z } from "zod";
2
+ // Maps to router/php.go, router/ssl.go, router/system.go, router/supervisor.go,
3
+ // router/crontab.go.
4
+ //
5
+ // php install/uninstall use the same fire-and-forget ExecRto primitive as
6
+ // the blocked custom-command/execute (confirmed by reading
7
+ // handler/php/*.go) - they start a real apt-get install/remove but the
8
+ // "output" field in the response is always empty. Flagged in the tool
9
+ // descriptions; verify success via ecp_php_installed_versions afterward.
10
+ //
11
+ // crontab/supervisor commands route through ecp-cli's buildArgs, which
12
+ // base64-encodes the JSON body into a single --body= flag before shelling
13
+ // out (ecp-cli.service.ts:38-54) - safe from shell injection regardless of
14
+ // content, unlike custom-command/execute's raw string. Crontab entries are
15
+ // a real, intentional ECP self-service feature (ecp-ui exposes it too), not
16
+ // a way around the Phase 7 command-execution block - but scheduling a
17
+ // command that runs repeatedly and unattended is still meaningfully
18
+ // different from a one-shot action, so it gets `confirm: true` too.
19
+ export const systemTools = [
20
+ // PHP
21
+ {
22
+ name: "ecp_php_installed_versions",
23
+ description: "List PHP versions installed on this account's container.",
24
+ inputSchema: {},
25
+ handler: async (_args, client) => client.request("GET", "php/installed-versions"),
26
+ },
27
+ {
28
+ name: "ecp_php_installed_packages",
29
+ description: "List installed PHP extensions for a version.",
30
+ inputSchema: { version: z.string() },
31
+ handler: async (args, client) => client.request("GET", `php/installed-packages/${args.version}`),
32
+ },
33
+ {
34
+ name: "ecp_php_get_ini",
35
+ description: "Get php.ini values for a PHP version.",
36
+ inputSchema: { version: z.string() },
37
+ handler: async (args, client) => client.request("GET", "php/ini", { query: { version: args.version } }),
38
+ },
39
+ {
40
+ name: "ecp_php_set_ini",
41
+ description: "Overwrite php.ini for a PHP version. Can break every app using that version if malformed.",
42
+ inputSchema: { version: z.string(), file_content: z.string(), confirm: z.literal(true) },
43
+ handler: async (args, client) => client.request("POST", "php/ini", { body: args }),
44
+ },
45
+ {
46
+ name: "ecp_php_install",
47
+ description: "Install a PHP version (apt-get, takes time). This tool cannot show install output - check ecp_php_installed_versions afterward to confirm it succeeded.",
48
+ inputSchema: { version: z.string(), confirm: z.literal(true) },
49
+ handler: async (args, client) => client.request("POST", "php/install", { body: { version: args.version } }),
50
+ },
51
+ {
52
+ name: "ecp_php_uninstall",
53
+ description: "Uninstall a PHP version. Breaks any app still configured to use it. This tool cannot show uninstall output - check ecp_php_installed_versions afterward.",
54
+ inputSchema: { version: z.string(), confirm: z.literal(true) },
55
+ handler: async (args, client) => client.request("POST", "php/uninstall", { body: { version: args.version } }),
56
+ },
57
+ // SSL
58
+ {
59
+ name: "ecp_ssl_available_certificates",
60
+ description: "List certificates available for a domain (pass certificate_name: 'lets_encrypt' or 'self_signed').",
61
+ inputSchema: { domain: z.string().optional(), certificate_name: z.enum(["lets_encrypt", "self_signed"]).optional() },
62
+ handler: async (args, client) => client.request("GET", "ssl/available-certificates", { query: args }),
63
+ },
64
+ {
65
+ name: "ecp_ssl_request_lets_encrypt",
66
+ description: "Issue a new Let's Encrypt certificate for a domain (does not apply it to nginx - see ecp_ssl_update_lets_encrypt or ecp_ssl_apply_certificate).",
67
+ inputSchema: { domain: z.string() },
68
+ handler: async (args, client) => client.request("POST", "ssl/request-lets-encrypt-certificate", { body: { domain: args.domain } }),
69
+ },
70
+ {
71
+ name: "ecp_ssl_update_lets_encrypt",
72
+ description: "Issue and apply a Let's Encrypt certificate to a domain's nginx config. Can break HTTPS for that domain if it fails partway.",
73
+ inputSchema: { domain: z.string(), confirm: z.literal(true) },
74
+ handler: async (args, client) => client.request("POST", "ssl/update-lets-encrypt-certificate", { body: { domain: args.domain, certificate_name: "lets_encrypt" } }),
75
+ },
76
+ {
77
+ name: "ecp_ssl_request_self_signed",
78
+ description: "Generate a new self-signed certificate for a domain (does not apply it to nginx).",
79
+ inputSchema: { domain: z.string() },
80
+ handler: async (args, client) => client.request("POST", "ssl/request-self-signed-certificate", { body: { domain: args.domain } }),
81
+ },
82
+ {
83
+ name: "ecp_ssl_update_self_signed",
84
+ description: "Generate and apply a self-signed certificate to a domain's nginx config. Can break HTTPS for that domain if it fails partway.",
85
+ inputSchema: { domain: z.string(), confirm: z.literal(true) },
86
+ handler: async (args, client) => client.request("POST", "ssl/update-self-signed-certificate", { body: { domain: args.domain, certificate_name: "self_signed" } }),
87
+ },
88
+ {
89
+ name: "ecp_ssl_apply_certificate",
90
+ description: "Apply an already-generated certificate to a domain's nginx config, without regenerating it. Can break HTTPS for that domain if misapplied.",
91
+ inputSchema: { domain: z.string(), certificate_name: z.enum(["lets_encrypt", "self_signed"]), confirm: z.literal(true) },
92
+ handler: async (args, client) => client.request("POST", "ssl/apply-certificate", { body: args }),
93
+ },
94
+ // System
95
+ {
96
+ name: "ecp_system_disk_usage",
97
+ description: "Get disk, container-temp-file, and database usage/quota for this account.",
98
+ inputSchema: {},
99
+ handler: async (_args, client) => client.request("GET", "system/quota/disk-usage"),
100
+ },
101
+ {
102
+ name: "ecp_system_check_for_update",
103
+ description: "Check whether an ECP/system update is available.",
104
+ inputSchema: {},
105
+ handler: async (_args, client) => client.request("GET", "system/update/check-for-update"),
106
+ },
107
+ {
108
+ name: "ecp_system_update",
109
+ description: "Update account/hosting settings (hosting_environment, hosting_version) or ECP password. Requires the account's own current password. Account-wide impact - review carefully.",
110
+ inputSchema: {
111
+ ecp_password: z.string(),
112
+ hosting_environment: z.string().optional(),
113
+ hosting_version: z.string().optional(),
114
+ confirm: z.literal(true),
115
+ },
116
+ handler: async (args, client) => client.request("POST", "system/update", { body: args }),
117
+ },
118
+ {
119
+ name: "ecp_system_get_config",
120
+ description: "Get this account's ECP config key/values.",
121
+ inputSchema: {},
122
+ handler: async (_args, client) => client.request("GET", "system/config"),
123
+ },
124
+ {
125
+ name: "ecp_system_set_config",
126
+ description: "Update ECP config key/values for this account.",
127
+ inputSchema: { config: z.record(z.string(), z.unknown()), confirm: z.literal(true) },
128
+ handler: async (args, client) => client.request("POST", "system/config", { body: args.config }),
129
+ },
130
+ // Supervisor (process management)
131
+ {
132
+ name: "ecp_supervisor_list_processes",
133
+ description: "List all supervised processes on this account.",
134
+ inputSchema: {},
135
+ handler: async (_args, client) => client.request("GET", "supervisor/processes"),
136
+ },
137
+ {
138
+ name: "ecp_supervisor_process_info",
139
+ description: "Get status/info for one supervised process.",
140
+ inputSchema: { app_name: z.string() },
141
+ handler: async (args, client) => client.request("GET", `supervisor/process-info/${args.app_name}`),
142
+ },
143
+ {
144
+ name: "ecp_supervisor_add_process",
145
+ description: "Register a new supervised (auto-restarting) process.",
146
+ inputSchema: {
147
+ name: z.string(),
148
+ command: z.string(),
149
+ directory: z.string(),
150
+ autostart: z.boolean().optional(),
151
+ environment: z.record(z.string(), z.string()).optional(),
152
+ },
153
+ handler: async (args, client) => client.request("POST", "supervisor/add-process", { body: args }),
154
+ },
155
+ {
156
+ name: "ecp_supervisor_remove_process",
157
+ description: "Remove a supervised process. Irreversible (config is deleted, not just stopped).",
158
+ inputSchema: { app_name: z.string(), confirm: z.literal(true) },
159
+ handler: async (args, client) => client.request("POST", `supervisor/remove-process/${args.app_name}`),
160
+ },
161
+ {
162
+ name: "ecp_supervisor_start_process",
163
+ description: "Start a supervised process.",
164
+ inputSchema: { app_name: z.string() },
165
+ handler: async (args, client) => client.request("POST", `supervisor/start-process/${args.app_name}`),
166
+ },
167
+ {
168
+ name: "ecp_supervisor_stop_process",
169
+ description: "Stop a supervised process.",
170
+ inputSchema: { app_name: z.string() },
171
+ handler: async (args, client) => client.request("POST", `supervisor/stop-process/${args.app_name}`),
172
+ },
173
+ {
174
+ name: "ecp_supervisor_restart_process",
175
+ description: "Restart a supervised process.",
176
+ inputSchema: { app_name: z.string() },
177
+ handler: async (args, client) => client.request("POST", `supervisor/restart-process/${args.app_name}`),
178
+ },
179
+ // Crontab
180
+ {
181
+ name: "ecp_crontab_list",
182
+ description: "List this account's scheduled cron jobs.",
183
+ inputSchema: {},
184
+ handler: async (_args, client) => client.request("GET", "crontab/list"),
185
+ },
186
+ {
187
+ name: "ecp_crontab_add",
188
+ description: "Schedule a cron job. cron_expression is a standard 5-field schedule (e.g. '0 3 * * *'). The command runs unattended, repeatedly, as this account's own system user - review carefully before confirming.",
189
+ inputSchema: { cron_expression: z.string(), command: z.string(), confirm: z.literal(true) },
190
+ handler: async (args, client) => client.request("POST", "crontab/add", { body: { cronExpression: args.cron_expression, command: args.command } }),
191
+ },
192
+ {
193
+ name: "ecp_crontab_remove",
194
+ description: "Remove a scheduled cron job. Must match an existing entry's cron_expression and command exactly (see ecp_crontab_list).",
195
+ inputSchema: { cron_expression: z.string(), command: z.string(), confirm: z.literal(true) },
196
+ handler: async (args, client) => client.request("DELETE", "crontab/remove", { body: { cronExpression: args.cron_expression, command: args.command } }),
197
+ },
198
+ ];