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