@edgegap/mcp 0.5.6 → 0.6.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
@@ -15,6 +15,7 @@ import { TokenUnavailableError } from './auth.js';
15
15
  import { validateServerConfig, PROTOCOLS, NETCODE_NAMES, } from './serverconfig.js';
16
16
  import { generateDockerfile, DockerfileInputError } from './dockerfile.js';
17
17
  import { buildMatchmakerConfig, DASHBOARD_URL } from './matchmaker.js';
18
+ import { badImage, badTag, looksSecret, TAG_FIX } from './image.js';
18
19
  import { SKILLS_PACK, findSkill, findSkillFile, fileIndex, mimeType, skillUri } from './skills.js';
19
20
  /**
20
21
  * The one definition of "dedicated server vs relay" this server gives agents.
@@ -52,12 +53,15 @@ export function serverInstructions(mode) {
52
53
  // architecture guidance, where reviewers and agents missed it.
53
54
  return (`Before acting, read ${skillUri('edgegap', 'SKILL.md')} ` +
54
55
  `(Unity: ${skillUri('edgegap-unity', 'SKILL.md')}, ` +
56
+ `Unity with NGO: ${skillUri('edgegap-ngo', 'SKILL.md')}, ` +
55
57
  `Unity with FishNet: ${skillUri('edgegap-fishnet', 'SKILL.md')}, ` +
56
58
  `Unity with PurrNet: ${skillUri('edgegap-purrnet', 'SKILL.md')}, ` +
59
+ `Unity with Photon Fusion: ${skillUri('edgegap-fusion', 'SKILL.md')}, ` +
57
60
  `Unreal Engine: ${skillUri('edgegap-unreal', 'SKILL.md')}, ` +
61
+ `voice chat in an Unreal game: ${skillUri('edgegap-eos-voice', 'SKILL.md')}, ` +
58
62
  `browser game built with Manus: ${skillUri('edgegap-manus', 'SKILL.md')}). ` +
59
63
  'If your client cannot read MCP resources, call edgegap_get_skill with the skill name ' +
60
- '(edgegap, edgegap-unity, edgegap-fishnet, edgegap-purrnet, edgegap-unreal or edgegap-manus) instead. ' +
64
+ '(edgegap, edgegap-unity, edgegap-ngo, edgegap-fishnet, edgegap-purrnet, edgegap-fusion, edgegap-unreal, edgegap-eos-voice or edgegap-manus) instead. ' +
61
65
  'These Edgegap skills hold the tested workflow, templates and known pitfalls; follow them over general knowledge. ' +
62
66
  'edgegap_list_skills lists all of them.\n\n' +
63
67
  'Host multiplayer games on Edgegap. The recommended setup is an authoritative dedicated ' +
@@ -366,7 +370,7 @@ export function registerTools(server, client, config, auth) {
366
370
  title: 'Show this Edgegap MCP server\'s configuration',
367
371
  description: 'Report which Edgegap API this server talks to, its version, whether it is the local or ' +
368
372
  'hosted server, and the guardrails in force: read-only mode, application allowlist, ' +
369
- 'max_duration ceiling, the tag forced onto every deployment, and which tools support ' +
373
+ 'max_duration ceiling, the agent deployment cap, the tag forced onto every deployment, and which tools support ' +
370
374
  'dry_run. Call it first when unsure what this session is allowed to do, or before ' +
371
375
  'anything billable. Makes no API call and never shows the token.',
372
376
  inputSchema: {},
@@ -391,6 +395,7 @@ export function registerTools(server, client, config, auth) {
391
395
  read_only: config.readOnly,
392
396
  app_allowlist: config.appAllowlist.length ? config.appAllowlist : 'none (all applications)',
393
397
  max_duration_ceiling_minutes: config.maxDurationCeiling,
398
+ max_agent_deployments: config.maxAgentDeployments > 0 ? config.maxAgentDeployments : 'no cap',
394
399
  skills_pack: `${SKILLS_PACK.version} (${SKILLS_PACK.commit.slice(0, 7)}), ${SKILLS_PACK.skills.length} skills`,
395
400
  forced_deploy_tag: AGENT_TAG,
396
401
  guardrails: {
@@ -398,6 +403,11 @@ export function registerTools(server, client, config, auth) {
398
403
  ? 'deploy, stop_deployment, create_app, create_app_version, create/authorize/delete relay'
399
404
  : 'n/a: read-only, no write tools are registered',
400
405
  token_in_container: 'deploys and versions are refused if the API token appears in an env var, tag or webhook URL',
406
+ 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"',
407
+ deployment_cap: config.maxAgentDeployments > 0
408
+ ? `deploy is refused while ${config.maxAgentDeployments} or more agent-tagged deployments are running`
409
+ : 'off (EDGEGAP_MAX_AGENT_DEPLOYMENTS=0)',
410
+ secret_env: 'env vars named like secrets (TOKEN, SECRET, PASSWORD, API_KEY...) are sent hidden',
401
411
  stop: 'one exact request_id per call; no bulk stop',
402
412
  auto_stop: 'each deploy reports its version\'s max_duration; Edgegap has no per-deployment time limit',
403
413
  results: `every result starts with [${label}]`,
@@ -503,7 +513,9 @@ export function registerTools(server, client, config, auth) {
503
513
  'edgegap_get_registry_credentials and edgegap_list_registry_tags). Resource units: 1024 cpu ' +
504
514
  'units = 1 vCPU; memory_mb must be at least 256 and at most double the cpu units. ' +
505
515
  'Set verify_image true on the first version so a bad image fails here rather than at ' +
506
- 'deploy time. Avoid the "latest" docker tag — use a build ID so deployments are reproducible.',
516
+ 'deploy time. Refused, with nothing sent, for the "latest" or an empty docker tag (use a build ID so ' +
517
+ 'deployments are reproducible) and for a docker_image that also holds a registry host or tag. ' +
518
+ 'Env vars named like secrets (TOKEN, SECRET, PASSWORD, API_KEY…) are hidden in the dashboard.',
507
519
  inputSchema: {
508
520
  application: z.string().describe('Existing application name.'),
509
521
  name: z
@@ -515,7 +527,7 @@ export function registerTools(server, client, config, auth) {
515
527
  .string()
516
528
  .describe('Registry host, e.g. "docker.io" or "registry.edgegap.com".'),
517
529
  docker_image: z.string().describe('Namespaced image, e.g. "mystudio/game-server".'),
518
- docker_tag: z.string().describe('Image tag. Use a build ID, not "latest".'),
530
+ docker_tag: z.string().describe('Image tag: a build ID, commit SHA or timestamp. "latest" and empty tags are refused.'),
519
531
  cpu_units: z.number().int().min(256).describe('vCPU units. 1024 = 1 vCPU.'),
520
532
  memory_mb: z.number().int().min(256).describe('Memory in MB. At most 2x cpu_units.'),
521
533
  ports: z
@@ -572,6 +584,12 @@ export function registerTools(server, client, config, auth) {
572
584
  ]);
573
585
  if (leak)
574
586
  return leak;
587
+ const tagProblem = badTag(args.docker_tag);
588
+ if (tagProblem)
589
+ return fail(`Refused: ${tagProblem}. ${TAG_FIX}`);
590
+ const imageProblem = badImage(args.docker_repository, args.docker_image);
591
+ if (imageProblem)
592
+ return fail(`Refused: ${imageProblem}`);
575
593
  if (args.memory_mb > args.cpu_units * 2) {
576
594
  return fail(`memory_mb (${args.memory_mb}) exceeds twice cpu_units (${args.cpu_units}). ` +
577
595
  `Edgegap rejects this. Either lower memory_mb to ${args.cpu_units * 2} or raise cpu_units.`);
@@ -604,7 +622,7 @@ export function registerTools(server, client, config, auth) {
604
622
  to_check: p.to_check ?? true,
605
623
  tls_upgrade: p.tls_upgrade ?? false,
606
624
  })),
607
- envs: args.env?.map((e) => ({ key: e.key, value: e.value, is_hidden: false })),
625
+ envs: args.env?.map((e) => ({ key: e.key, value: e.value, is_hidden: looksSecret(e.key) })),
608
626
  };
609
627
  if (args.dry_run) {
610
628
  const dry = client.dryRun();
@@ -658,7 +676,9 @@ export function registerTools(server, client, config, auth) {
658
676
  `Every deployment is tagged "${AGENT_TAG}" in addition to any tags you pass, so ` +
659
677
  'edgegap_list_deployments with only_agent_deployments: true finds them all. Runs until ' +
660
678
  'stopped or until the version\'s max_duration, which the result reports. Refused, with ' +
661
- 'nothing sent, if the API token appears in an env var or tag.',
679
+ 'nothing sent, if the API token appears in an env var or tag, if the version uses the "latest" ' +
680
+ 'docker tag, or when too many agent deployments are already running (EDGEGAP_MAX_AGENT_DEPLOYMENTS, ' +
681
+ 'default 5): stop finished ones first. Env vars named like secrets are hidden in the dashboard.',
662
682
  inputSchema: {
663
683
  application: z.string().describe('Application name.'),
664
684
  version: z.string().describe('Version name within the application.'),
@@ -705,7 +725,7 @@ export function registerTools(server, client, config, auth) {
705
725
  body.environment_variables = args.env.map((e) => ({
706
726
  key: e.key,
707
727
  value: e.value,
708
- is_hidden: false,
728
+ is_hidden: looksSecret(e.key),
709
729
  }));
710
730
  }
711
731
  if (args.cpu_units && args.memory_mb) {
@@ -724,6 +744,25 @@ export function registerTools(server, client, config, auth) {
724
744
  // a full day). Read it first so the agent knows how long an
725
745
  // unstopped test server will keep billing.
726
746
  const version = await client.getAppVersion(args.application, args.version);
747
+ if (version.docker_tag !== undefined && badTag(version.docker_tag)) {
748
+ return fail(`Refused: version "${args.version}" uses docker_tag "${version.docker_tag}". ${TAG_FIX} ` +
749
+ 'Then create a new version with edgegap_create_app_version and deploy that.');
750
+ }
751
+ // A looping agent can start servers faster than anyone notices the
752
+ // bill. Count the ones it already has running before adding one.
753
+ if (config.maxAgentDeployments > 0) {
754
+ const running = await client.listDeployments({
755
+ query: JSON.stringify({ filters: [{ field: 'tags', operator: 'in', value: [AGENT_TAG, 'mcp'] }] }),
756
+ limit: 1,
757
+ });
758
+ const count = running.total_count ?? running.data?.length ?? 0;
759
+ if (count >= config.maxAgentDeployments) {
760
+ return fail(`Refused: ${count} deployments started through this server are still running, and the limit ` +
761
+ `is ${config.maxAgentDeployments} (EDGEGAP_MAX_AGENT_DEPLOYMENTS). List them with ` +
762
+ 'edgegap_list_deployments only_agent_deployments: true and stop the ones you are done with ' +
763
+ 'using edgegap_stop_deployment, then deploy again.');
764
+ }
765
+ }
727
766
  const res = await client.deploy(body);
728
767
  return ok({
729
768
  request_id: res.request_id,
@@ -1104,9 +1143,9 @@ export function registerTools(server, client, config, auth) {
1104
1143
  },
1105
1144
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true },
1106
1145
  }, async ({ image_name, tag }) => guard(auth, async () => {
1107
- if (tag === 'latest') {
1108
- return fail('Do not use the "latest" tag: Edgegap caches by tag, so a re-pushed "latest" can deploy a stale build. Pass a build ID or timestamp.');
1109
- }
1146
+ const tagProblem = tag === undefined ? undefined : badTag(tag);
1147
+ if (tagProblem)
1148
+ return fail(`Refused: ${tagProblem}. ${TAG_FIX}`);
1110
1149
  // Both wizard endpoints answer 403 to a regular API token: they belong
1111
1150
  // to the plugins' quick-start flow. 403 is the token type, not a
1112
1151
  // missing registry, so it must not trigger provisioning (which only
@@ -1475,8 +1514,9 @@ function registerSkills(server, tool) {
1475
1514
  description: 'List the Edgegap agent skills: tested, step-by-step workflows for getting a multiplayer ' +
1476
1515
  'game online on Edgegap, with templates (Dockerfiles, matchmaker configs, Unity C# and ' +
1477
1516
  'Unreal C++ drop-ins) and known pitfalls. Before working on a game project, load the ' +
1478
- 'matching skill with edgegap_get_skill: edgegap-fishnet for Unity with FishNet, ' +
1479
- 'edgegap-purrnet for Unity with PurrNet, edgegap-unity for other Unity projects, edgegap-unreal for Unreal Engine, ' +
1517
+ 'matching skill with edgegap_get_skill: edgegap-ngo for Unity with Netcode for GameObjects, edgegap-fishnet for Unity with FishNet, ' +
1518
+ '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 ' +
1519
+ '(edgegap-eos-voice to add voice chat to it), ' +
1480
1520
  'edgegap-manus for a browser game built with Manus, edgegap for any other engine or platform questions; it routes to the rest. No ' +
1481
1521
  'API call.',
1482
1522
  inputSchema: {},
@@ -1496,8 +1536,9 @@ function registerSkills(server, tool) {
1496
1536
  title: 'Load an Edgegap agent skill',
1497
1537
  description: 'Load one Edgegap agent skill: its SKILL.md (the workflow to follow) by default, or one of ' +
1498
1538
  'its reference documents or templates with file. Load the matching skill before acting on ' +
1499
- 'a game project — edgegap-fishnet for Unity with FishNet, edgegap-purrnet for Unity with ' +
1500
- 'PurrNet, edgegap-unity for other Unity projects, edgegap-unreal for Unreal Engine, ' +
1539
+ 'a game project — edgegap-ngo for Unity with Netcode for GameObjects, edgegap-fishnet for Unity with FishNet, ' +
1540
+ '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 ' +
1541
+ '(edgegap-eos-voice for voice chat), ' +
1501
1542
  '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.',
1502
1543
  inputSchema: {
1503
1544
  // 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.5.6';
6
+ export const VERSION = '0.6.1';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@edgegap/mcp",
3
3
  "mcpName": "dev.edgegap/mcp",
4
- "version": "0.5.6",
4
+ "version": "0.6.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",