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 +21 -0
- package/LICENSE +21 -0
- package/README.md +118 -0
- package/dist/audit-log.js +39 -0
- package/dist/ecp-client.js +165 -0
- package/dist/index.js +99 -0
- package/dist/tools/account.js +13 -0
- package/dist/tools/apps.js +120 -0
- package/dist/tools/asdf.js +51 -0
- package/dist/tools/backup.js +21 -0
- package/dist/tools/database.js +198 -0
- package/dist/tools/domains.js +127 -0
- package/dist/tools/files.js +131 -0
- package/dist/tools/git-integrations.js +105 -0
- package/dist/tools/mongodb.js +135 -0
- package/dist/tools/oneclick.js +45 -0
- package/dist/tools/relational-engines.js +21 -0
- package/dist/tools/resource-monitor.js +48 -0
- package/dist/tools/sql-engine-factory.js +177 -0
- package/dist/tools/storage-bd.js +26 -0
- package/dist/tools/system.js +198 -0
- package/dist/tools/types.js +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Maps to router/backup.go - local restic snapshots of host paths, separate
|
|
2
|
+
// from storage.bd's own backup/restore (tools/storage-bd.ts). Only the read
|
|
3
|
+
// side is exposed:
|
|
4
|
+
//
|
|
5
|
+
// ecp_backup_path/ecp_backup_restore are NOT built. Both require a
|
|
6
|
+
// socket_id and run through the same job-claim/complete + WS-progress
|
|
7
|
+
// machinery as the already-excluded storage-bd job endpoints (confirmed by
|
|
8
|
+
// reading handler/backup/backup.go's BackupPath/RestorePath - they call
|
|
9
|
+
// claimJob/completeJob and stream progress to that socket) - same
|
|
10
|
+
// fire-and-forget, output-blind shape as the blocked command-execution
|
|
11
|
+
// tools, not just "needs an extra field." ListSnapshots has no such
|
|
12
|
+
// requirement - it runs `restic snapshots --json` synchronously and
|
|
13
|
+
// returns real output directly.
|
|
14
|
+
export const backupTools = [
|
|
15
|
+
{
|
|
16
|
+
name: "ecp_backup_list_snapshots",
|
|
17
|
+
description: "List local restic snapshots of this account's host paths (separate from storage.bd's own backups).",
|
|
18
|
+
inputSchema: {},
|
|
19
|
+
handler: async (_args, client) => client.request("GET", "backup/snapshots"),
|
|
20
|
+
},
|
|
21
|
+
];
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// Maps to router/database.go (MySQL + engine-agnostic status/connection-info)
|
|
3
|
+
// and the MySQL-user/privilege portion of router/database.go that proxies to
|
|
4
|
+
// ehm-api's mysql.controller.ts. db_name you pass is NOT pre-prefixed -
|
|
5
|
+
// ehm-api applies the account's own a<id>_ prefix server-side.
|
|
6
|
+
//
|
|
7
|
+
// createBackup (ehm-api's ecp/database/createBackup) is intentionally NOT
|
|
8
|
+
// exposed - ecp-go's own router/database.go never calls it either (ecp-ui
|
|
9
|
+
// doesn't use it), so per the "match the real client's own surface"
|
|
10
|
+
// architecture rule, it's not part of this MCP server either.
|
|
11
|
+
// Matches MYSQL_GRANTABLE_PRIVILEGES in ehm-api's mysql-identifier.util.ts
|
|
12
|
+
// exactly - ehm-api validates this server-side too, but constraining it
|
|
13
|
+
// here as well means a bad value fails fast in the tool schema instead of
|
|
14
|
+
// round-tripping to the server first, and the AI sees the real option list
|
|
15
|
+
// instead of guessing at free-form strings.
|
|
16
|
+
const MYSQL_PRIVILEGES = [
|
|
17
|
+
"SELECT", "INSERT", "UPDATE", "DELETE", "CREATE", "DROP", "ALTER", "INDEX",
|
|
18
|
+
"REFERENCES", "CREATE TEMPORARY TABLES", "LOCK TABLES", "EXECUTE",
|
|
19
|
+
"CREATE VIEW", "SHOW VIEW", "CREATE ROUTINE", "ALTER ROUTINE", "EVENT", "TRIGGER",
|
|
20
|
+
];
|
|
21
|
+
const privilegesShape = {
|
|
22
|
+
db_name: z.string(),
|
|
23
|
+
db_username: z.string(),
|
|
24
|
+
privileges: z.array(z.enum(MYSQL_PRIVILEGES)),
|
|
25
|
+
};
|
|
26
|
+
const rowCredsShape = { db_name: z.string(), table_name: z.string(), db_username: z.string(), password: z.string() };
|
|
27
|
+
export const databaseTools = [
|
|
28
|
+
{
|
|
29
|
+
name: "ecp_db_services_status",
|
|
30
|
+
description: "Check whether Postgres/MSSQL/Mongo are enabled/configured/reachable for this account (MySQL is always available - it's EHM's own DB engine, not an optional one).",
|
|
31
|
+
inputSchema: {},
|
|
32
|
+
handler: async (_args, client) => client.request("GET", "database/services-status"),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "ecp_db_connection_info",
|
|
36
|
+
description: "Get the static host/port connection info for each database engine, for apps running in this account's own container.",
|
|
37
|
+
inputSchema: {},
|
|
38
|
+
handler: async (_args, client) => client.request("GET", "database/connection-info"),
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "ecp_mysql_create_database",
|
|
42
|
+
description: "Create a MySQL database. db_name gets the account's own prefix applied automatically.",
|
|
43
|
+
inputSchema: { db_name: z.string(), db_username: z.string().optional() },
|
|
44
|
+
handler: async (args, client) => client.request("POST", "database/createMySqlDatabase", { body: args }),
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "ecp_mysql_delete_database",
|
|
48
|
+
description: "Delete a MySQL database. Irreversible.",
|
|
49
|
+
inputSchema: { db_name: z.string(), confirm: z.literal(true) },
|
|
50
|
+
handler: async (args, client) => client.request("POST", "database/deleteMySqlDatabase", { body: { db_name: args.db_name } }),
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "ecp_mysql_list_databases",
|
|
54
|
+
description: "List this account's MySQL databases.",
|
|
55
|
+
inputSchema: {},
|
|
56
|
+
handler: async (_args, client) => client.request("GET", "database/getMySqlDatabases"),
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "ecp_mysql_database_sizes",
|
|
60
|
+
description: "Get size (in bytes) of each MySQL database.",
|
|
61
|
+
inputSchema: {},
|
|
62
|
+
handler: async (_args, client) => client.request("GET", "database/getDatabaseSizes"),
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "ecp_mysql_table_sizes",
|
|
66
|
+
description: "Get size of each table in a MySQL database.",
|
|
67
|
+
inputSchema: { db_name: z.string() },
|
|
68
|
+
handler: async (args, client) => client.request("GET", "database/getTableSizes", { query: { db_name: args.db_name } }),
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "ecp_mysql_list_columns",
|
|
72
|
+
description: "List a table's columns (metadata only, no row data).",
|
|
73
|
+
inputSchema: { db_name: z.string(), table_name: z.string() },
|
|
74
|
+
handler: async (args, client) => client.request("GET", "database/listColumns", { query: { db_name: args.db_name, table_name: args.table_name } }),
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "ecp_mysql_truncate_table",
|
|
78
|
+
description: "Delete all rows from a table. Irreversible.",
|
|
79
|
+
inputSchema: { db_name: z.string(), table_name: z.string(), confirm: z.literal(true) },
|
|
80
|
+
handler: async (args, client) => client.request("POST", "database/truncateTable", { body: { db_name: args.db_name, table_name: args.table_name } }),
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "ecp_mysql_drop_table",
|
|
84
|
+
description: "Drop (delete) a table entirely. Irreversible.",
|
|
85
|
+
inputSchema: { db_name: z.string(), table_name: z.string(), confirm: z.literal(true) },
|
|
86
|
+
handler: async (args, client) => client.request("POST", "database/dropTable", { body: { db_name: args.db_name, table_name: args.table_name } }),
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "ecp_mysql_browse_rows",
|
|
90
|
+
description: "Browse rows in a table. Connects as the given MySQL user (db_username/password), which must be a user this account owns.",
|
|
91
|
+
inputSchema: {
|
|
92
|
+
...rowCredsShape,
|
|
93
|
+
page: z.number().optional(),
|
|
94
|
+
page_size: z.number().optional(),
|
|
95
|
+
sort_column: z.string().optional(),
|
|
96
|
+
sort_direction: z.enum(["asc", "desc"]).optional(),
|
|
97
|
+
filters: z.record(z.string(), z.unknown()).optional(),
|
|
98
|
+
},
|
|
99
|
+
handler: async (args, client) => client.request("POST", "database/browseRows", { body: args }),
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "ecp_mysql_insert_row",
|
|
103
|
+
description: "Insert a row into a table.",
|
|
104
|
+
inputSchema: { ...rowCredsShape, values: z.record(z.string(), z.unknown()), confirm: z.literal(true) },
|
|
105
|
+
handler: async (args, client) => client.request("POST", "database/insertRow", { body: args }),
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "ecp_mysql_update_row",
|
|
109
|
+
description: "Update a row in a table, identified by primary_key.",
|
|
110
|
+
inputSchema: {
|
|
111
|
+
...rowCredsShape,
|
|
112
|
+
primary_key: z.record(z.string(), z.unknown()),
|
|
113
|
+
values: z.record(z.string(), z.unknown()),
|
|
114
|
+
confirm: z.literal(true),
|
|
115
|
+
},
|
|
116
|
+
handler: async (args, client) => client.request("POST", "database/updateRow", { body: args }),
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "ecp_mysql_delete_row",
|
|
120
|
+
description: "Delete a row from a table, identified by primary_key. Irreversible.",
|
|
121
|
+
inputSchema: { ...rowCredsShape, primary_key: z.record(z.string(), z.unknown()), confirm: z.literal(true) },
|
|
122
|
+
handler: async (args, client) => client.request("POST", "database/deleteRow", { body: args }),
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "ecp_mysql_export_database",
|
|
126
|
+
description: "Export a MySQL database as a .sql dump (returned as text - large databases will produce a large result, consider ecp_mysql_backup_to_storage_bd instead for anything beyond a quick look).",
|
|
127
|
+
inputSchema: { db_name: z.string() },
|
|
128
|
+
handler: async (args, client) => client.request("GET", "database/exportDatabase", { query: { db_name: args.db_name } }),
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: "ecp_mysql_import_database",
|
|
132
|
+
description: "Import a .sql dump into an existing MySQL database, overwriting its content. Irreversible - pass the full SQL as text.",
|
|
133
|
+
inputSchema: { db_name: z.string(), sql_content: z.string(), confirm: z.literal(true) },
|
|
134
|
+
handler: async (args, client) => client.requestMultipart("database/importDatabase", { db_name: args.db_name }, {
|
|
135
|
+
fieldName: "file",
|
|
136
|
+
fileName: `${args.db_name}.sql`,
|
|
137
|
+
content: String(args.sql_content),
|
|
138
|
+
contentType: "application/sql",
|
|
139
|
+
}),
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "ecp_mysql_backup_to_storage_bd",
|
|
143
|
+
description: "Back up a MySQL database to the account's storage.bd tenant.",
|
|
144
|
+
inputSchema: { db_name: z.string() },
|
|
145
|
+
handler: async (args, client) => client.request("POST", "database/backup-to-storage-bd", { body: { db_name: args.db_name } }),
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: "ecp_mysql_restore_from_storage_bd",
|
|
149
|
+
description: "Restore a MySQL database from a storage.bd snapshot, overwriting its current content. Irreversible.",
|
|
150
|
+
inputSchema: { db_name: z.string(), snapshot_id: z.string(), confirm: z.literal(true) },
|
|
151
|
+
handler: async (args, client) => client.request("POST", "database/restore-from-storage-bd", {
|
|
152
|
+
body: { db_name: args.db_name, snapshot_id: args.snapshot_id },
|
|
153
|
+
}),
|
|
154
|
+
},
|
|
155
|
+
// MySQL additional users + privileges (mysql.controller.ts, proxied via database.go)
|
|
156
|
+
{
|
|
157
|
+
name: "ecp_mysql_list_db_users",
|
|
158
|
+
description: "List additional MySQL users on this account (beyond the account's own default user).",
|
|
159
|
+
inputSchema: {},
|
|
160
|
+
handler: async (_args, client) => client.request("GET", "database/getDbUserList"),
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: "ecp_mysql_create_db_user",
|
|
164
|
+
description: "Create an additional MySQL user. db_username gets the account's own prefix applied automatically.",
|
|
165
|
+
inputSchema: { db_username: z.string(), password: z.string() },
|
|
166
|
+
handler: async (args, client) => client.request("POST", "database/createMySqlDbUser", { body: args }),
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "ecp_mysql_delete_db_user",
|
|
170
|
+
description: "Delete an additional MySQL user. Irreversible.",
|
|
171
|
+
inputSchema: { db_username: z.string(), confirm: z.literal(true) },
|
|
172
|
+
handler: async (args, client) => client.request("POST", "database/deleteDbUser", { body: { db_username: args.db_username } }),
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: "ecp_mysql_change_db_user",
|
|
176
|
+
description: "Reassign a database to be owned by a different MySQL user (both must already belong to this account).",
|
|
177
|
+
inputSchema: { db_name: z.string(), db_username: z.string() },
|
|
178
|
+
handler: async (args, client) => client.request("POST", "database/changeDbUser", { body: args }),
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "ecp_mysql_list_privileges",
|
|
182
|
+
description: "List a MySQL user's privileges on a database.",
|
|
183
|
+
inputSchema: { db_name: z.string(), db_username: z.string() },
|
|
184
|
+
handler: async (args, client) => client.request("GET", "database/listPrivileges", { query: args }),
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: "ecp_mysql_grant_privileges",
|
|
188
|
+
description: "Grant privileges (e.g. ['SELECT','INSERT']) to a MySQL user on a database. Security-sensitive - review carefully before confirming.",
|
|
189
|
+
inputSchema: { ...privilegesShape, confirm: z.literal(true) },
|
|
190
|
+
handler: async (args, client) => client.request("POST", "database/grantPrivileges", { body: args }),
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: "ecp_mysql_revoke_privileges",
|
|
194
|
+
description: "Revoke privileges from a MySQL user on a database.",
|
|
195
|
+
inputSchema: { ...privilegesShape, confirm: z.literal(true) },
|
|
196
|
+
handler: async (args, client) => client.request("POST", "database/revokePrivileges", { body: args }),
|
|
197
|
+
},
|
|
198
|
+
];
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// Maps to router/domain.go, router/dns.go, router/network.go, router/nginx.go.
|
|
3
|
+
const dnsRecordShape = {
|
|
4
|
+
name: z.string(),
|
|
5
|
+
type: z.string(),
|
|
6
|
+
ttl: z.number().optional(),
|
|
7
|
+
value: z.string().optional(),
|
|
8
|
+
content: z.string().optional(),
|
|
9
|
+
comment: z.string().optional(),
|
|
10
|
+
proxied: z.boolean().optional(),
|
|
11
|
+
priority: z.number().optional(),
|
|
12
|
+
};
|
|
13
|
+
export const domainTools = [
|
|
14
|
+
{
|
|
15
|
+
name: "ecp_domains_list_all",
|
|
16
|
+
description: "List every domain (primary + additional) on this account.",
|
|
17
|
+
inputSchema: {},
|
|
18
|
+
handler: async (_args, client) => client.request("GET", "domain/all-domains"),
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "ecp_domains_list_additional",
|
|
22
|
+
description: "List additional (addon) domains only, excluding the primary domain.",
|
|
23
|
+
inputSchema: {},
|
|
24
|
+
handler: async (_args, client) => client.request("GET", "domain/additional-domains"),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "ecp_domains_add_domain",
|
|
28
|
+
description: "Add an additional (addon) domain to this account.",
|
|
29
|
+
inputSchema: { domain: z.string(), dns_server: z.string().nullable().optional() },
|
|
30
|
+
handler: async (args, client) => client.request("POST", "domain/add-domain", { body: args }),
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "ecp_domains_add_subdomain",
|
|
34
|
+
description: "Add a subdomain of a domain this account already owns.",
|
|
35
|
+
inputSchema: { domain: z.string(), subdomain: z.string() },
|
|
36
|
+
handler: async (args, client) => client.request("POST", "domain/add-subdomain", { body: args }),
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "ecp_domains_delete",
|
|
40
|
+
description: "Delete a domain from this account. Cannot delete the primary domain. Irreversible.",
|
|
41
|
+
inputSchema: { domain: z.string(), confirm: z.literal(true) },
|
|
42
|
+
handler: async (args, client) => client.request("POST", "domain/delete-domain", { body: { domain: args.domain } }),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "ecp_domains_set_redirect",
|
|
46
|
+
description: "Redirect a domain to another URL (e.g. www -> apex).",
|
|
47
|
+
inputSchema: {
|
|
48
|
+
domain: z.string(),
|
|
49
|
+
redirect_target: z.string(),
|
|
50
|
+
redirect_type: z.enum(["permanent", "temporary"]),
|
|
51
|
+
},
|
|
52
|
+
handler: async (args, client) => client.request("POST", "domain/set-redirect", { body: args }),
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "ecp_domains_remove_redirect",
|
|
56
|
+
description: "Remove a domain's redirect.",
|
|
57
|
+
inputSchema: { domain: z.string() },
|
|
58
|
+
handler: async (args, client) => client.request("POST", "domain/remove-redirect", { body: args }),
|
|
59
|
+
},
|
|
60
|
+
// DNS (Bind9-backed zones only - domains on Cloudflare are managed there instead)
|
|
61
|
+
{
|
|
62
|
+
name: "ecp_dns_list_records",
|
|
63
|
+
description: "List DNS records for a domain's zone.",
|
|
64
|
+
inputSchema: { domain: z.string() },
|
|
65
|
+
handler: async (args, client) => client.request("GET", `dns/records/domain/${args.domain}`),
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "ecp_dns_add_record",
|
|
69
|
+
description: "Add a DNS record to a domain's zone.",
|
|
70
|
+
inputSchema: { domain: z.string(), ...dnsRecordShape },
|
|
71
|
+
handler: async (args, client) => client.request("POST", "dns/add-record", { body: args }),
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "ecp_dns_delete_record",
|
|
75
|
+
description: "Delete a DNS record from a domain's zone. `record` must match the existing record (name/type/content) closely enough for the DNS provider to identify it.",
|
|
76
|
+
inputSchema: {
|
|
77
|
+
domain: z.string(),
|
|
78
|
+
record: z.object(dnsRecordShape),
|
|
79
|
+
confirm: z.literal(true),
|
|
80
|
+
},
|
|
81
|
+
handler: async (args, client) => client.request("POST", "dns/delete-record", { body: args }),
|
|
82
|
+
},
|
|
83
|
+
// Network / port mappings
|
|
84
|
+
{
|
|
85
|
+
name: "ecp_network_port_maps",
|
|
86
|
+
description: "List all port mappings on this account.",
|
|
87
|
+
inputSchema: {},
|
|
88
|
+
handler: async (_args, client) => client.request("GET", "network/port-maps"),
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "ecp_network_domain_port_maps",
|
|
92
|
+
description: "List port mappings for one domain.",
|
|
93
|
+
inputSchema: { domain: z.string() },
|
|
94
|
+
handler: async (args, client) => client.request("GET", `network/port-maps/${args.domain}`),
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: "ecp_network_update_port_maps",
|
|
98
|
+
description: "Update a port mapping and its nginx config. Can affect site routing.",
|
|
99
|
+
inputSchema: {
|
|
100
|
+
domain: z.string(),
|
|
101
|
+
host_port: z.number(),
|
|
102
|
+
guest_port: z.number(),
|
|
103
|
+
https: z.boolean().optional(),
|
|
104
|
+
description: z.string().optional(),
|
|
105
|
+
},
|
|
106
|
+
handler: async (args, client) => client.request("POST", "network/update-port-maps", { body: args }),
|
|
107
|
+
},
|
|
108
|
+
// Nginx
|
|
109
|
+
{
|
|
110
|
+
name: "ecp_nginx_list_domains",
|
|
111
|
+
description: "List domains that have an nginx config on this container.",
|
|
112
|
+
inputSchema: {},
|
|
113
|
+
handler: async (_args, client) => client.request("GET", "nginx/domains"),
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: "ecp_nginx_get_conf",
|
|
117
|
+
description: "Read the raw nginx config for a domain.",
|
|
118
|
+
inputSchema: { domain_name: z.string() },
|
|
119
|
+
handler: async (args, client) => client.request("GET", "nginx/conf", { query: { domain_name: args.domain_name } }),
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "ecp_nginx_set_conf",
|
|
123
|
+
description: "Overwrite the raw nginx config for a domain. Malformed content can break the site - verify the config is valid before writing.",
|
|
124
|
+
inputSchema: { domain_name: z.string(), file_content: z.string(), confirm: z.literal(true) },
|
|
125
|
+
handler: async (args, client) => client.request("POST", "nginx/conf", { body: args }),
|
|
126
|
+
},
|
|
127
|
+
];
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// Maps to router/file-system.go + router/code-editory.go - real local
|
|
3
|
+
// filesystem access on the account's own container, with no EHM-API
|
|
4
|
+
// equivalent at all. Genuinely useful ("show me this app's .env", "fix this
|
|
5
|
+
// config") and genuinely capable of damaging a live site, so every
|
|
6
|
+
// destructive op (delete, overwrite, move) requires confirm: true.
|
|
7
|
+
//
|
|
8
|
+
// direct-download and upload-recursive are intentionally NOT exposed here:
|
|
9
|
+
// both move raw binary bytes, which doesn't fit an MCP tool response well
|
|
10
|
+
// (same reasoning as the DB import/export punt in the plan) - revisit later
|
|
11
|
+
// if there's a concrete need.
|
|
12
|
+
export const filesTools = [
|
|
13
|
+
{
|
|
14
|
+
name: "ecp_files_list",
|
|
15
|
+
description: "List files/folders in a directory.",
|
|
16
|
+
inputSchema: { directory: z.string().optional(), hidden_files: z.boolean().optional() },
|
|
17
|
+
handler: async (args, client) => client.request("GET", "file-system/list", {
|
|
18
|
+
query: { directory: args.directory, "hidden-files": args.hidden_files },
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "ecp_files_directory_tree",
|
|
23
|
+
description: "Get the directory tree including files (for browsing/editing, unlike ecp_apps_directory_tree which is folders only).",
|
|
24
|
+
inputSchema: { directory: z.string().optional(), hidden_files: z.boolean().optional() },
|
|
25
|
+
handler: async (args, client) => client.request("GET", "code-editor/directory-tree", {
|
|
26
|
+
query: { directory: args.directory, "hidden-files": args.hidden_files },
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "ecp_files_is_directory_exists",
|
|
31
|
+
description: "Check whether a directory exists.",
|
|
32
|
+
inputSchema: { directory: z.string() },
|
|
33
|
+
handler: async (args, client) => client.request("GET", "file-system/is-directory-exists", { query: { directory: args.directory } }),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "ecp_files_read",
|
|
37
|
+
description: "Read a text file's content.",
|
|
38
|
+
inputSchema: { file_path: z.string() },
|
|
39
|
+
handler: async (args, client) => client.request("GET", "code-editor/file", { query: { "file-path": args.file_path } }),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "ecp_files_write",
|
|
43
|
+
description: "Overwrite a text file's content (creates it if it doesn't exist). Can break a running app if it's a config/env/source file - review the current content first.",
|
|
44
|
+
inputSchema: { file_path: z.string(), file_content: z.string(), confirm: z.literal(true) },
|
|
45
|
+
handler: async (args, client) => client.request("POST", "code-editor/file", {
|
|
46
|
+
body: { "file-path": args.file_path, "file-content": args.file_content },
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "ecp_files_add_file",
|
|
51
|
+
description: "Create a new empty file.",
|
|
52
|
+
inputSchema: { destination: z.string(), file_name: z.string() },
|
|
53
|
+
handler: async (args, client) => client.request("POST", "file-system/add-new-file", { body: args }),
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "ecp_files_add_folder",
|
|
57
|
+
description: "Create a new folder.",
|
|
58
|
+
inputSchema: { destination: z.string(), folder_name: z.string() },
|
|
59
|
+
handler: async (args, client) => client.request("POST", "file-system/add-new-folder", { body: args }),
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "ecp_files_rename",
|
|
63
|
+
description: "Rename a file or folder within a directory.",
|
|
64
|
+
inputSchema: { current_directory: z.string(), file_name: z.string(), new_name: z.string() },
|
|
65
|
+
handler: async (args, client) => client.request("POST", "file-system/rename", { body: args }),
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "ecp_files_copy",
|
|
69
|
+
description: "Copy one file/folder to a destination.",
|
|
70
|
+
inputSchema: { file_path: z.string(), destination: z.string() },
|
|
71
|
+
handler: async (args, client) => client.request("POST", "file-system/copy", { body: args }),
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "ecp_files_copy_multiple",
|
|
75
|
+
description: "Copy multiple files/folders to a destination.",
|
|
76
|
+
inputSchema: { file_paths: z.array(z.string()), destination: z.string() },
|
|
77
|
+
handler: async (args, client) => client.request("POST", "file-system/copy-multiple", { body: args }),
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "ecp_files_move",
|
|
81
|
+
description: "Move one file/folder to a destination.",
|
|
82
|
+
inputSchema: { file_path: z.string(), destination: z.string() },
|
|
83
|
+
handler: async (args, client) => client.request("POST", "file-system/move", { body: args }),
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "ecp_files_move_multiple",
|
|
87
|
+
description: "Move multiple files/folders to a destination.",
|
|
88
|
+
inputSchema: { file_paths: z.array(z.string()), destination: z.string() },
|
|
89
|
+
handler: async (args, client) => client.request("POST", "file-system/move-multiple", { body: args }),
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "ecp_files_change_permission",
|
|
93
|
+
description: "chmod a file (e.g. new_permission: '644').",
|
|
94
|
+
inputSchema: { current_directory: z.string(), file_name: z.string(), new_permission: z.string() },
|
|
95
|
+
handler: async (args, client) => client.request("POST", "file-system/change-permission", { body: args }),
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "ecp_files_compress",
|
|
99
|
+
description: "Compress one or more files/folders into an archive.",
|
|
100
|
+
inputSchema: {
|
|
101
|
+
file_paths: z.array(z.string()),
|
|
102
|
+
output_filename: z.string(),
|
|
103
|
+
current_directory: z.string(),
|
|
104
|
+
},
|
|
105
|
+
handler: async (args, client) => client.request("POST", "file-system/compress", {
|
|
106
|
+
body: {
|
|
107
|
+
filePaths: args.file_paths,
|
|
108
|
+
outputFilename: args.output_filename,
|
|
109
|
+
currentDirectory: args.current_directory,
|
|
110
|
+
},
|
|
111
|
+
}),
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "ecp_files_extract",
|
|
115
|
+
description: "Extract an archive into a destination directory.",
|
|
116
|
+
inputSchema: { file_path: z.string(), destination: z.string() },
|
|
117
|
+
handler: async (args, client) => client.request("POST", "file-system/extract", { body: args }),
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "ecp_files_delete",
|
|
121
|
+
description: "Delete a single file or folder. Irreversible.",
|
|
122
|
+
inputSchema: { file_path: z.string(), confirm: z.literal(true) },
|
|
123
|
+
handler: async (args, client) => client.request("POST", "file-system/delete", { body: { file_path: args.file_path } }),
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "ecp_files_delete_multiple",
|
|
127
|
+
description: "Delete multiple files/folders. Irreversible.",
|
|
128
|
+
inputSchema: { file_paths: z.array(z.string()), confirm: z.literal(true) },
|
|
129
|
+
handler: async (args, client) => client.request("POST", "file-system/delete-multiple", { body: { file_paths: args.file_paths } }),
|
|
130
|
+
},
|
|
131
|
+
];
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// Maps to router/git-integrations.go + router/git-webhook-management.go.
|
|
3
|
+
// clone-token is NOT exposed - it hands back a real git credential and is
|
|
4
|
+
// only ever called server-to-server from ecp-go's own create-from-git flow
|
|
5
|
+
// (already used internally by ecp_apps_create_from_git), never reachable
|
|
6
|
+
// from ecp-ui/browser either.
|
|
7
|
+
//
|
|
8
|
+
// Webhook commands (below) are a real, intentional ECP feature - what runs
|
|
9
|
+
// automatically on a future git push - same posture as crontab: legitimate
|
|
10
|
+
// and correctly implemented (no shell injection, per docs/GIT_WEBHOOKS.md),
|
|
11
|
+
// but the command runs unattended later, so it's confirm-gated.
|
|
12
|
+
const commandsShape = z.array(z.object({ title: z.string().optional(), command: z.string() }));
|
|
13
|
+
export const gitIntegrationTools = [
|
|
14
|
+
{
|
|
15
|
+
name: "ecp_git_list_providers",
|
|
16
|
+
description: "List git providers (GitHub/GitLab/Bitbucket) enabled for this install.",
|
|
17
|
+
inputSchema: {},
|
|
18
|
+
handler: async (_args, client) => client.request("GET", "account-git/providers"),
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "ecp_git_authorize_url",
|
|
22
|
+
description: "Get the OAuth authorize URL to connect a git provider. Open it in a browser to complete the connection - this tool can't complete OAuth itself.",
|
|
23
|
+
inputSchema: { provider: z.enum(["github", "gitlab", "bitbucket"]) },
|
|
24
|
+
handler: async (args, client) => client.request("GET", `account-git/${args.provider}/authorize`),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "ecp_git_list_connections",
|
|
28
|
+
description: "List this account's connected git accounts.",
|
|
29
|
+
inputSchema: {},
|
|
30
|
+
handler: async (_args, client) => client.request("GET", "account-git/connections"),
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "ecp_git_disconnect_provider",
|
|
34
|
+
description: "Disconnect a connected git provider.",
|
|
35
|
+
inputSchema: { provider: z.enum(["github", "gitlab", "bitbucket"]), confirm: z.literal(true) },
|
|
36
|
+
handler: async (args, client) => client.request("DELETE", `account-git/${args.provider}`),
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "ecp_git_list_repos",
|
|
40
|
+
description: "Browse repos available via a connected git provider (for picking one to deploy from).",
|
|
41
|
+
inputSchema: { provider: z.enum(["github", "gitlab", "bitbucket"]), search: z.string().optional(), page: z.number().optional() },
|
|
42
|
+
handler: async (args, client) => client.request("GET", `account-git/${args.provider}/repos`, { query: { search: args.search, page: args.page } }),
|
|
43
|
+
},
|
|
44
|
+
// Per-app deploy webhook management
|
|
45
|
+
{
|
|
46
|
+
name: "ecp_git_webhook_get",
|
|
47
|
+
description: "Get an app's git deploy-webhook config and status.",
|
|
48
|
+
inputSchema: { app_id: z.union([z.string(), z.number()]) },
|
|
49
|
+
handler: async (args, client) => client.request("GET", `account-git/apps/${args.app_id}/webhook`),
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "ecp_git_webhook_create",
|
|
53
|
+
description: "Create a deploy webhook for an app: runs `commands` automatically whenever a matching push arrives. Review each command carefully before confirming.",
|
|
54
|
+
inputSchema: {
|
|
55
|
+
app_id: z.union([z.string(), z.number()]),
|
|
56
|
+
provider: z.enum(["github", "gitlab", "bitbucket"]),
|
|
57
|
+
branch_filter: z.string().optional(),
|
|
58
|
+
commands: commandsShape.optional(),
|
|
59
|
+
confirm: z.literal(true),
|
|
60
|
+
},
|
|
61
|
+
handler: async (args, client) => {
|
|
62
|
+
const { app_id, confirm, ...body } = args;
|
|
63
|
+
return client.request("POST", `account-git/apps/${app_id}/webhook`, { body });
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "ecp_git_webhook_update",
|
|
68
|
+
description: "Update an app's deploy-webhook branch filter and/or commands. Review each command carefully before confirming.",
|
|
69
|
+
inputSchema: {
|
|
70
|
+
app_id: z.union([z.string(), z.number()]),
|
|
71
|
+
provider: z.enum(["github", "gitlab", "bitbucket"]),
|
|
72
|
+
branch_filter: z.string().optional(),
|
|
73
|
+
commands: commandsShape.optional(),
|
|
74
|
+
confirm: z.literal(true),
|
|
75
|
+
},
|
|
76
|
+
handler: async (args, client) => {
|
|
77
|
+
const { app_id, confirm, ...body } = args;
|
|
78
|
+
return client.request("PATCH", `account-git/apps/${app_id}/webhook`, { body });
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "ecp_git_webhook_delete",
|
|
83
|
+
description: "Delete an app's deploy webhook. Irreversible.",
|
|
84
|
+
inputSchema: { app_id: z.union([z.string(), z.number()]), confirm: z.literal(true) },
|
|
85
|
+
handler: async (args, client) => client.request("DELETE", `account-git/apps/${args.app_id}/webhook`),
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "ecp_git_webhook_rotate_secret",
|
|
89
|
+
description: "Rotate an app's deploy-webhook secret (invalidates the old one).",
|
|
90
|
+
inputSchema: { app_id: z.union([z.string(), z.number()]), confirm: z.literal(true) },
|
|
91
|
+
handler: async (args, client) => client.request("POST", `account-git/apps/${args.app_id}/webhook/rotate`),
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "ecp_git_webhook_capabilities",
|
|
95
|
+
description: "Get what webhook features the app's git provider supports.",
|
|
96
|
+
inputSchema: { app_id: z.union([z.string(), z.number()]) },
|
|
97
|
+
handler: async (args, client) => client.request("GET", `account-git/apps/${args.app_id}/webhook/capabilities`),
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "ecp_git_webhook_deliveries",
|
|
101
|
+
description: "List an app's webhook delivery history (for debugging why a push didn't deploy).",
|
|
102
|
+
inputSchema: { app_id: z.union([z.string(), z.number()]) },
|
|
103
|
+
handler: async (args, client) => client.request("GET", `account-git/apps/${args.app_id}/webhook/deliveries`),
|
|
104
|
+
},
|
|
105
|
+
];
|