@edgegap/mcp 0.3.1 → 0.3.2

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 CHANGED
@@ -142,7 +142,7 @@ To keep your API token on your own machine, run the server locally instead. Leav
142
142
  }
143
143
  ```
144
144
 
145
- Needs Node 18+. Pin a version in production (`@edgegap/mcp@0.3.1`) rather than floating on latest. Registered in the official MCP registry as `dev.edgegap/mcp`.
145
+ Needs Node 18+. Pin a version in production (`@edgegap/mcp@0.3.2`) rather than floating on latest. Registered in the official MCP registry as `dev.edgegap/mcp`.
146
146
 
147
147
  The local server can also limit what an agent can do. These variables have no effect on the hosted endpoint at `mcp.edgegap.dev`:
148
148
 
@@ -164,8 +164,8 @@ Your agent picks the right tool from your request. You don't need to name them,
164
164
  | --- | --- |
165
165
  | `edgegap_generate_dockerfile` | Writes a Dockerfile for your server build: your build folder, server binary or start script, ports, and launch arguments, with the right headless flags (Unity `-batchmode -nographics`, Godot `--headless`), a non-root user for Unreal, and matching ports. Lists anything it had to assume so your agent can confirm it. Works for Unity, Unreal Engine, Godot, and any other engine. |
166
166
  | `edgegap_validate_server_config` | Checks an existing Dockerfile, ports, resources, and image tag before you build. Catches ARM or Windows images (Edgegap runs `linux/amd64`), Unreal servers running as root, missing Unity `-batchmode -nographics`, servers bound to `localhost`, ports that don't match your netcode transport, and the `latest` tag. |
167
- | `edgegap_get_registry_credentials` ● | Returns push credentials for your private Edgegap container registry, with the exact `docker login`, build, and push commands. No Docker Hub account needed. |
168
- | `edgegap_list_registry_tags` | Confirms your image push landed before you register it. |
167
+ | `edgegap_get_registry_credentials` ● | Returns push credentials for your private Edgegap container registry, with the exact `docker login`, build, and push commands. Edgegap only gives these to the Unity/Unreal plugins' quick-start token; with a regular API token, it tells your agent to ask you for the login from the dashboard's **Container Registry** page instead. |
168
+ | `edgegap_list_registry_tags` | Confirms your image push landed before you register it. Takes the image name only, e.g. `my-game-server`: the project comes from your token. |
169
169
 
170
170
  ### Dedicated Servers (Recommended)
171
171
 
@@ -230,7 +230,7 @@ Edgegap could not pull your container image. Check the repository, image name, a
230
230
 
231
231
  ### Registry Credentials Unavailable
232
232
 
233
- If your agent can't retrieve registry credentials, request them in the [dashboard](https://app.edgegap.com) under **Container Registry**, or push to another registry Edgegap can pull from (Docker Hub, GitHub, AWS ECR, GCP, GitLab). See [External Registries](https://docs.edgegap.com/docs/tools-and-integrations/docker/external-registries).
233
+ Edgegap only gives registry credentials to the quick-start token the Unity and Unreal plugins use, so with a regular API token your agent can't retrieve them and asks you instead. Copy the Project, Username and Token from the [dashboard](https://app.edgegap.com) under **Container Registry**, or push to another registry Edgegap can pull from (Docker Hub, GitHub, AWS ECR, GCP, GitLab). See [External Registries](https://docs.edgegap.com/docs/tools-and-integrations/docker/external-registries).
234
234
 
235
235
  ### Server Starts Locally but Not on Edgegap
236
236
 
package/dist/client.js CHANGED
@@ -115,17 +115,23 @@ export class EdgegapClient {
115
115
  // --- Container registry -------------------------------------------------
116
116
  /**
117
117
  * Push credentials for the organization's project on registry.edgegap.com.
118
- * Not in the published OpenAPI spec: this is the endpoint the Unity plugin
119
- * uses, and it can fail until init-quick-start has provisioned the project.
118
+ * Not in the published OpenAPI spec: this is the Unity plugin's quick-start
119
+ * endpoint, and it only accepts that flow's quick-start tokens. A regular
120
+ * API token gets 403 "This token is not a quick start token".
120
121
  */
121
122
  getRegistryCredentials() {
122
123
  return this.request('GET', 'v1', '/v1/wizard/registry-credentials');
123
124
  }
124
- /** Provisions the registry project if needed. Idempotent; returns 204. */
125
+ /** Provisions the registry project for a quick-start token. Returns 204.
126
+ * Also quick-start only: a regular API token gets 403. */
125
127
  initQuickStart(source) {
126
128
  return this.request('POST', 'v1', '/v1/wizard/init-quick-start', { body: { source } });
127
129
  }
128
- /** imageName is "<project>/<image>"; the slash is part of the route. */
130
+ /**
131
+ * imageName is the image name only, e.g. "my-game-server": the API takes the
132
+ * project from the token, and "<project>/<image>" is a 404. The route is
133
+ * <path:image_name>, so a nested name keeps its slashes unencoded.
134
+ */
129
135
  listRegistryTags(imageName, query = {}) {
130
136
  const path = imageName.split('/').map(encodeURIComponent).join('/');
131
137
  return this.request('GET', 'v1', `/v1/container-registry/images/${path}/tags`, { query });
package/dist/http.js CHANGED
@@ -91,7 +91,7 @@ function main() {
91
91
  }
92
92
  const { token, problem } = extractToken(req.headers.authorization);
93
93
  const auth = new StaticTokenProvider(token, problem ? unavailableMessage(problem) : undefined);
94
- const server = new McpServer({ name: 'edgegap', version: '0.3.1' }, { instructions: serverInstructions('hosted') });
94
+ const server = new McpServer({ name: 'edgegap', version: '0.3.2' }, { instructions: serverInstructions('hosted') });
95
95
  registerTools(server, new EdgegapClient(config, auth), config, auth);
96
96
  const transport = new StreamableHTTPServerTransport({
97
97
  sessionIdGenerator: undefined,
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ async function main() {
29
29
  }
30
30
  throw err;
31
31
  }
32
- const server = new McpServer({ name: 'edgegap', version: '0.3.1' }, { instructions: serverInstructions('local') });
32
+ const server = new McpServer({ name: 'edgegap', version: '0.3.2' }, { instructions: serverInstructions('local') });
33
33
  warnIfTokenInArgv();
34
34
  const auth = new TokenProvider(config);
35
35
  auth.attach(server.server);
package/dist/tools.js CHANGED
@@ -752,13 +752,16 @@ export function registerTools(server, client, config, auth) {
752
752
  if (mutating) {
753
753
  server.registerTool('edgegap_get_registry_credentials', {
754
754
  title: 'Get Edgegap container registry push credentials',
755
- description: 'Return the registry URL, project, username and token for this organization\'s private ' +
756
- 'Edgegap container registry (registry.edgegap.com), plus the exact docker login, build ' +
757
- 'and push commands for your image. Use this when the server image is not in a registry ' +
758
- 'yet — no Docker Hub account needed. Provisions the registry project on first use. The ' +
759
- 'token is registry-scoped (push/pull images in this project), not the org API token: ' +
760
- 'pass it to docker login via --password-stdin, never as a command-line argument, and do ' +
761
- 'not write it into files. Call edgegap_validate_server_config before building.',
755
+ description: 'Get the push login for this organization\'s private Edgegap container registry ' +
756
+ '(registry.edgegap.com) and the exact docker login, build and push commands for your ' +
757
+ 'image. Use this when the server image is not in a registry yet. Edgegap only hands ' +
758
+ 'these credentials to the quick-start token the Unity/Unreal plugins use; with a ' +
759
+ 'regular API token this tool cannot fetch them and instead returns the steps to copy ' +
760
+ 'them from the dashboard\'s Container Registry page — ask the developer for them then, ' +
761
+ 'do not retry. When it does return a token, it is registry-scoped (push/pull images in ' +
762
+ 'this project), not the org API token: pass it to docker login via --password-stdin, ' +
763
+ 'never as a command-line argument, and do not write it into files. Call ' +
764
+ 'edgegap_validate_server_config before building.',
762
765
  inputSchema: {
763
766
  image_name: z
764
767
  .string()
@@ -775,24 +778,35 @@ export function registerTools(server, client, config, auth) {
775
778
  if (tag === 'latest') {
776
779
  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.');
777
780
  }
781
+ // Both wizard endpoints answer 403 to a regular API token: they belong
782
+ // to the plugins' quick-start flow. 403 is the token type, not a
783
+ // missing registry, so it must not trigger provisioning (which only
784
+ // fails with a second, more confusing 403). Only a 404 — a
785
+ // quick-start token whose project is not provisioned yet — does.
786
+ const unavailable = () => fail(registryCredentialsUnavailable(image_name, tag));
778
787
  let creds;
779
788
  try {
780
789
  creds = await client.getRegistryCredentials();
781
790
  }
782
791
  catch (err) {
783
- if (!(err instanceof EdgegapApiError) || err.status === 401)
792
+ if (!(err instanceof EdgegapApiError))
784
793
  throw err;
785
- // Usually means the registry project has not been provisioned for
786
- // this org yet. The plugins provision it this way on every login.
787
- await client.initQuickStart('mcp');
794
+ if (err.status === 403)
795
+ return unavailable();
796
+ if (err.status !== 404)
797
+ throw err;
798
+ try {
799
+ await client.initQuickStart('mcp');
800
+ }
801
+ catch (initErr) {
802
+ if (initErr instanceof EdgegapApiError && initErr.status === 403)
803
+ return unavailable();
804
+ throw initErr;
805
+ }
788
806
  creds = await client.getRegistryCredentials();
789
807
  }
790
- if (!creds.project || !creds.username || !creds.token) {
791
- return fail('Edgegap did not return registry credentials for this organization. The developer ' +
792
- `can request them in the dashboard (${DASHBOARD_URL}, Container Registry page), or ` +
793
- 'push to any other registry Edgegap can pull from (Docker Hub, GHCR, ECR, GCR, GitLab) ' +
794
- 'and pass registry_username/registry_token to edgegap_create_app_version.');
795
- }
808
+ if (!creds.project || !creds.username || !creds.token)
809
+ return unavailable();
796
810
  const host = (creds.registry_url || 'registry.edgegap.com').replace(/^https?:\/\//, '').replace(/\/$/, '');
797
811
  const image = image_name ?? '<image-name>';
798
812
  const buildTag = tag ?? '<unique-build-tag>';
@@ -817,7 +831,7 @@ export function registerTools(server, client, config, auth) {
817
831
  },
818
832
  next_step: 'Export the token as EDGEGAP_REGISTRY_TOKEN in the shell that runs docker login ' +
819
833
  '(it never needs to appear in a command line or file), then build and push. ' +
820
- `Confirm the push with edgegap_list_registry_tags (image_name "${creds.project}/${image}"), ` +
834
+ `Confirm the push with edgegap_list_registry_tags (image_name "${image}", without the project), ` +
821
835
  'then call edgegap_create_app_version with the values in for_create_app_version.',
822
836
  });
823
837
  }));
@@ -831,23 +845,65 @@ export function registerTools(server, client, config, auth) {
831
845
  inputSchema: {
832
846
  image_name: z
833
847
  .string()
834
- .describe('"<project>/<image>", e.g. "my-org-cv2l3w3vy6fg/my-game-server". Project comes from edgegap_get_registry_credentials.'),
848
+ .min(1)
849
+ .describe('The image name only, without the project, registry host or tag, e.g. "my-game-server". ' +
850
+ 'The API reads the project from your token; "<project>/my-game-server" is not found.'),
835
851
  page: z.number().int().min(1).optional(),
836
852
  limit: z.number().int().min(1).max(100).optional().describe('Default 20.'),
837
853
  },
838
854
  annotations: { readOnlyHint: true, openWorldHint: true },
839
855
  }, async ({ image_name, page, limit }) => guard(auth, async () => {
840
- if (!image_name.includes('/')) {
841
- return fail(`image_name "${image_name}" needs the project prefix: "<project>/${image_name}".`);
856
+ // Agents often pass the full reference they pushed. Reduce it to what
857
+ // the API wants: no "registry.edgegap.com/" host, no ":tag".
858
+ const parts = image_name.replace(/@sha256:.*$/, '').split('/');
859
+ if (parts.length > 1 && /[.:]/.test(parts[0]))
860
+ parts.shift();
861
+ parts[parts.length - 1] = parts[parts.length - 1].replace(/:[^:]*$/, '');
862
+ let name = parts.join('/');
863
+ const query = { page, limit: limit ?? 20 };
864
+ const notFound = (err) => err instanceof EdgegapApiError && err.status === 404;
865
+ let res;
866
+ try {
867
+ try {
868
+ res = await client.listRegistryTags(name, query);
869
+ }
870
+ catch (err) {
871
+ // Nested image names are valid, so try the name as given first. If
872
+ // it is "<project>/<image>", that 404s; retry without the project.
873
+ if (!notFound(err) || !name.includes('/'))
874
+ throw err;
875
+ name = name.slice(name.indexOf('/') + 1);
876
+ res = await client.listRegistryTags(name, query);
877
+ }
878
+ }
879
+ catch (err) {
880
+ // The generic 404 hint points at applications, which is wrong here.
881
+ if (!notFound(err))
882
+ throw err;
883
+ return fail(`No image named "${name}" in this organization's Edgegap registry, so nothing has been ` +
884
+ 'pushed under that name. Check the name (image name only, as used after ' +
885
+ '"registry.edgegap.com/<project>/" in docker push), or push the image first.');
842
886
  }
843
- const res = await client.listRegistryTags(image_name, { page, limit: limit ?? 20 });
844
887
  const tags = (res.data ?? []).map((t) => ({
845
888
  tag: t.tag,
846
889
  pushed: t.last_push_at,
847
890
  size_mb: t.artifact?.size_mb,
848
891
  digest: t.artifact?.image_hash,
849
892
  }));
850
- return ok({ image_name, ...pageInfo(res.total_count, tags.length, page ?? 1), tags });
893
+ const hasNext = res.pagination?.has_next === true;
894
+ return ok({
895
+ image_name: name,
896
+ note: name !== image_name ? `Looked up "${name}". Pass the image name only next time.` : undefined,
897
+ total: res.count ?? tags.length,
898
+ ...(hasNext
899
+ ? {
900
+ showing: tags.length,
901
+ truncated: true,
902
+ next_step: `Only page ${page ?? 1} is shown. Call again with page: ${(page ?? 1) + 1} before concluding a tag is missing.`,
903
+ }
904
+ : {}),
905
+ tags,
906
+ });
851
907
  }));
852
908
  // ================================================== peer-to-peer relays ====
853
909
  // --------------------------------------------------------------- 14 ----
@@ -1035,6 +1091,32 @@ export function registerTools(server, client, config, auth) {
1035
1091
  });
1036
1092
  }));
1037
1093
  }
1094
+ /**
1095
+ * What edgegap_get_registry_credentials says when Edgegap will not hand the
1096
+ * registry login to this token. Written as the manual path that works today,
1097
+ * so the agent asks the developer instead of retrying or guessing.
1098
+ */
1099
+ function registryCredentialsUnavailable(imageName, tag) {
1100
+ const image = imageName ?? '<image-name>';
1101
+ const buildTag = tag ?? '<unique-build-tag>';
1102
+ const ref = `registry.edgegap.com/<project>/${image}:${buildTag}`;
1103
+ return ('Edgegap does not give container registry credentials to a regular API token: the ' +
1104
+ 'endpoint only accepts the quick-start token the Unity/Unreal plugins use (it answered ' +
1105
+ '403). This is the token type, not a problem with the registry. Do not retry. Ask the ' +
1106
+ 'developer for the registry login instead:\n\n' +
1107
+ `1. In the dashboard (${DASHBOARD_URL}), open the Container Registry page and copy the ` +
1108
+ 'Project, Username and Token.\n' +
1109
+ '2. Log in with the token read from an environment variable, never as an argument:\n' +
1110
+ ` printf '%s' "$EDGEGAP_REGISTRY_TOKEN" | docker login registry.edgegap.com -u '<username>' --password-stdin\n` +
1111
+ `3. docker build --platform linux/amd64 -t ${ref} .\n` +
1112
+ `4. docker push ${ref}\n` +
1113
+ `5. Confirm with edgegap_list_registry_tags (image_name "${image}", without the project).\n` +
1114
+ '6. Call edgegap_create_app_version with docker_repository "registry.edgegap.com", ' +
1115
+ `docker_image "<project>/${image}", docker_tag "${buildTag}", and the same username and ` +
1116
+ 'token as registry_username/registry_token.\n\n' +
1117
+ 'Or push to any other registry Edgegap can pull from (Docker Hub, GHCR, ECR, GCR, GitLab) ' +
1118
+ 'and pass its registry_username/registry_token to edgegap_create_app_version.');
1119
+ }
1038
1120
  /** Trims a relay session down to what a game client integration needs. */
1039
1121
  function compactRelay(s) {
1040
1122
  return {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@edgegap/mcp",
3
3
  "mcpName": "dev.edgegap/mcp",
4
- "version": "0.3.1",
4
+ "version": "0.3.2",
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",