@edgegap/mcp 0.14.1 → 0.15.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/README.md +3 -1
- package/dist/client.js +6 -0
- package/dist/outputs.js +1 -0
- package/dist/tools.js +145 -30
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -213,7 +213,7 @@ To keep your API token on your own machine, run the server locally instead. Leav
|
|
|
213
213
|
}
|
|
214
214
|
```
|
|
215
215
|
|
|
216
|
-
Needs Node 18+. Pin a version in production (`@edgegap/mcp@0.
|
|
216
|
+
Needs Node 18+. Pin a version in production (`@edgegap/mcp@0.15.0`) rather than floating on latest. Registered in the official MCP registry as `dev.edgegap/mcp`.
|
|
217
217
|
|
|
218
218
|
The local server can also limit what an agent can do. These variables have no effect on the hosted endpoint at `mcp.edgegap.dev`:
|
|
219
219
|
|
|
@@ -332,6 +332,8 @@ Container logs disappear with the deployment unless they are exported to your ow
|
|
|
332
332
|
| `edgegap_create_endpoint_storage` ● | Registers a bucket (AWS S3, Cloudflare R2, DigitalOcean Spaces…) for log export. Set `endpoint_storage` on a version to turn export on. The secret key is never echoed back. |
|
|
333
333
|
| `edgegap_create_pull_profile` ● | Copies a file or folder from the bucket into the container at boot (maps, configs, large assets). |
|
|
334
334
|
| `edgegap_link_pull_profile` ● | Links a pull profile to a version, or unlinks it. |
|
|
335
|
+
| `edgegap_delete_pull_profile` ● | Deletes one pull profile. The bucket and its files stay. |
|
|
336
|
+
| `edgegap_delete_endpoint_storage` ● | Deletes one Endpoint Storage; refused while it has pull profiles unless `max_pull_profiles` allows them. The bucket and its logs stay. |
|
|
335
337
|
|
|
336
338
|
### Relays (Host-Client Games Only)
|
|
337
339
|
|
package/dist/client.js
CHANGED
|
@@ -218,6 +218,12 @@ export class EdgegapClient {
|
|
|
218
218
|
createPullProfile(endpointName, body) {
|
|
219
219
|
return this.request('POST', 'v1', `/v1/storage/endpoint/${encodeURIComponent(endpointName)}/pull-profile`, { body });
|
|
220
220
|
}
|
|
221
|
+
deleteEndpointStorage(endpointName) {
|
|
222
|
+
return this.request('DELETE', 'v1', `/v1/storage/endpoint/${encodeURIComponent(endpointName)}`);
|
|
223
|
+
}
|
|
224
|
+
deletePullProfile(endpointName, profileName) {
|
|
225
|
+
return this.request('DELETE', 'v1', `/v1/storage/endpoint/${encodeURIComponent(endpointName)}/pull-profile/${encodeURIComponent(profileName)}`);
|
|
226
|
+
}
|
|
221
227
|
/** PUT links, DELETE unlinks; the path is the same. */
|
|
222
228
|
linkPullProfile(method, endpointName, profileName, appName, versionName) {
|
|
223
229
|
return this.request(method, 'v1', `/v1/storage/endpoint/${encodeURIComponent(endpointName)}/pull-profile/${encodeURIComponent(profileName)}` +
|
package/dist/outputs.js
CHANGED
package/dist/tools.js
CHANGED
|
@@ -301,6 +301,12 @@ function errorHint(err, notFound, forbidden) {
|
|
|
301
301
|
case 409:
|
|
302
302
|
return 'a resource with that name already exists. Pick a different name or reuse the existing one.';
|
|
303
303
|
case 422:
|
|
304
|
+
// require_cached_locations on a version without force_cache (live, 2026-10-28).
|
|
305
|
+
if (/caching disabled|enable caching/i.test(err.apiMessage)) {
|
|
306
|
+
return ('require_cached_locations needs image caching on the version. Turn it on with edgegap_update_app_version ' +
|
|
307
|
+
'force_cache: true and wait for caching_percent (edgegap_get_app_version) to rise, or deploy without ' +
|
|
308
|
+
'require_cached_locations.');
|
|
309
|
+
}
|
|
304
310
|
return 'Edgegap could not allocate a server for the requested location or resources. Try different user coordinates, or lower cpu_units/memory_mb.';
|
|
305
311
|
case 424:
|
|
306
312
|
return 'Edgegap could not pull the container image. Check docker_repository, docker_image, docker_tag, and registry credentials.';
|
|
@@ -407,10 +413,11 @@ function compactDeployment(d) {
|
|
|
407
413
|
}
|
|
408
414
|
/** The version fields every version tool shows. Never the registry token. */
|
|
409
415
|
function compactVersion(v) {
|
|
416
|
+
const ref = [v.docker_repository, v.docker_image].filter(Boolean).join('/');
|
|
410
417
|
return {
|
|
411
418
|
name: v.name,
|
|
412
419
|
active: v.is_active,
|
|
413
|
-
image:
|
|
420
|
+
image: v.docker_tag ? `${ref}:${v.docker_tag}` : ref,
|
|
414
421
|
// Whether a login is set, never the login itself: the API returns the
|
|
415
422
|
// registry token in version responses.
|
|
416
423
|
registry_credentials_set: Boolean(v.private_username && v.private_token),
|
|
@@ -924,8 +931,8 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
924
931
|
tool('edgegap_get_app_version', {
|
|
925
932
|
title: 'Get one application version',
|
|
926
933
|
description: 'Read one version in full: image, resources, ports, max_duration, whether image caching ' +
|
|
927
|
-
'(force_cache) and verify_image are on, restart policy,
|
|
928
|
-
'(values are never shown). Use it before edgegap_update_app_version or edgegap_deploy ' +
|
|
934
|
+
'(force_cache) and verify_image are on, restart policy, the Endpoint Storage its logs go to, and the names ' +
|
|
935
|
+
'of its env vars (values are never shown). Use it before edgegap_update_app_version or edgegap_deploy ' +
|
|
929
936
|
'to check what a version will do.',
|
|
930
937
|
inputSchema: {
|
|
931
938
|
application: z.string().describe('Application name.'),
|
|
@@ -943,6 +950,7 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
943
950
|
verify_image: v.verify_image,
|
|
944
951
|
restart_policy: v.restart_policy,
|
|
945
952
|
termination_grace_period_seconds: v.termination_grace_period_seconds,
|
|
953
|
+
endpoint_storage: v.endpoint_storage || undefined,
|
|
946
954
|
time_to_deploy_seconds: v.time_to_deploy,
|
|
947
955
|
env: v.envs?.map((e) => ({ key: e.key, hidden: e.is_hidden ?? false })),
|
|
948
956
|
...autoStop(v.max_duration),
|
|
@@ -1403,7 +1411,8 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
1403
1411
|
require_cached_locations: z
|
|
1404
1412
|
.boolean()
|
|
1405
1413
|
.optional()
|
|
1406
|
-
.describe('Only place it where the image is already cached: starts faster, fewer places to choose from.'
|
|
1414
|
+
.describe('Only place it where the image is already cached: starts faster, fewer places to choose from. Needs ' +
|
|
1415
|
+
'force_cache on the version (edgegap_update_app_version); without it the API refuses the deploy.'),
|
|
1407
1416
|
webhook_on_ready: z.string().optional().describe('https URL Edgegap POSTs to when the server is ready.'),
|
|
1408
1417
|
webhook_on_error: z.string().optional().describe('https URL Edgegap POSTs to when the deployment fails.'),
|
|
1409
1418
|
webhook_on_terminated: z.string().optional().describe('https URL Edgegap POSTs to when the deployment ends.'),
|
|
@@ -1492,19 +1501,30 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
1492
1501
|
`(EDGEGAP_MAX_DEPLOYS_PER_RUN=${perRun}). Nothing was sent. Stop what is running and ask the developer; ` +
|
|
1493
1502
|
'restarting the MCP server resets the count.');
|
|
1494
1503
|
}
|
|
1495
|
-
|
|
1504
|
+
// Edgegap has no per-deployment time limit: a deployment runs until
|
|
1505
|
+
// stopped or until its version's max_duration (default 1440 minutes,
|
|
1506
|
+
// a full day). Read it first so the agent knows how long an
|
|
1507
|
+
// unstopped test server will keep billing. A dry run reads it too,
|
|
1508
|
+
// so it previews the refusals below, but only with a token already
|
|
1509
|
+
// in hand (a dry run must not trigger the token prompt); if the read
|
|
1510
|
+
// fails, it still shows the request and says what it could not check.
|
|
1511
|
+
let version;
|
|
1512
|
+
try {
|
|
1513
|
+
if (args.dry_run && !auth.current)
|
|
1514
|
+
throw new Error('no API token in this session yet');
|
|
1515
|
+
version = await client.getAppVersion(args.application, args.version);
|
|
1516
|
+
}
|
|
1517
|
+
catch (err) {
|
|
1518
|
+
if (!args.dry_run)
|
|
1519
|
+
throw err;
|
|
1496
1520
|
const dry = client.dryRun();
|
|
1497
1521
|
await send(dry.client);
|
|
1498
1522
|
return dryRunResult(dry.requests, [
|
|
1499
1523
|
`Tagged "${AGENT_TAG}" automatically.`,
|
|
1500
|
-
|
|
1524
|
+
`Could not read the version (${err instanceof Error ? err.message.split('\n')[0] : String(err)}), so ` +
|
|
1525
|
+
'the docker tag, max_duration and running-deployment checks did not run. A real deploy runs them.',
|
|
1501
1526
|
]);
|
|
1502
1527
|
}
|
|
1503
|
-
// Edgegap has no per-deployment time limit: a deployment runs until
|
|
1504
|
-
// stopped or until its version's max_duration (default 1440 minutes,
|
|
1505
|
-
// a full day). Read it first so the agent knows how long an
|
|
1506
|
-
// unstopped test server will keep billing.
|
|
1507
|
-
const version = await client.getAppVersion(args.application, args.version);
|
|
1508
1528
|
if (version.docker_tag !== undefined && badTag(version.docker_tag)) {
|
|
1509
1529
|
return fail(`Refused: version "${args.version}" uses docker_tag "${version.docker_tag}". ${TAG_FIX} ` +
|
|
1510
1530
|
'Then create a new version with edgegap_create_app_version and deploy that.');
|
|
@@ -1534,32 +1554,49 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
1534
1554
|
'using edgegap_stop_deployment, then deploy again.');
|
|
1535
1555
|
}
|
|
1536
1556
|
}
|
|
1537
|
-
|
|
1557
|
+
if (args.dry_run) {
|
|
1558
|
+
const dry = client.dryRun();
|
|
1559
|
+
await send(dry.client);
|
|
1560
|
+
const stop = autoStop(version.max_duration);
|
|
1561
|
+
return dryRunResult(dry.requests, [
|
|
1562
|
+
`Tagged "${AGENT_TAG}" automatically.`,
|
|
1563
|
+
...(longRunning ? ['long_running: allowed by allow_long_running.'] : []),
|
|
1564
|
+
typeof stop.auto_stop_after_minutes === 'number'
|
|
1565
|
+
? `Auto-stop: after ${stop.auto_stop_after_minutes} minutes (the version's max_duration).`
|
|
1566
|
+
: `Auto-stop: ${stop.auto_stop}.`,
|
|
1567
|
+
]);
|
|
1568
|
+
}
|
|
1569
|
+
// A refused deploy can still leave a deployment behind (a 422 "not
|
|
1570
|
+
// enough space" did, 2026-10-28) with no request_id in the error.
|
|
1571
|
+
// The lookup looks back a minute for clock skew, which also catches
|
|
1572
|
+
// deploys of the same version made just before this one (live,
|
|
1573
|
+
// 2026-10-28), so note those first and leave them out afterwards.
|
|
1538
1574
|
const sentAt = new Date(Date.now() - 60_000).toISOString();
|
|
1575
|
+
const recentQuery = {
|
|
1576
|
+
query: JSON.stringify({
|
|
1577
|
+
filters: [
|
|
1578
|
+
{ field: 'application', operator: 'eq', value: args.application },
|
|
1579
|
+
{ field: 'version', operator: 'eq', value: args.version },
|
|
1580
|
+
{ field: 'tags', operator: 'in', value: [AGENT_TAG] },
|
|
1581
|
+
{ field: 'created_at', operator: 'gte', value: sentAt },
|
|
1582
|
+
],
|
|
1583
|
+
}),
|
|
1584
|
+
limit: 100,
|
|
1585
|
+
};
|
|
1586
|
+
const recentIds = () => client
|
|
1587
|
+
.listDeployments(recentQuery)
|
|
1588
|
+
.then((r) => (r.data ?? []).map((d) => d.request_id).filter(Boolean))
|
|
1589
|
+
.catch(() => []);
|
|
1590
|
+
const before = new Set(await recentIds());
|
|
1591
|
+
deploysSent++;
|
|
1539
1592
|
let res;
|
|
1540
1593
|
try {
|
|
1541
1594
|
res = await send(client);
|
|
1542
1595
|
}
|
|
1543
1596
|
catch (err) {
|
|
1544
|
-
// A refused deploy can still leave a deployment behind (a 422
|
|
1545
|
-
// "not enough space" did, 2026-10-28) with no request_id in the
|
|
1546
|
-
// error. Name it so the agent can stop it.
|
|
1547
1597
|
if (!(err instanceof EdgegapApiError))
|
|
1548
1598
|
throw err;
|
|
1549
|
-
const left = await
|
|
1550
|
-
.listDeployments({
|
|
1551
|
-
query: JSON.stringify({
|
|
1552
|
-
filters: [
|
|
1553
|
-
{ field: 'application', operator: 'eq', value: args.application },
|
|
1554
|
-
{ field: 'version', operator: 'eq', value: args.version },
|
|
1555
|
-
{ field: 'tags', operator: 'in', value: [AGENT_TAG] },
|
|
1556
|
-
{ field: 'created_at', operator: 'gte', value: sentAt },
|
|
1557
|
-
],
|
|
1558
|
-
}),
|
|
1559
|
-
limit: 10,
|
|
1560
|
-
})
|
|
1561
|
-
.then((r) => (r.data ?? []).map((d) => d.request_id).filter(Boolean))
|
|
1562
|
-
.catch(() => []);
|
|
1599
|
+
const left = (await recentIds()).filter((id) => !before.has(id));
|
|
1563
1600
|
if (left.length === 0)
|
|
1564
1601
|
throw err;
|
|
1565
1602
|
throw new EdgegapApiError(err.status, `${err.apiMessage}\nThe API still created ${left.length === 1 ? 'a deployment' : 'deployments'} for this ` +
|
|
@@ -2583,7 +2620,11 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
2583
2620
|
inputSchema: {
|
|
2584
2621
|
endpoint_storage: z.string().min(1).describe('Endpoint Storage name, from edgegap_list_endpoint_storage.'),
|
|
2585
2622
|
name: z.string().min(1).describe('Name for the profile, e.g. "maps".'),
|
|
2586
|
-
source: z
|
|
2623
|
+
source: z
|
|
2624
|
+
.string()
|
|
2625
|
+
.min(1)
|
|
2626
|
+
.describe('Path in the bucket, starting with "/" and without a trailing "/", e.g. "/maps" or "/config/server.json". ' +
|
|
2627
|
+
'Letters, digits, "_", "-", "+" and "." only.'),
|
|
2587
2628
|
source_type: z.enum(['File', 'Folder']).describe('Whether source is a file or a folder.'),
|
|
2588
2629
|
destination: z.string().min(1).describe('Absolute path in the container, e.g. "/data/maps".'),
|
|
2589
2630
|
dry_run: dryRunParam,
|
|
@@ -2592,6 +2633,14 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
2592
2633
|
}, async (args) => guard(auth, async () => {
|
|
2593
2634
|
if (!args.destination.startsWith('/'))
|
|
2594
2635
|
return fail('destination must be an absolute container path, e.g. "/data/maps".');
|
|
2636
|
+
// The API's pattern is ^((\/{1}[A-z0-9-+.]+)*)*$ (live, 2026-10-28): "maps/" is refused.
|
|
2637
|
+
const bucketPath = /^(\/[A-Za-z0-9_+.-]+)+$/;
|
|
2638
|
+
if (!bucketPath.test(args.source)) {
|
|
2639
|
+
const suggestion = `/${args.source.split('/').filter(Boolean).join('/')}`;
|
|
2640
|
+
return fail(`source "${args.source.slice(0, 80)}" is not a bucket path Edgegap accepts: start it with "/", drop any ` +
|
|
2641
|
+
`trailing "/", and use only letters, digits, "_", "-", "+" and "." in each part` +
|
|
2642
|
+
(bucketPath.test(suggestion) ? `, e.g. "${suggestion}".` : '.'));
|
|
2643
|
+
}
|
|
2595
2644
|
const body = { name: args.name, source: args.source, source_type: args.source_type, destination: args.destination };
|
|
2596
2645
|
if (args.dry_run) {
|
|
2597
2646
|
const dry = client.dryRun();
|
|
@@ -2635,6 +2684,72 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
2635
2684
|
linked: !args.unlink,
|
|
2636
2685
|
});
|
|
2637
2686
|
}, 'the Endpoint Storage, pull profile, application or version does not exist. Check them with edgegap_list_endpoint_storage and edgegap_list_app_versions.'));
|
|
2687
|
+
tool('edgegap_delete_pull_profile', {
|
|
2688
|
+
title: 'Delete a pull profile',
|
|
2689
|
+
description: 'Delete one pull profile from an Endpoint Storage, to clean up a test profile. Exactly one exact name. ' +
|
|
2690
|
+
'Every version linked to it stops getting its files at boot (the API cannot list those links, so ask ' +
|
|
2691
|
+
'the developer when the profile is not one this conversation created). The bucket and its files are not ' +
|
|
2692
|
+
'touched. Cannot be undone.',
|
|
2693
|
+
inputSchema: {
|
|
2694
|
+
endpoint_storage: z.string().min(1).describe('Endpoint Storage name, from edgegap_list_endpoint_storage.'),
|
|
2695
|
+
pull_profile: z.string().min(1).describe('The exact pull profile name to delete.'),
|
|
2696
|
+
dry_run: dryRunParam,
|
|
2697
|
+
},
|
|
2698
|
+
annotations: { destructiveHint: true, idempotentHint: true, openWorldHint: true },
|
|
2699
|
+
}, async ({ endpoint_storage, pull_profile, dry_run }) => guard(auth, async () => {
|
|
2700
|
+
const badName = exactName(endpoint_storage, 'Endpoint Storage') ?? exactName(pull_profile, 'pull profile');
|
|
2701
|
+
if (badName)
|
|
2702
|
+
return badName;
|
|
2703
|
+
if (dry_run) {
|
|
2704
|
+
const dry = client.dryRun();
|
|
2705
|
+
await dry.client.deletePullProfile(endpoint_storage, pull_profile);
|
|
2706
|
+
return dryRunResult(dry.requests);
|
|
2707
|
+
}
|
|
2708
|
+
await client.deletePullProfile(endpoint_storage, pull_profile);
|
|
2709
|
+
return ok({ endpoint_storage, deleted_pull_profile: pull_profile, bucket_kept: 'The bucket and its files were not touched.' });
|
|
2710
|
+
}, `no pull profile "${pull_profile}" under Endpoint Storage "${endpoint_storage}". List them with edgegap_list_endpoint_storage.`));
|
|
2711
|
+
tool('edgegap_delete_endpoint_storage', {
|
|
2712
|
+
title: 'Delete an Endpoint Storage',
|
|
2713
|
+
description: 'Delete one Endpoint Storage, to clean up a test one. Exactly one exact name; refused when it still has ' +
|
|
2714
|
+
'more pull profiles than max_pull_profiles (default 0: delete them first with edgegap_delete_pull_profile, ' +
|
|
2715
|
+
'or raise max_pull_profiles after the developer agreed). Versions that export logs to it stop doing so, ' +
|
|
2716
|
+
'so confirm with the developer when the storage is not one this conversation created. The bucket and the ' +
|
|
2717
|
+
'logs already in it are not touched. Cannot be undone.',
|
|
2718
|
+
inputSchema: {
|
|
2719
|
+
endpoint_storage: z.string().min(1).describe('The exact Endpoint Storage name to delete.'),
|
|
2720
|
+
max_pull_profiles: z
|
|
2721
|
+
.number()
|
|
2722
|
+
.int()
|
|
2723
|
+
.min(0)
|
|
2724
|
+
.optional()
|
|
2725
|
+
.describe('Delete only if it has at most this many pull profiles, which go with it. Default 0.'),
|
|
2726
|
+
dry_run: dryRunParam,
|
|
2727
|
+
},
|
|
2728
|
+
annotations: { destructiveHint: true, idempotentHint: true, openWorldHint: true },
|
|
2729
|
+
}, async ({ endpoint_storage, max_pull_profiles, dry_run }) => guard(auth, async () => {
|
|
2730
|
+
const badName = exactName(endpoint_storage, 'Endpoint Storage');
|
|
2731
|
+
if (badName)
|
|
2732
|
+
return badName;
|
|
2733
|
+
if (dry_run) {
|
|
2734
|
+
const dry = client.dryRun();
|
|
2735
|
+
await dry.client.deleteEndpointStorage(endpoint_storage);
|
|
2736
|
+
return dryRunResult(dry.requests, ['A real call first checks how many pull profiles it has.']);
|
|
2737
|
+
}
|
|
2738
|
+
const profiles = ((await client.listPullProfiles(endpoint_storage)).pull_profiles ?? []).map((p) => p.name);
|
|
2739
|
+
const limit = max_pull_profiles ?? 0;
|
|
2740
|
+
if (profiles.length > limit) {
|
|
2741
|
+
return fail(`Refused: Endpoint Storage "${endpoint_storage}" has ${profiles.length} pull profile` +
|
|
2742
|
+
`${profiles.length === 1 ? '' : 's'} (${profiles.slice(0, 10).join(', ')}${profiles.length > 10 ? ', …' : ''}), ` +
|
|
2743
|
+
`more than max_pull_profiles (${limit}). Nothing was deleted. Delete them with edgegap_delete_pull_profile, ` +
|
|
2744
|
+
`or pass max_pull_profiles ${profiles.length} once the developer agreed to delete them all.`);
|
|
2745
|
+
}
|
|
2746
|
+
await client.deleteEndpointStorage(endpoint_storage);
|
|
2747
|
+
return ok({
|
|
2748
|
+
deleted_endpoint_storage: endpoint_storage,
|
|
2749
|
+
deleted_pull_profiles: profiles,
|
|
2750
|
+
bucket_kept: 'The bucket and the logs already in it were not touched.',
|
|
2751
|
+
});
|
|
2752
|
+
}, `no Endpoint Storage named "${endpoint_storage}". List them with edgegap_list_endpoint_storage.`));
|
|
2638
2753
|
}
|
|
2639
2754
|
// ================================================== peer-to-peer relays ====
|
|
2640
2755
|
// --------------------------------------------------------------- 14 ----
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edgegap/mcp",
|
|
3
3
|
"mcpName": "dev.edgegap/mcp",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.15.0",
|
|
5
5
|
"description": "Check, push, and deploy game servers on Edgegap from your coding agent, with relays for P2P games. Runs locally; your API token never leaves your machine.",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prebuild": "rm -rf dist",
|