@edgegap/mcp 0.6.3 → 0.7.1

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/dist/tools.js CHANGED
@@ -63,9 +63,10 @@ export function serverInstructions(mode) {
63
63
  `Godot 4 with a Godot server: ${skillUri('edgegap-godot', 'SKILL.md')}, ` +
64
64
  `Colyseus server: ${skillUri('edgegap-colyseus', 'SKILL.md')}, ` +
65
65
  `Nakama backend: ${skillUri('edgegap-nakama', 'SKILL.md')}, ` +
66
+ `PlayFab Matchmaking: ${skillUri('edgegap-playfab', 'SKILL.md')}, ` +
66
67
  `browser game built with Manus: ${skillUri('edgegap-manus', 'SKILL.md')}). ` +
67
68
  'If your client cannot read MCP resources, call edgegap_get_skill with the skill name ' +
68
- '(edgegap, edgegap-unity, edgegap-ngo, edgegap-fishnet, edgegap-purrnet, edgegap-fusion, edgegap-fusion-simplefps, edgegap-unreal, edgegap-eos-voice, edgegap-godot, edgegap-colyseus, edgegap-nakama or edgegap-manus) instead. ' +
69
+ '(edgegap, edgegap-unity, edgegap-ngo, edgegap-fishnet, edgegap-purrnet, edgegap-fusion, edgegap-fusion-simplefps, edgegap-unreal, edgegap-eos-voice, edgegap-godot, edgegap-colyseus, edgegap-nakama, edgegap-playfab or edgegap-manus) instead. ' +
69
70
  'These Edgegap skills hold the tested workflow, templates and known pitfalls; follow them over general knowledge. ' +
70
71
  'edgegap_list_skills lists all of them.\n\n' +
71
72
  'Host multiplayer games on Edgegap. The recommended setup is an authoritative dedicated ' +
@@ -109,8 +110,32 @@ const TERMINAL_OK = ['READY', 'STATUS_READY'];
109
110
  const TERMINAL_BAD = ['ERROR', 'STATUS_ERROR', 'TERMINATED', 'STATUS_TERMINATED'];
110
111
  function ok(payload, notice) {
111
112
  const body = typeof payload === 'string' ? payload : JSON.stringify(payload, null, 2);
113
+ const structured = payload !== null && typeof payload === 'object' && !Array.isArray(payload)
114
+ ? JSON.parse(body)
115
+ : undefined;
112
116
  return {
113
117
  content: [{ type: 'text', text: notice ? `${body}\n\nNOTE: ${notice}` : body }],
118
+ ...(structured ? { structuredContent: structured } : {}),
119
+ };
120
+ }
121
+ /**
122
+ * Strips the API token from a whole result, success or failure. Errors were
123
+ * already redacted at the source; this covers anything the API echoes back in
124
+ * a successful response, and any text a tool builds from it.
125
+ */
126
+ function scrubToken(result, token) {
127
+ if (!token || token.length < 8)
128
+ return result;
129
+ const needles = [token, token.replace(/-/g, '')].filter((n, i, all) => n.length >= 8 && all.indexOf(n) === i);
130
+ const clean = (text) => needles.reduce((t, n) => redact(t, n), text);
131
+ const hit = (text) => needles.some((n) => text.includes(n));
132
+ const structuredText = result.structuredContent ? JSON.stringify(result.structuredContent) : '';
133
+ if (!result.content.some((c) => hit(c.text)) && !hit(structuredText))
134
+ return result;
135
+ return {
136
+ ...result,
137
+ content: result.content.map((c) => ({ ...c, text: clean(c.text) })),
138
+ ...(result.structuredContent ? { structuredContent: JSON.parse(clean(structuredText)) } : {}),
114
139
  };
115
140
  }
116
141
  function fail(message) {
@@ -242,6 +267,52 @@ function compactDeployment(d) {
242
267
  ports,
243
268
  };
244
269
  }
270
+ /** The version fields every version tool shows. Never the registry token. */
271
+ function compactVersion(v) {
272
+ return {
273
+ name: v.name,
274
+ active: v.is_active,
275
+ image: [v.docker_repository, v.docker_image, v.docker_tag].filter(Boolean).join('/'),
276
+ // Whether a login is set, never the login itself: the API returns the
277
+ // registry token in version responses.
278
+ registry_credentials_set: Boolean(v.private_username && v.private_token),
279
+ cpu_units: v.req_cpu,
280
+ memory_mb: v.req_memory,
281
+ max_duration_minutes: v.max_duration,
282
+ ports: v.ports?.map((p) => ({
283
+ name: p.name,
284
+ port: p.port,
285
+ protocol: p.protocol,
286
+ tls_upgrade: p.tls_upgrade ?? false,
287
+ })),
288
+ };
289
+ }
290
+ /** Reduces "registry.edgegap.com/<project>/img:tag" to the image path the
291
+ * registry endpoints take. The project is stripped later only on a 404,
292
+ * because nested image names are valid. */
293
+ function imageNameOnly(input) {
294
+ const parts = input.trim().replace(/@sha256:.*$/, '').split('/');
295
+ if (parts.length > 1 && /[.:]/.test(parts[0]))
296
+ parts.shift();
297
+ parts[parts.length - 1] = parts[parts.length - 1].replace(/:[^:]*$/, '');
298
+ return parts.join('/');
299
+ }
300
+ /** Latest, average and peak of one metrics series, plus its labels. */
301
+ function summarizeSeries(series) {
302
+ const values = (series?.datasets ?? []).filter((x) => typeof x === 'number' && Number.isFinite(x));
303
+ if (values.length === 0)
304
+ return undefined;
305
+ const round = (x) => Math.round(x * 100) / 100;
306
+ return {
307
+ latest: round(values[values.length - 1]),
308
+ average: round(values.reduce((a, b) => a + b, 0) / values.length),
309
+ peak: round(Math.max(...values)),
310
+ samples: values.length,
311
+ labels: series?.labels?.length ? [...new Set(series.labels)].slice(0, 5) : undefined,
312
+ from: series?.timestamps?.[0],
313
+ to: series?.timestamps?.[series.timestamps.length - 1],
314
+ };
315
+ }
245
316
  const userSchema = z
246
317
  .object({
247
318
  ip_addresses: z
@@ -366,7 +437,8 @@ export function registerTools(server, client, config, auth) {
366
437
  // Every result names the API host it came from, first, so a session pointed
367
438
  // at a custom EDGEGAP_BASE_URL can never be mistaken for production.
368
439
  const label = hostLabel(config);
369
- const tool = ((name, def, cb) => server.registerTool(name, def, (async (...a) => withHost(await cb(...a), label))));
440
+ // ...and never carries the API token, whatever the API echoed back.
441
+ const tool = ((name, def, cb) => server.registerTool(name, def, (async (...a) => withHost(scrubToken(await cb(...a), auth.current), label))));
370
442
  // ---------------------------------------------------------------- 0 ----
371
443
  // No token, no network: describes this server's own configuration, so an
372
444
  // agent can check where it is pointed and what is allowed before acting.
@@ -404,7 +476,7 @@ export function registerTools(server, client, config, auth) {
404
476
  forced_deploy_tag: AGENT_TAG,
405
477
  guardrails: {
406
478
  dry_run: mutating
407
- ? 'deploy, stop_deployment, create_app, create_app_version, create/authorize/delete relay'
479
+ ? 'deploy, stop_deployment, create_app, update_app, create_app_version, update_app_version, delete_registry_tag, create/authorize/revoke/delete relay'
408
480
  : 'n/a: read-only, no write tools are registered',
409
481
  token_in_container: 'deploys and versions are refused if the API token appears in an env var, tag or webhook URL',
410
482
  image_tags: 'versions on "latest", an empty or malformed tag, or a docker_image holding a registry or tag are refused; so is deploying a version on "latest"',
@@ -472,6 +544,31 @@ export function registerTools(server, client, config, auth) {
472
544
  });
473
545
  }));
474
546
  }
547
+ // --------------------------------------------------------------- 2b ----
548
+ if (mutating) {
549
+ tool('edgegap_update_app', {
550
+ title: 'Turn an application on or off',
551
+ description: 'Set whether an application accepts new deployments. Turning it off stops new ' +
552
+ 'deployments of every version under it; running deployments keep running. Use it to ' +
553
+ 'pause an application without deleting anything.',
554
+ inputSchema: {
555
+ application: z.string().describe('Application name.'),
556
+ is_active: z.boolean().describe('false blocks new deployments; true allows them again.'),
557
+ dry_run: dryRunParam,
558
+ },
559
+ annotations: { destructiveHint: false, idempotentHint: true, openWorldHint: true },
560
+ }, async ({ application, is_active, dry_run }) => guarded(auth, NOT_FOUND.app, async () => {
561
+ assertAppAllowed(config, application);
562
+ const body = { is_active };
563
+ if (dry_run) {
564
+ const dry = client.dryRun();
565
+ await dry.client.updateApp(application, body);
566
+ return dryRunResult(dry.requests);
567
+ }
568
+ const res = await client.updateApp(application, body);
569
+ return ok({ application: res.name ?? application, active: res.is_active ?? is_active });
570
+ }));
571
+ }
475
572
  // ---------------------------------------------------------------- 3 ----
476
573
  tool('edgegap_list_app_versions', {
477
574
  title: 'List versions of an application',
@@ -489,25 +586,36 @@ export function registerTools(server, client, config, auth) {
489
586
  // limits what the agent can create and deploy into, as documented.
490
587
  guarded(auth, NOT_FOUND.app, async () => {
491
588
  const res = await client.listAppVersions(application);
492
- const versions = (res.versions ?? []).map((v) => ({
493
- name: v.name,
494
- active: v.is_active,
495
- image: [v.docker_repository, v.docker_image, v.docker_tag].filter(Boolean).join('/'),
496
- // Whether a login is set, never the login itself: the API returns
497
- // the registry token in this response.
498
- registry_credentials_set: Boolean(v.private_username && v.private_token),
499
- cpu_units: v.req_cpu,
500
- memory_mb: v.req_memory,
501
- max_duration_minutes: v.max_duration,
502
- ports: v.ports?.map((p) => ({
503
- name: p.name,
504
- port: p.port,
505
- protocol: p.protocol,
506
- tls_upgrade: p.tls_upgrade ?? false,
507
- })),
508
- }));
589
+ const versions = (res.versions ?? []).map(compactVersion);
509
590
  return ok({ application, ...pageInfo(res.total_count, versions.length, 1), versions });
510
591
  }));
592
+ // --------------------------------------------------------------- 3b ----
593
+ tool('edgegap_get_app_version', {
594
+ title: 'Get one application version',
595
+ description: 'Read one version in full: image, resources, ports, max_duration, whether image caching ' +
596
+ '(force_cache) and verify_image are on, restart policy, and the names of its env vars ' +
597
+ '(values are never shown). Use it before edgegap_update_app_version or edgegap_deploy ' +
598
+ 'to check what a version will do.',
599
+ inputSchema: {
600
+ application: z.string().describe('Application name.'),
601
+ version: z.string().describe('Version name, as listed by edgegap_list_app_versions.'),
602
+ },
603
+ annotations: { readOnlyHint: true, openWorldHint: true },
604
+ }, async ({ application, version }) => guarded(auth, NOT_FOUND.app, async () => {
605
+ const v = await client.getAppVersion(application, version);
606
+ return ok({
607
+ application,
608
+ ...compactVersion(v),
609
+ force_cache: v.force_cache,
610
+ caching_percent: v.caching_percent,
611
+ verify_image: v.verify_image,
612
+ restart_policy: v.restart_policy,
613
+ termination_grace_period_seconds: v.termination_grace_period_seconds,
614
+ time_to_deploy_seconds: v.time_to_deploy,
615
+ env: v.envs?.map((e) => ({ key: e.key, hidden: e.is_hidden ?? false })),
616
+ ...autoStop(v.max_duration),
617
+ });
618
+ }));
511
619
  // ---------------------------------------------------------------- 4 ----
512
620
  if (mutating) {
513
621
  tool('edgegap_create_app_version', {
@@ -668,6 +776,157 @@ export function registerTools(server, client, config, auth) {
668
776
  });
669
777
  }));
670
778
  }
779
+ // --------------------------------------------------------------- 4b ----
780
+ if (mutating) {
781
+ tool('edgegap_update_app_version', {
782
+ title: 'Update an application version',
783
+ description: 'Change settings on an existing version instead of creating a new one: point it at a new ' +
784
+ 'image tag, turn it on or off, change max_duration, set the registry login, turn on image ' +
785
+ 'caching (force_cache: Edgegap pre-loads the image so deployments start faster), or set ' +
786
+ 'the shutdown grace period. Only the fields you pass change. Deployments already running ' +
787
+ 'keep their old settings; new deployments get the new ones. Same refusals as ' +
788
+ 'edgegap_create_app_version: "latest" or empty tags, a docker_image holding a host or ' +
789
+ 'tag, and the API token in the registry login. Resources, ports and env vars cannot be ' +
790
+ 'changed here; create a new version for those.',
791
+ inputSchema: {
792
+ application: z.string().describe('Application name.'),
793
+ version: z.string().describe('Version name to change.'),
794
+ is_active: z.boolean().optional().describe('false blocks new deployments of this version.'),
795
+ docker_repository: z.string().optional().describe('Registry host, e.g. "registry.edgegap.com".'),
796
+ docker_image: z.string().optional().describe('Image path, e.g. "my-org-abc123/my-game-server".'),
797
+ docker_tag: z.string().optional().describe('New image tag: a build ID, commit SHA or timestamp.'),
798
+ registry_username: z.string().optional(),
799
+ registry_token: z.string().optional().describe('Registry password or token. Never echoed back.'),
800
+ max_duration_minutes: z
801
+ .number()
802
+ .int()
803
+ .optional()
804
+ .describe('Auto-stop after this many minutes. Capped by EDGEGAP_MAX_DURATION_MINUTES.'),
805
+ force_cache: z.boolean().optional().describe('Pre-load the image on Edgegap so deployments start faster.'),
806
+ verify_image: z.boolean().optional().describe('Check Edgegap can pull the image when saving.'),
807
+ termination_grace_period_seconds: z
808
+ .number()
809
+ .int()
810
+ .min(0)
811
+ .max(3600)
812
+ .optional()
813
+ .describe('Seconds between SIGTERM and SIGKILL when a deployment stops.'),
814
+ dry_run: dryRunParam,
815
+ },
816
+ annotations: { destructiveHint: false, idempotentHint: true, openWorldHint: true },
817
+ }, async (args) => guarded(auth, NOT_FOUND.app, async () => {
818
+ assertAppAllowed(config, args.application);
819
+ const leak = await tokenLeak(auth, args.dry_run, [
820
+ ['registry_username', args.registry_username],
821
+ ['registry_token', args.registry_token],
822
+ ]);
823
+ if (leak)
824
+ return leak;
825
+ if (args.docker_tag !== undefined) {
826
+ const tagProblem = badTag(args.docker_tag);
827
+ if (tagProblem)
828
+ return fail(`Refused: ${tagProblem}. ${TAG_FIX}`);
829
+ }
830
+ if (args.docker_image !== undefined) {
831
+ const imageProblem = badImage(args.docker_repository ?? '', args.docker_image);
832
+ if (imageProblem)
833
+ return fail(`Refused: ${imageProblem}`);
834
+ }
835
+ const capped = args.max_duration_minutes === undefined
836
+ ? undefined
837
+ : Math.min(args.max_duration_minutes, config.maxDurationCeiling);
838
+ const body = {
839
+ is_active: args.is_active,
840
+ docker_repository: args.docker_repository,
841
+ docker_image: args.docker_image,
842
+ docker_tag: args.docker_tag,
843
+ private_username: args.registry_username,
844
+ private_token: args.registry_token,
845
+ max_duration: capped,
846
+ force_cache: args.force_cache,
847
+ verify_image: args.verify_image,
848
+ termination_grace_period_seconds: args.termination_grace_period_seconds,
849
+ };
850
+ for (const k of Object.keys(body))
851
+ if (body[k] === undefined)
852
+ delete body[k];
853
+ if (Object.keys(body).length === 0) {
854
+ return fail('Nothing to change: pass at least one field to update.');
855
+ }
856
+ const notes = capped !== undefined && capped < (args.max_duration_minutes ?? 0)
857
+ ? [`max_duration capped to ${capped} minutes by EDGEGAP_MAX_DURATION_MINUTES.`]
858
+ : [];
859
+ if (args.dry_run) {
860
+ const dry = client.dryRun();
861
+ await dry.client.updateAppVersion(args.application, args.version, body);
862
+ return dryRunResult(dry.requests, notes);
863
+ }
864
+ await client.updateAppVersion(args.application, args.version, body);
865
+ return ok({
866
+ updated: `${args.application}/${args.version}`,
867
+ changed: Object.keys(body).map((k) => (k === 'private_token' ? 'registry_token' : k === 'private_username' ? 'registry_username' : k)),
868
+ notes: notes.length ? notes : undefined,
869
+ next_step: 'Running deployments keep the old settings. Check the result with edgegap_get_app_version.',
870
+ });
871
+ }));
872
+ }
873
+ // --------------------------------------------------------------- 5b ----
874
+ tool('edgegap_list_locations', {
875
+ title: 'List where servers can run',
876
+ description: 'List the cities Edgegap can deploy to. Pass application and version to see only the ' +
877
+ 'locations with capacity for that version right now. Use it to pick geo_coordinates for ' +
878
+ 'edgegap_deploy when you have no player IPs, or to tell a developer where their players ' +
879
+ 'can be served from. For the ping beacons game clients use to measure latency, see ' +
880
+ 'edgegap_list_ping_beacons.',
881
+ inputSchema: {
882
+ application: z.string().optional().describe('With version: only locations with capacity for it now.'),
883
+ version: z.string().optional(),
884
+ page: z.number().int().min(1).optional(),
885
+ limit: z.number().int().min(1).max(200).optional().describe('Default 100.'),
886
+ },
887
+ annotations: { readOnlyHint: true, openWorldHint: true },
888
+ }, async ({ application, version, page, limit }) => guarded(auth, NOT_FOUND.app, async () => {
889
+ if ((application === undefined) !== (version === undefined)) {
890
+ return fail('Pass both application and version to filter by capacity, or neither for every location.');
891
+ }
892
+ const res = await client.listLocations({ app: application, version, page, limit: limit ?? 100 });
893
+ const locations = (res.locations ?? []).map((l) => ({
894
+ city: l.city,
895
+ region: l.administrative_division || undefined,
896
+ country: l.country,
897
+ continent: l.continent,
898
+ latitude: l.latitude,
899
+ longitude: l.longitude,
900
+ }));
901
+ return ok({
902
+ filtered_for: application ? `${application}/${version} (capacity right now)` : undefined,
903
+ ...pageInfo(res.total_count, locations.length, page ?? 1),
904
+ locations,
905
+ messages: res.messages?.length ? res.messages : undefined,
906
+ });
907
+ }));
908
+ tool('edgegap_list_ping_beacons', {
909
+ title: 'List ping beacons',
910
+ description: 'List Edgegap\'s ping beacons: one host per region that a game client can ping (UDP or ' +
911
+ 'TCP) to measure its latency before matchmaking. The matchmaker\'s latency rules use these ' +
912
+ 'measurements. Read-only; the game client does the pinging, not this tool.',
913
+ inputSchema: {
914
+ page: z.number().int().min(1).optional(),
915
+ limit: z.number().int().min(1).max(200).optional().describe('Default 100.'),
916
+ },
917
+ annotations: { readOnlyHint: true, openWorldHint: true },
918
+ }, async ({ page, limit }) => guard(auth, async () => {
919
+ const res = await client.listBeacons({ page, limit: limit ?? 100 });
920
+ const beacons = (res.locations ?? []).map((b) => ({
921
+ host: b.fqdn ?? b.host,
922
+ udp_port: b.udp_port,
923
+ tcp_port: b.tcp_port,
924
+ city: b.location?.city,
925
+ country: b.location?.country,
926
+ continent: b.location?.continent,
927
+ }));
928
+ return ok({ total: res.count ?? beacons.length, beacons });
929
+ }));
671
930
  // ---------------------------------------------------------------- 5 ----
672
931
  if (mutating) {
673
932
  tool('edgegap_deploy', {
@@ -695,8 +954,13 @@ export function registerTools(server, client, config, auth) {
695
954
  .array(z.string().min(1).max(40))
696
955
  .optional()
697
956
  .describe(`Extra tags for filtering later, e.g. ["agent-test"]. "${AGENT_TAG}" is always added.`),
698
- cpu_units: z.number().int().min(256).optional().describe('Override the version CPU.'),
699
- memory_mb: z.number().int().min(256).optional().describe('Override the version memory.'),
957
+ cpu_units: z
958
+ .number()
959
+ .int()
960
+ .min(256)
961
+ .optional()
962
+ .describe('Override the version CPU (with memory_mb). Not in the published v2 spec, so the API may ignore it; a version with the size you need is the reliable way.'),
963
+ memory_mb: z.number().int().min(256).optional().describe('Override the version memory (with cpu_units). Same caveat as cpu_units.'),
700
964
  dry_run: dryRunParam,
701
965
  },
702
966
  annotations: { destructiveHint: false, idempotentHint: false, openWorldHint: true },
@@ -773,6 +1037,13 @@ export function registerTools(server, client, config, auth) {
773
1037
  status: 'starting',
774
1038
  tags,
775
1039
  ...autoStop(version.max_duration),
1040
+ // "resources" is not in the published v2 deploy schema
1041
+ // (test/spec.mjs). Say so rather than promise the override.
1042
+ resources_note: body.resources
1043
+ ? 'cpu_units/memory_mb were sent, but the published v2 API does not document a per-deployment ' +
1044
+ 'override, so the deployment may run with the version\'s size. For a different size, create a ' +
1045
+ 'version with it.'
1046
+ : undefined,
776
1047
  next_step: `Call edgegap_wait_for_deployment with request_id ${res.request_id}.`,
777
1048
  });
778
1049
  }));
@@ -961,6 +1232,43 @@ export function registerTools(server, client, config, auth) {
961
1232
  storage_link: res.logs_link ?? undefined,
962
1233
  });
963
1234
  }));
1235
+ // --------------------------------------------------------------- 10b ----
1236
+ tool('edgegap_get_deployment_metrics', {
1237
+ title: 'Get CPU, memory and network use of a deployment',
1238
+ description: 'Summarise a deployment\'s resource use over time: CPU, CPU throttling, memory and network, ' +
1239
+ 'each as latest, average and peak, with the API\'s own labels. Use it to size a version ' +
1240
+ '(cpu_units, memory_mb) from a real match, or to check whether a crash was memory or CPU ' +
1241
+ 'starvation before redeploying. Defaults to the whole life of the deployment.',
1242
+ inputSchema: {
1243
+ request_id: z.string().describe('The request_id of the deployment.'),
1244
+ start_time: z.string().optional().describe('ISO 8601. Default: when the deployment started.'),
1245
+ end_time: z.string().optional().describe('ISO 8601. Default: now, or when it stopped.'),
1246
+ step: z.string().optional().describe('Averaging step, e.g. "30s" or "5m". Default: the API\'s.'),
1247
+ },
1248
+ annotations: { readOnlyHint: true, openWorldHint: true },
1249
+ }, async ({ request_id, start_time, end_time, step }) => guarded(auth, NOT_FOUND.deployment, async () => {
1250
+ const bad = checkRequestId(request_id);
1251
+ if (bad)
1252
+ return bad;
1253
+ const m = await client.getDeploymentMetrics(request_id, { start_time, end_time, steps: step });
1254
+ return ok({
1255
+ request_id,
1256
+ cpu: summarizeSeries(m.cpu),
1257
+ cpu_throttle_rate: summarizeSeries(m.cpu_throttle_rate),
1258
+ memory: summarizeSeries(m.mem),
1259
+ network_receive: summarizeSeries(m.network?.receive),
1260
+ network_transmit: summarizeSeries(m.network?.transmit),
1261
+ totals: m.total
1262
+ ? {
1263
+ received: summarizeSeries(m.total.receive_total)?.latest,
1264
+ transmitted: summarizeSeries(m.total.transmit_total)?.latest,
1265
+ disk_read: summarizeSeries(m.total.disk_read_total)?.latest,
1266
+ disk_written: summarizeSeries(m.total.disk_write_total)?.latest,
1267
+ }
1268
+ : undefined,
1269
+ note: 'Units are as the API labels them; values are averaged per step.',
1270
+ });
1271
+ }));
964
1272
  // ============================================= before the first deploy ====
965
1273
  // -------------------------------------------------------------- 11a ----
966
1274
  // Pure text generation: no token, no network, so it is always registered and
@@ -1227,11 +1535,7 @@ export function registerTools(server, client, config, auth) {
1227
1535
  }, async ({ image_name, page, limit }) => guard(auth, async () => {
1228
1536
  // Agents often pass the full reference they pushed. Reduce it to what
1229
1537
  // the API wants: no "registry.edgegap.com/" host, no ":tag".
1230
- const parts = image_name.replace(/@sha256:.*$/, '').split('/');
1231
- if (parts.length > 1 && /[.:]/.test(parts[0]))
1232
- parts.shift();
1233
- parts[parts.length - 1] = parts[parts.length - 1].replace(/:[^:]*$/, '');
1234
- let name = parts.join('/');
1538
+ let name = imageNameOnly(image_name);
1235
1539
  const query = { page, limit: limit ?? 20 };
1236
1540
  const notFound = (err) => err instanceof EdgegapApiError && err.status === 404;
1237
1541
  let res;
@@ -1277,6 +1581,64 @@ export function registerTools(server, client, config, auth) {
1277
1581
  tags,
1278
1582
  });
1279
1583
  }));
1584
+ // --------------------------------------------------------------- 13b ----
1585
+ if (mutating) {
1586
+ tool('edgegap_delete_registry_tag', {
1587
+ title: 'Delete one image tag from the Edgegap registry',
1588
+ description: 'Delete one tag, and the image it points to, from this organization\'s Edgegap container ' +
1589
+ 'registry, to clean up old builds. Takes exactly one image name and one exact tag; ' +
1590
+ 'wildcards, lists and "latest" are refused, and there is no bulk delete. A version that ' +
1591
+ 'still uses the tag can no longer start deployments, so check edgegap_list_app_versions ' +
1592
+ 'first. Cannot be undone.',
1593
+ inputSchema: {
1594
+ image_name: z.string().min(1).describe('The image name only, e.g. "my-game-server", as for edgegap_list_registry_tags.'),
1595
+ tag: z.string().describe('The exact tag to delete, e.g. "build-41".'),
1596
+ dry_run: dryRunParam,
1597
+ },
1598
+ annotations: { destructiveHint: true, idempotentHint: true, openWorldHint: true },
1599
+ }, async ({ image_name, tag, dry_run }) => guard(auth, async () => {
1600
+ let name = imageNameOnly(image_name);
1601
+ if (!/^[a-z0-9][a-z0-9._\/-]{0,254}$/.test(name)) {
1602
+ return fail(`"${image_name.slice(0, 80)}" is not a single image name. Pass one, e.g. "my-game-server".`);
1603
+ }
1604
+ if (badTag(tag) || tag.toLowerCase() === 'latest') {
1605
+ return fail(`"${tag.slice(0, 80)}" is not one exact tag. Pass a single tag as listed by edgegap_list_registry_tags; "latest" and wildcards are refused.`);
1606
+ }
1607
+ if (dry_run) {
1608
+ const dry = client.dryRun();
1609
+ await dry.client.deleteRegistryTag(name, tag);
1610
+ return dryRunResult(dry.requests, name !== image_name ? [`Looked up "${name}".`] : []);
1611
+ }
1612
+ const notFound = (err) => err instanceof EdgegapApiError && err.status === 404;
1613
+ try {
1614
+ let res;
1615
+ try {
1616
+ res = await client.deleteRegistryTag(name, tag);
1617
+ }
1618
+ catch (err) {
1619
+ // As in edgegap_list_registry_tags: "<project>/<image>" 404s, and
1620
+ // a 404 deleted nothing, so retry once without the project.
1621
+ if (!notFound(err) || !name.includes('/'))
1622
+ throw err;
1623
+ name = name.slice(name.indexOf('/') + 1);
1624
+ res = await client.deleteRegistryTag(name, tag);
1625
+ }
1626
+ return ok({
1627
+ image_name: name,
1628
+ deleted_tag: res.deleted_tag ?? tag,
1629
+ image_deleted: res.artifact?.artifact_deleted,
1630
+ freed_mb: res.artifact?.artifact_deleted ? res.artifact?.size_mb : undefined,
1631
+ tags_still_on_that_image: res.artifact?.remaining_tags?.length ? res.artifact.remaining_tags : undefined,
1632
+ });
1633
+ }
1634
+ catch (err) {
1635
+ if (notFound(err)) {
1636
+ return fail(`No tag "${tag}" on image "${name}" in this organization's registry. List tags with edgegap_list_registry_tags.`);
1637
+ }
1638
+ throw err;
1639
+ }
1640
+ }));
1641
+ }
1280
1642
  // ================================================== peer-to-peer relays ====
1281
1643
  // --------------------------------------------------------------- 14 ----
1282
1644
  if (mutating) {
@@ -1352,6 +1714,28 @@ export function registerTools(server, client, config, auth) {
1352
1714
  inputSchema: { session_id: z.string().describe('Returned by edgegap_create_relay_session.') },
1353
1715
  annotations: { readOnlyHint: true, openWorldHint: true },
1354
1716
  }, async ({ session_id }) => guarded(auth, NOT_FOUND.relay, async () => ok(compactRelay(await client.getRelaySession(session_id)))));
1717
+ // --------------------------------------------------------------- 15b ----
1718
+ tool('edgegap_list_relay_sessions', {
1719
+ title: 'List relay sessions',
1720
+ description: 'List this organization\'s active relay sessions: id, status, readiness and player count. ' +
1721
+ 'Relay sessions bill while open, so use this to find ones left over from earlier sessions ' +
1722
+ 'and delete them with edgegap_delete_relay_session. Authorization tokens are not listed; ' +
1723
+ 'read one session with edgegap_get_relay_session.',
1724
+ inputSchema: {},
1725
+ annotations: { readOnlyHint: true, openWorldHint: true },
1726
+ }, async () => guard(auth, async () => {
1727
+ const res = await client.listRelaySessions();
1728
+ const sessions = (res.sessions ?? []).map((r) => ({
1729
+ session_id: r.session_id,
1730
+ status: r.status,
1731
+ ready: r.ready,
1732
+ linked: r.linked,
1733
+ players: r.session_users?.length ?? 0,
1734
+ relay: r.relay?.host ?? r.relay?.ip ?? undefined,
1735
+ error: r.error || undefined,
1736
+ }));
1737
+ return ok({ ...pageInfo(res.total_count, sessions.length, 1), sessions });
1738
+ }));
1355
1739
  if (mutating) {
1356
1740
  // ------------------------------------------------------------- 16 ----
1357
1741
  tool('edgegap_authorize_relay_user', {
@@ -1378,6 +1762,31 @@ export function registerTools(server, client, config, auth) {
1378
1762
  session_authorization_token: res.authorization_token,
1379
1763
  });
1380
1764
  }));
1765
+ // ------------------------------------------------------------- 16b ----
1766
+ tool('edgegap_revoke_relay_user', {
1767
+ title: 'Remove a player from a relay session',
1768
+ description: 'Revoke one player\'s access to a relay session, by that player\'s authorization token ' +
1769
+ '(from edgegap_get_relay_session or edgegap_authorize_relay_user). The player loses the ' +
1770
+ 'relay connection; the session and the other players stay.',
1771
+ inputSchema: {
1772
+ session_id: z.string().describe('The relay session_id, e.g. "0724828881e2-S".'),
1773
+ user_authorization_token: z.number().int().describe('The player\'s authorization token, not the session\'s.'),
1774
+ dry_run: dryRunParam,
1775
+ },
1776
+ annotations: { destructiveHint: true, idempotentHint: true, openWorldHint: true },
1777
+ }, async ({ session_id, user_authorization_token, dry_run }) => guarded(auth, NOT_FOUND.relay, async () => {
1778
+ if (!SESSION_ID.test(session_id)) {
1779
+ return fail(`"${session_id.slice(0, 80)}" is not a single relay session_id. Pass exactly one, e.g. "0724828881e2-S".`);
1780
+ }
1781
+ const body = { session_id, authorization_token: user_authorization_token };
1782
+ if (dry_run) {
1783
+ const dry = client.dryRun();
1784
+ await dry.client.revokeRelayUser(body);
1785
+ return dryRunResult(dry.requests);
1786
+ }
1787
+ const res = await client.revokeRelayUser(body);
1788
+ return ok({ ...compactRelay(res), revoked: user_authorization_token });
1789
+ }));
1381
1790
  // ------------------------------------------------------------- 17 ----
1382
1791
  tool('edgegap_delete_relay_session', {
1383
1792
  title: 'Delete a relay session',
@@ -1525,7 +1934,7 @@ function registerSkills(server, tool) {
1525
1934
  'matching skill with edgegap_get_skill: edgegap-ngo for Unity with Netcode for GameObjects, edgegap-fishnet for Unity with FishNet, ' +
1526
1935
  'edgegap-purrnet for Unity with PurrNet, edgegap-fusion for Unity with Photon Fusion 2, edgegap-unity for other Unity projects, edgegap-unreal for Unreal Engine ' +
1527
1936
  '(edgegap-eos-voice to add voice chat to it), edgegap-fusion-simplefps for the Photon Simple FPS sample, edgegap-godot for Godot 4 with a Godot server, ' +
1528
- 'edgegap-colyseus for a Colyseus server, edgegap-nakama for a game with a Nakama backend, ' +
1937
+ 'edgegap-colyseus for a Colyseus server, edgegap-nakama for a game with a Nakama backend, edgegap-playfab for a game that keeps PlayFab Matchmaking, ' +
1529
1938
  'edgegap-manus for a browser game built with Manus, edgegap for any other engine or platform questions; it routes to the rest. No ' +
1530
1939
  'API call.',
1531
1940
  inputSchema: {},
@@ -1548,7 +1957,7 @@ function registerSkills(server, tool) {
1548
1957
  'a game project — edgegap-ngo for Unity with Netcode for GameObjects, edgegap-fishnet for Unity with FishNet, ' +
1549
1958
  'edgegap-purrnet for Unity with PurrNet, edgegap-fusion for Unity with Photon Fusion 2, edgegap-unity for other Unity projects, edgegap-unreal for Unreal Engine ' +
1550
1959
  '(edgegap-eos-voice for voice chat), edgegap-fusion-simplefps for the Photon Simple FPS sample, edgegap-godot for Godot 4 with a Godot server, ' +
1551
- 'edgegap-colyseus for a Colyseus server, edgegap-nakama for a Nakama backend, ' +
1960
+ 'edgegap-colyseus for a Colyseus server, edgegap-nakama for a Nakama backend, edgegap-playfab for PlayFab Matchmaking, ' +
1552
1961
  'edgegap-manus for a browser game built with Manus, edgegap otherwise — and fetch the references and templates it points to as you reach them. No API call.',
1553
1962
  inputSchema: {
1554
1963
  // A string, not an enum: clients cache tool schemas, and a cached enum from an older
package/dist/version.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * call, and by edgegap_context. Keep in step with package.json and server.json;
4
4
  * test/package.mjs fails the build when they disagree.
5
5
  */
6
- export const VERSION = '0.6.3';
6
+ export const VERSION = '0.7.1';
package/package.json CHANGED
@@ -1,14 +1,17 @@
1
1
  {
2
2
  "name": "@edgegap/mcp",
3
3
  "mcpName": "dev.edgegap/mcp",
4
- "version": "0.6.3",
4
+ "version": "0.7.1",
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",
8
8
  "build": "tsc && chmod +x dist/index.js dist/http.js",
9
9
  "typecheck": "tsc --noEmit",
10
10
  "typecheck:worker": "tsc -p worker/tsconfig.json --noEmit",
11
- "test": "node test/package.mjs && node test/skills.mjs && node test/smoke.mjs && node test/guards.mjs && node test/elicit.mjs && node test/newtools.mjs && node test/http.mjs",
11
+ "test": "node --test test/unit.test.mjs && node test/package.mjs && node test/skills.mjs && node test/smoke.mjs && node test/guards.mjs && node test/elicit.mjs && node test/newtools.mjs && node test/http.mjs && node test/spec.mjs && node test/snapshot.mjs",
12
+ "test:unit": "node --test test/unit.test.mjs",
13
+ "snapshot:update": "node test/snapshot.mjs --update",
14
+ "scan": "node scripts/scan-repo.mjs",
12
15
  "start:http": "node dist/index.js --http",
13
16
  "worker:dev": "wrangler dev --config worker/wrangler.jsonc --local --port 8787",
14
17
  "worker:check": "wrangler deploy --config worker/wrangler.jsonc --dry-run --outdir=.wrangler/dryrun",