@edgegap/mcp 0.3.1 → 0.3.3

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
@@ -82,9 +82,24 @@ claude mcp add --transport http edgegap https://mcp.edgegap.dev/mcp \
82
82
  codex mcp add edgegap --url https://mcp.edgegap.dev/mcp
83
83
  ```
84
84
 
85
- #### claude.ai
85
+ #### Claude Desktop and claude.ai
86
86
 
87
- Add `https://mcp.edgegap.dev/mcp` as a custom connector and supply the same token.
87
+ Custom connectors in claude.ai and Claude Desktop cannot send an `Authorization` header, so the hosted endpoint never receives your token from them: the connector shows as connected, but every tool call fails. Use the [Local Server](#local-server) instead.
88
+
89
+ In Claude Desktop, open **Settings → Developer → Edit Config** and add the local server to `claude_desktop_config.json`:
90
+
91
+ ```json
92
+ {
93
+ "mcpServers": {
94
+ "edgegap": {
95
+ "command": "npx",
96
+ "args": ["-y", "@edgegap/mcp"]
97
+ }
98
+ }
99
+ }
100
+ ```
101
+
102
+ Leave the token out and you're asked for it on first use. claude.ai in the browser can't run a local server, so it can't use Edgegap MCP until the hosted endpoint supports OAuth.
88
103
 
89
104
  #### mcp.json
90
105
 
@@ -142,7 +157,7 @@ To keep your API token on your own machine, run the server locally instead. Leav
142
157
  }
143
158
  ```
144
159
 
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`.
160
+ Needs Node 18+. Pin a version in production (`@edgegap/mcp@0.3.3`) rather than floating on latest. Registered in the official MCP registry as `dev.edgegap/mcp`.
146
161
 
147
162
  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
163
 
@@ -150,7 +165,7 @@ The local server can also limit what an agent can do. These variables have no ef
150
165
  | --- | --- | --- |
151
166
  | `EDGEGAP_API_TOKEN` | *(prompted)* | API token. Optional: omit it and you're asked at first use. The `token ` prefix is added for you. Never pass it as a command-line argument. |
152
167
  | `EDGEGAP_READ_ONLY` | `0` | Set to `1` and the eight mutating tools are never registered, so the agent cannot be talked into calling them. |
153
- | `EDGEGAP_APP_ALLOWLIST` | *(empty)* | Comma-separated application names. Limits what the agent can create and deploy into, not what it can touch once running. See [DESIGN.md](DESIGN.md#scope-of-the-allowlist). |
168
+ | `EDGEGAP_APP_ALLOWLIST` | *(empty)* | Comma-separated application names. Limits what the agent can create and deploy into. Reading (listing apps and versions) is not limited, and neither is touching deployments once running. See [DESIGN.md](DESIGN.md#scope-of-the-allowlist). |
154
169
  | `EDGEGAP_MAX_DURATION_MINUTES` | `60` | Ceiling on `max_duration` the agent may set on a version. |
155
170
  | `EDGEGAP_TIMEOUT_MS` | `30000` | Per-request HTTP timeout. |
156
171
 
@@ -164,8 +179,8 @@ Your agent picks the right tool from your request. You don't need to name them,
164
179
  | --- | --- |
165
180
  | `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
181
  | `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. |
182
+ | `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. |
183
+ | `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
184
 
170
185
  ### Dedicated Servers (Recommended)
171
186
 
@@ -173,20 +188,20 @@ Your agent picks the right tool from your request. You don't need to name them,
173
188
  | --- | --- |
174
189
  | `edgegap_list_apps` | Lists your applications. |
175
190
  | `edgegap_create_app` ● | Creates an application. |
176
- | `edgegap_list_app_versions` | Lists versions with their image, resources, and ports. |
177
- | `edgegap_create_app_version` ● | Registers a container image as a deployable version. |
191
+ | `edgegap_list_app_versions` | Lists versions with their image, resources, ports (with TLS Upgrade), and whether a registry login is set. |
192
+ | `edgegap_create_app_version` ● | Registers a container image as a deployable version. Supports TLS Upgrade on WS and HTTP ports, which browser (WebGL) clients need for `wss://`. |
178
193
  | `edgegap_deploy` ● | Deploys an authoritative dedicated server close to your players. |
179
194
  | `edgegap_wait_for_deployment` | Waits until the server is ready and returns the connection address. |
180
195
  | `edgegap_get_deployment` | Reads a deployment's status. |
181
196
  | `edgegap_list_deployments` | Lists running deployments, filtered by application, version, status, tags and more, and sorted by age. Finds servers left running. See [Filter Deployments](https://docs.edgegap.com/learn/orchestration/deployments#filter-deployments). |
182
- | `edgegap_get_deployment_logs` | Reads container logs and crash details. |
197
+ | `edgegap_get_deployment_logs` | Reads container logs and crash details while the deployment runs. After it stops, logs are only kept if Endpoint Storage was set up. |
183
198
  | `edgegap_stop_deployment` ● | Stops one deployment. |
184
199
 
185
200
  ### Matchmaking
186
201
 
187
202
  | Tool | What it does |
188
203
  | --- | --- |
189
- | `edgegap_build_matchmaker_config` | Generates a matchmaker configuration (teams, team size, optional latency rules and expansions) and checks that the version it deploys exists. Upload the result in the dashboard to create your matchmaker, which starts a dedicated server for each match. |
204
+ | `edgegap_build_matchmaker_config` | Generates a matchmaker configuration (teams, team size, optional latency rules and expansions) and checks that the version it deploys exists. Set `allowed_cors_origins` for browser (WebGL) clients. Upload the result in the dashboard to create your matchmaker, which starts a dedicated server for each match. |
190
205
 
191
206
  Learn more about the configuration in [Matchmaking](https://docs.edgegap.com/learn/matchmaking).
192
207
 
@@ -230,7 +245,7 @@ Edgegap could not pull your container image. Check the repository, image name, a
230
245
 
231
246
  ### Registry Credentials Unavailable
232
247
 
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).
248
+ 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
249
 
235
250
  ### Server Starts Locally but Not on Edgegap
236
251
 
package/dist/auth.js CHANGED
@@ -37,6 +37,7 @@
37
37
  * The real fix is scoped, revocable, deploy-only credentials issued by Edgegap.
38
38
  * Until those exist, this file is a workaround and should be labelled as one.
39
39
  */
40
+ import { stripTokenPrefix } from './config.js';
40
41
  export class TokenUnavailableError extends Error {
41
42
  }
42
43
  /** Shown to the developer at the moment they are asked to hand over a token. */
@@ -181,7 +182,7 @@ export class TokenProvider {
181
182
  'organization with EDGEGAP_READ_ONLY=1.');
182
183
  }
183
184
  const raw = String(result.content.api_token ?? '').trim();
184
- const token = raw.replace(/^token\s+/i, '');
185
+ const token = stripTokenPrefix(raw);
185
186
  if (!token) {
186
187
  throw new TokenUnavailableError('An empty token was submitted. Nothing was stored.');
187
188
  }
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/config.js CHANGED
@@ -26,8 +26,8 @@ export function loadConfig(env = process.env) {
26
26
  // anything works" step that loses people during onboarding.
27
27
  const raw = env.EDGEGAP_API_TOKEN?.trim();
28
28
  // Tokens are pasted by hand often enough that it is worth catching the
29
- // common mistake of including the "token " prefix twice.
30
- const envToken = raw ? raw.replace(/^token\s+/i, '') : undefined;
29
+ // common mistake of including the "token " prefix, once or more.
30
+ const envToken = raw ? stripTokenPrefix(raw) || undefined : undefined;
31
31
  return {
32
32
  envToken,
33
33
  baseUrlV1: env.EDGEGAP_BASE_URL?.trim() || 'https://api.edgegap.com',
@@ -52,6 +52,18 @@ export function assertAppAllowed(config, appName) {
52
52
  `allowlist rather than trying another application name.`);
53
53
  }
54
54
  }
55
+ /**
56
+ * Removes any run of "Bearer " / "token " prefixes from a pasted credential.
57
+ *
58
+ * The prefix gets doubled easily: the dashboard shows the header form
59
+ * ("token <uuid>"), so an EDGEGAP_API_TOKEN that already carries it, dropped
60
+ * into a config that adds "token " again, sends "token token <uuid>". Stripping
61
+ * only one left "token <uuid>", which the hosted server then mistook for a
62
+ * foreign credential and refused with a misleading message.
63
+ */
64
+ export function stripTokenPrefix(value) {
65
+ return value.trim().replace(/^(?:(?:bearer|token)\s+)+/i, '').trim();
66
+ }
55
67
  /**
56
68
  * Strips the live token out of text before it reaches the model.
57
69
  * Error strings from HTTP layers sometimes echo request headers back.
@@ -72,17 +72,31 @@ export function generateDockerfile(input) {
72
72
  throw new DockerfileInputError(`base_image "${base}" is not a valid image reference.`);
73
73
  }
74
74
  // ------------------------------------------------------------- ports ----
75
+ // A WebSocket transport means browser (WebGL) clients, which need wss://:
76
+ // Edgegap's TLS Upgrade on the WS port.
77
+ const browserNetcode = input.netcode !== undefined && protocolForNetcode(input.netcode) === 'WS';
78
+ let autoTls = false; // set when TLS was turned on without being asked for
75
79
  let ports;
76
80
  if (input.ports && input.ports.length > 0) {
77
- ports = input.ports.map((p, i) => ({
78
- port: p.port,
79
- protocol: p.protocol.toUpperCase(),
80
- name: p.name ?? (i === 0 ? 'gameport' : `port${i + 1}`),
81
- }));
81
+ ports = input.ports.map((p, i) => {
82
+ const protocol = p.protocol.toUpperCase();
83
+ let tls = p.tls_upgrade;
84
+ if (tls === undefined && browserNetcode && protocol === 'WS') {
85
+ tls = true;
86
+ autoTls = true;
87
+ }
88
+ return {
89
+ port: p.port,
90
+ protocol,
91
+ name: p.name ?? (i === 0 ? 'gameport' : `port${i + 1}`),
92
+ ...(tls !== undefined ? { tls_upgrade: tls } : {}),
93
+ };
94
+ });
82
95
  }
83
96
  else {
84
97
  const protocol = (input.netcode && protocolForNetcode(input.netcode)) || 'UDP';
85
- ports = [{ port: 7777, protocol, name: 'gameport' }];
98
+ ports = [{ port: 7777, protocol, name: 'gameport', ...(browserNetcode ? { tls_upgrade: true } : {}) }];
99
+ autoTls = browserNetcode;
86
100
  assumptions.push(`Assumed the server listens on 7777/${protocol}${input.netcode ? ` (the protocol ${input.netcode} uses)` : ''}. ` +
87
101
  'Confirm the port in the server\'s network/transport settings and pass ports if it differs.');
88
102
  }
@@ -172,6 +186,10 @@ export function generateDockerfile(input) {
172
186
  }
173
187
  }
174
188
  }
189
+ if (autoTls) {
190
+ assumptions.push('Turned on tls_upgrade for the WebSocket port, because WebSocket transports usually mean ' +
191
+ 'browser (WebGL) clients, which need wss://. Set tls_upgrade: false if no client runs in a browser.');
192
+ }
175
193
  assumptions.push(buildPath === '.'
176
194
  ? 'Run docker build from inside the server build folder (the folder itself is the build context).'
177
195
  : `Run docker build from the folder that contains ${buildPath}.`);
package/dist/hosted.js CHANGED
@@ -6,6 +6,7 @@
6
6
  * Edgegap token in its Authorization header, and it is used for that request
7
7
  * and discarded. See worker/DECISION.md.
8
8
  */
9
+ import { stripTokenPrefix } from './config.js';
9
10
  const TOKEN_URL = 'https://app.edgegap.com/user-settings?tab=tokens';
10
11
  /**
11
12
  * Edgegap API tokens are UUIDs. The strict form is the real test; the loose
@@ -27,7 +28,8 @@ function looksLikeEdgegapToken(value) {
27
28
  export function extractToken(header) {
28
29
  if (!header)
29
30
  return { token: undefined, problem: 'absent' };
30
- const value = header.replace(/^Bearer\s+/i, '').replace(/^token\s+/i, '').trim();
31
+ // Any run of "Bearer "/"token ", so "token token <uuid>" still works.
32
+ const value = stripTokenPrefix(header);
31
33
  if (!value)
32
34
  return { token: undefined, problem: 'absent' };
33
35
  if (!looksLikeEdgegapToken(value))
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.3' }, { 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.3' }, { instructions: serverInstructions('local') });
33
33
  warnIfTokenInArgv();
34
34
  const auth = new TokenProvider(config);
35
35
  auth.attach(server.server);
@@ -83,10 +83,20 @@ export function buildMatchmakerConfig(input) {
83
83
  if (input.team_count * input.min_team_size === 1) {
84
84
  cautions.push('A match of one player starts a server per ticket. Fine for testing, costly in production.');
85
85
  }
86
+ // Browser (WebGL) clients call the matchmaker directly, so their page's
87
+ // origin must be allowed. An origin is scheme + host (+ port), nothing more:
88
+ // a path or trailing slash never matches a browser's Origin header.
89
+ const origins = input.allowed_cors_origins ?? [];
90
+ for (const o of origins) {
91
+ if (!/^https?:\/\/[^/\s?#]+$/.test(o)) {
92
+ problems.push(`allowed_cors_origins entry "${o}" is not an origin. Use scheme and host only, e.g. "https://mygame.example.com" or "http://localhost:8080", with no path or trailing slash.`);
93
+ }
94
+ }
86
95
  const config = {
87
96
  version: input.config_version ?? MATCHMAKER_CONFIG_VERSION,
88
97
  inspect: input.inspect ?? true,
89
98
  max_deployment_retry_count: 3,
99
+ ...(origins.length ? { allowed_cors_origins: origins } : {}),
90
100
  profiles: {
91
101
  [input.profile_name]: {
92
102
  ticket_expiration_period: expiration,
@@ -196,6 +196,9 @@ export function validateServerConfig(input) {
196
196
  err('duplicate-port-name', `Port name "${name}" is used twice. Deployment ports are keyed by name, so one would hide the other.`, 'Give every port a distinct name, e.g. "gameport" and "webport".');
197
197
  }
198
198
  seenNames.add(name);
199
+ if (p.tls_upgrade && proto !== 'WS' && proto !== 'HTTP') {
200
+ err('tls-wrong-protocol', `ports[${idx}] has tls_upgrade on a ${p.protocol} port. Edgegap only offers TLS Upgrade on WS and HTTP ports.`, 'Use protocol "WS" for a WebSocket server, or drop tls_upgrade.');
201
+ }
199
202
  });
200
203
  if (input.netcode) {
201
204
  const expected = NETCODE_PROTOCOL[input.netcode.toLowerCase()];
@@ -208,6 +211,15 @@ export function validateServerConfig(input) {
208
211
  })) {
209
212
  err('netcode-protocol', `${input.netcode} speaks ${expected}, but no configured port uses ${expected}. Clients will time out connecting.`, `Set the game port's protocol to ${expected}.`);
210
213
  }
214
+ else if (expected === 'WS') {
215
+ // WebSocket transports are what browser (WebGL) builds use, and a
216
+ // browser on an https page refuses plain ws://.
217
+ for (const p of ports) {
218
+ if (p.protocol.toUpperCase() === 'WS' && !p.tls_upgrade) {
219
+ warn('ws-no-tls', `Port ${p.port} is WebSocket without tls_upgrade. Browser (WebGL) clients need wss://, which needs Edgegap's TLS Upgrade.`, 'Set tls_upgrade: true on this port in edgegap_create_app_version, unless no client runs in a browser.');
220
+ }
221
+ }
222
+ }
211
223
  }
212
224
  // Cross-check EXPOSE against the version ports. EXPOSE is documentation,
213
225
  // so a mismatch is not fatal on its own, but it is the best signal we have
package/dist/tools.js CHANGED
@@ -74,6 +74,10 @@ export function serverInstructions(mode) {
74
74
  /** 1x1 transparent PNG. The create-app endpoint requires an image and agents
75
75
  * have no sensible one to supply; a placeholder beats a blocked flow. */
76
76
  const PLACEHOLDER_IMAGE = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==';
77
+ /** Port protocols, uppercased. The API accepts "WS" but returns "Websocket". */
78
+ const WS_PROTOCOLS = new Set(['WS', 'WEBSOCKET']);
79
+ /** tls_upgrade is only valid on WebSocket and HTTP ports (per the API spec). */
80
+ const TLS_PROTOCOLS = new Set(['WS', 'WEBSOCKET', 'HTTP']);
77
81
  const TERMINAL_OK = ['READY', 'STATUS_READY'];
78
82
  const TERMINAL_BAD = ['ERROR', 'STATUS_ERROR', 'TERMINATED', 'STATUS_TERMINATED'];
79
83
  function ok(payload, notice) {
@@ -85,9 +89,25 @@ function ok(payload, notice) {
85
89
  function fail(message) {
86
90
  return { content: [{ type: 'text', text: message }], isError: true };
87
91
  }
92
+ /**
93
+ * What a 404 means, per kind of resource. A 404 from Edgegap only says "not
94
+ * found"; which thing is missing, and what to do next, depends on the tool.
95
+ * One generic hint used to be attached to every 404, which sent agents to
96
+ * edgegap_list_apps for stopped deployments and missing registry images.
97
+ */
98
+ const NOT_FOUND = {
99
+ app: 'the application or version name does not exist. Call edgegap_list_apps, then ' +
100
+ 'edgegap_list_app_versions, to find the right names.',
101
+ deployment: 'no deployment with that request_id. It may have stopped and been cleaned up, or the ' +
102
+ 'request_id is wrong. Running deployments are listed by edgegap_list_deployments.',
103
+ logs: 'no logs for this deployment. Container logs only exist while a deployment is running; ' +
104
+ 'once it has stopped they are gone, unless Endpoint Storage was configured on the version ' +
105
+ 'before it ran. If it is still running, check the request_id with edgegap_list_deployments.',
106
+ relay: 'no relay session with that session_id. It may already have been deleted.',
107
+ };
88
108
  /** Wraps a handler so API errors come back as readable, self-correctable text
89
109
  * rather than a protocol-level exception the agent cannot act on. */
90
- function guard(auth, fn) {
110
+ function guard(auth, fn, notFound) {
91
111
  const handled = fn().catch((err) => {
92
112
  if (err instanceof TokenUnavailableError) {
93
113
  // Not a failure to correct — a decision the human made. Say so plainly
@@ -95,7 +115,7 @@ function guard(auth, fn) {
95
115
  return fail(err.message);
96
116
  }
97
117
  if (err instanceof EdgegapApiError) {
98
- const hint = errorHint(err);
118
+ const hint = errorHint(err, notFound);
99
119
  return fail(`${err.message}${hint ? `\n\nLikely cause: ${hint}` : ''}`);
100
120
  }
101
121
  return fail(redact(err.message ?? String(err), auth.current));
@@ -114,7 +134,11 @@ function guard(auth, fn) {
114
134
  };
115
135
  });
116
136
  }
117
- function errorHint(err) {
137
+ /** guard() with the 404 hint first, so it reads at the call site. */
138
+ function guarded(auth, notFound, fn) {
139
+ return guard(auth, fn, notFound);
140
+ }
141
+ function errorHint(err, notFound) {
118
142
  switch (err.status) {
119
143
  case 401:
120
144
  // Deliberately does not promise a re-prompt: the local server asks again
@@ -124,8 +148,16 @@ function errorHint(err) {
124
148
  'different organization. Check it at ' +
125
149
  'https://app.edgegap.com/user-settings?tab=tokens. The token has been ' +
126
150
  'discarded from this session.');
151
+ case 400:
152
+ // The deployment endpoints answer an unknown request_id with 400 ("Bad
153
+ // Request ID provided", or a generic "could not understand" for logs),
154
+ // not 404. Their only input is the request_id, so a 400 means that.
155
+ return notFound === NOT_FOUND.deployment || notFound === NOT_FOUND.logs ? notFound : undefined;
127
156
  case 404:
128
- return 'the application or version name does not exist. Call edgegap_list_apps first.';
157
+ // Only the tool knows what was not found; no hint beats a wrong one.
158
+ return notFound;
159
+ case 429:
160
+ return 'Edgegap rate-limited this token. Wait a few seconds before the next call, and do not retry in a loop.';
129
161
  case 409:
130
162
  return 'a resource with that name already exists. Pick a different name or reuse the existing one.';
131
163
  case 422:
@@ -263,24 +295,36 @@ export function registerTools(server, client, config, auth) {
263
295
  // ---------------------------------------------------------------- 3 ----
264
296
  server.registerTool('edgegap_list_app_versions', {
265
297
  title: 'List versions of an application',
266
- description: 'List the versions under an application, with their container image and resource ' +
267
- 'settings. Use this to find the version name to deploy, or to copy settings from a ' +
268
- 'working version when creating a new one.',
298
+ description: 'List the versions under an application, with their container image, resources, ports ' +
299
+ '(including whether TLS Upgrade is on, which browser/WebGL clients need for wss://) and ' +
300
+ 'whether a registry login is set for pulling the image. Use this to find the version ' +
301
+ 'name to deploy, to check a version is ready before deploying, or to copy settings from ' +
302
+ 'a working version when creating a new one.',
269
303
  inputSchema: {
270
304
  application: z.string().describe('Application name, as returned by edgegap_list_apps.'),
271
305
  },
272
306
  annotations: { readOnlyHint: true, openWorldHint: true },
273
- }, async ({ application }) => guard(auth, async () => {
274
- assertAppAllowed(config, application);
307
+ }, async ({ application }) =>
308
+ // Read-only, so not subject to EDGEGAP_APP_ALLOWLIST: the allowlist
309
+ // limits what the agent can create and deploy into, as documented.
310
+ guarded(auth, NOT_FOUND.app, async () => {
275
311
  const res = await client.listAppVersions(application);
276
312
  const versions = (res.versions ?? []).map((v) => ({
277
313
  name: v.name,
278
314
  active: v.is_active,
279
315
  image: [v.docker_repository, v.docker_image, v.docker_tag].filter(Boolean).join('/'),
316
+ // Whether a login is set, never the login itself: the API returns
317
+ // the registry token in this response.
318
+ registry_credentials_set: Boolean(v.private_username && v.private_token),
280
319
  cpu_units: v.req_cpu,
281
320
  memory_mb: v.req_memory,
282
321
  max_duration_minutes: v.max_duration,
283
- ports: v.ports?.map((p) => `${p.name ?? 'port'}:${p.port}/${p.protocol}`),
322
+ ports: v.ports?.map((p) => ({
323
+ name: p.name,
324
+ port: p.port,
325
+ protocol: p.protocol,
326
+ tls_upgrade: p.tls_upgrade ?? false,
327
+ })),
284
328
  }));
285
329
  return ok({ application, ...pageInfo(res.total_count, versions.length, 1), versions });
286
330
  }));
@@ -319,10 +363,20 @@ export function registerTools(server, client, config, auth) {
319
363
  .boolean()
320
364
  .optional()
321
365
  .describe('Readiness check on this port. Default true.'),
366
+ tls_upgrade: z
367
+ .boolean()
368
+ .optional()
369
+ .describe('Edgegap terminates TLS on this port, so clients connect with wss:// or https://. ' +
370
+ 'Required for browser (WebGL) clients, which cannot use plain ws:// from an https page. ' +
371
+ 'WS and HTTP ports only. Default false.'),
322
372
  }))
323
373
  .min(1)
324
374
  .describe('Ports to expose. At least one is required for players to connect.'),
325
- registry_username: z.string().optional().describe('Registry username, for private images.'),
375
+ registry_username: z
376
+ .string()
377
+ .optional()
378
+ .describe('Registry username. Needed for private images, including images in your own ' +
379
+ 'registry.edgegap.com project: Edgegap pulls with this login, not your API token.'),
326
380
  registry_token: z.string().optional().describe('Registry password or token.'),
327
381
  max_duration_minutes: z
328
382
  .number()
@@ -339,38 +393,72 @@ export function registerTools(server, client, config, auth) {
339
393
  .describe('Environment variables injected into the container.'),
340
394
  },
341
395
  annotations: { destructiveHint: false, idempotentHint: false, openWorldHint: true },
342
- }, async (args) => guard(auth, async () => {
396
+ }, async (args) => guarded(auth, NOT_FOUND.app, async () => {
343
397
  assertAppAllowed(config, args.application);
344
398
  if (args.memory_mb > args.cpu_units * 2) {
345
399
  return fail(`memory_mb (${args.memory_mb}) exceeds twice cpu_units (${args.cpu_units}). ` +
346
400
  `Edgegap rejects this. Either lower memory_mb to ${args.cpu_units * 2} or raise cpu_units.`);
347
401
  }
402
+ const badTls = args.ports.find((p) => p.tls_upgrade && !TLS_PROTOCOLS.has(p.protocol.toUpperCase()));
403
+ if (badTls) {
404
+ return fail(`Port ${badTls.port} is ${badTls.protocol}; tls_upgrade only works on WS and HTTP ports. ` +
405
+ 'Use protocol "WS" for a WebSocket server, or drop tls_upgrade.');
406
+ }
348
407
  const requested = args.max_duration_minutes ?? config.maxDurationCeiling;
349
408
  const capped = Math.min(requested, config.maxDurationCeiling);
350
- const res = await client.createAppVersion(args.application, {
351
- name: args.name,
352
- is_active: true,
353
- req_cpu: args.cpu_units,
354
- req_memory: args.memory_mb,
355
- docker_repository: args.docker_repository,
356
- docker_image: args.docker_image,
357
- docker_tag: args.docker_tag,
358
- private_username: args.registry_username,
359
- private_token: args.registry_token,
360
- verify_image: args.verify_image ?? false,
361
- max_duration: capped,
362
- ports: args.ports.map((p) => ({
363
- port: p.port,
364
- protocol: p.protocol,
365
- name: p.name ?? 'gameport',
366
- to_check: p.to_check ?? true,
367
- })),
368
- envs: args.env?.map((e) => ({ key: e.key, value: e.value, is_hidden: false })),
369
- });
409
+ const hasRegistryLogin = Boolean(args.registry_username && args.registry_token);
410
+ const edgegapRegistry = /(^|\/\/)registry\.edgegap\.com\/?$/.test(args.docker_repository.trim());
411
+ let res;
412
+ try {
413
+ res = await client.createAppVersion(args.application, {
414
+ name: args.name,
415
+ is_active: true,
416
+ req_cpu: args.cpu_units,
417
+ req_memory: args.memory_mb,
418
+ docker_repository: args.docker_repository,
419
+ docker_image: args.docker_image,
420
+ docker_tag: args.docker_tag,
421
+ private_username: args.registry_username,
422
+ private_token: args.registry_token,
423
+ verify_image: args.verify_image ?? false,
424
+ max_duration: capped,
425
+ ports: args.ports.map((p) => ({
426
+ port: p.port,
427
+ protocol: p.protocol,
428
+ name: p.name ?? 'gameport',
429
+ to_check: p.to_check ?? true,
430
+ tls_upgrade: p.tls_upgrade ?? false,
431
+ })),
432
+ envs: args.env?.map((e) => ({ key: e.key, value: e.value, is_hidden: false })),
433
+ });
434
+ }
435
+ catch (err) {
436
+ // verify_image pulls with the version's registry login. Without one
437
+ // — even for the org's own registry.edgegap.com project — Edgegap
438
+ // answers a bare 400 "Unable to login with the given credentials".
439
+ if (err instanceof EdgegapApiError && err.status === 400 && /login|credential/i.test(err.apiMessage)) {
440
+ return fail(registryLoginNeeded(args.docker_repository, hasRegistryLogin));
441
+ }
442
+ throw err;
443
+ }
444
+ const notes = [];
445
+ if (edgegapRegistry && !hasRegistryLogin) {
446
+ notes.push('No registry login was set. Edgegap pulls images from registry.edgegap.com with the ' +
447
+ 'version\'s registry login, not your API token, so deployments of this version will ' +
448
+ 'likely fail to pull (424) until the developer adds the Container Registry username ' +
449
+ 'and token to this version in the dashboard.');
450
+ }
451
+ for (const p of args.ports) {
452
+ if (WS_PROTOCOLS.has(p.protocol.toUpperCase()) && !p.tls_upgrade) {
453
+ notes.push(`Port ${p.port} is WebSocket without tls_upgrade. If clients run in a browser (WebGL), ` +
454
+ 'they need wss://: create the version with tls_upgrade: true on this port.');
455
+ }
456
+ }
370
457
  return ok({
371
458
  created: `${args.application}/${res.version?.name ?? args.name}`,
372
459
  max_duration_minutes: capped,
373
460
  capped_by_server: capped < requested ? config.maxDurationCeiling : undefined,
461
+ notes: notes.length ? notes : undefined,
374
462
  next_step: 'Call edgegap_deploy to start an instance.',
375
463
  });
376
464
  }));
@@ -400,7 +488,7 @@ export function registerTools(server, client, config, auth) {
400
488
  memory_mb: z.number().int().min(256).optional().describe('Override the version memory.'),
401
489
  },
402
490
  annotations: { destructiveHint: false, idempotentHint: false, openWorldHint: true },
403
- }, async (args) => guard(auth, async () => {
491
+ }, async (args) => guarded(auth, NOT_FOUND.app, async () => {
404
492
  assertAppAllowed(config, args.application);
405
493
  const users = buildUsers(args.users);
406
494
  if (users.length === 0) {
@@ -441,7 +529,7 @@ export function registerTools(server, client, config, auth) {
441
529
  request_id: z.string().describe('The request_id returned by edgegap_deploy.'),
442
530
  },
443
531
  annotations: { readOnlyHint: true, openWorldHint: true },
444
- }, async ({ request_id }) => guard(auth, async () => {
532
+ }, async ({ request_id }) => guarded(auth, NOT_FOUND.deployment, async () => {
445
533
  const d = await client.getDeployment(request_id);
446
534
  return ok(compactDeployment(d));
447
535
  }));
@@ -463,7 +551,7 @@ export function registerTools(server, client, config, auth) {
463
551
  .describe('How long to wait before giving up. Default 180.'),
464
552
  },
465
553
  annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
466
- }, async ({ request_id, timeout_seconds }) => guard(auth, async () => {
554
+ }, async ({ request_id, timeout_seconds }) => guarded(auth, NOT_FOUND.deployment, async () => {
467
555
  const budgetMs = (timeout_seconds ?? 180) * 1000;
468
556
  const startedAt = Date.now();
469
557
  let intervalMs = 2000;
@@ -554,7 +642,7 @@ export function registerTools(server, client, config, auth) {
554
642
  request_id: z.string().describe('The request_id of the deployment to stop.'),
555
643
  },
556
644
  annotations: { destructiveHint: true, idempotentHint: true, openWorldHint: true },
557
- }, async ({ request_id }) => guard(auth, async () => {
645
+ }, async ({ request_id }) => guarded(auth, NOT_FOUND.deployment, async () => {
558
646
  const res = await client.stopDeployment(request_id);
559
647
  return ok({ request_id, result: res.message ?? 'stop requested' });
560
648
  }));
@@ -577,7 +665,7 @@ export function registerTools(server, client, config, auth) {
577
665
  .describe('Truncate logs to this length, keeping the tail. Default 8000.'),
578
666
  },
579
667
  annotations: { readOnlyHint: true, openWorldHint: true },
580
- }, async ({ request_id, max_characters }) => guard(auth, async () => {
668
+ }, async ({ request_id, max_characters }) => guarded(auth, NOT_FOUND.logs, async () => {
581
669
  const res = await client.getDeploymentLogs(request_id);
582
670
  const cap = max_characters ?? 8000;
583
671
  const tail = (s) => !s ? undefined : s.length > cap ? `...[truncated]...\n${s.slice(-cap)}` : s;
@@ -624,6 +712,7 @@ export function registerTools(server, client, config, auth) {
624
712
  port: z.number().int().min(1).max(59999),
625
713
  protocol: z.enum(PROTOCOLS),
626
714
  name: z.string().optional(),
715
+ tls_upgrade: z.boolean().optional().describe('TLS Upgrade (wss/https) on a WS or HTTP port, for browser clients.'),
627
716
  }))
628
717
  .optional()
629
718
  .describe('Ports the server listens on. Default: 7777, with the protocol the netcode uses (UDP if unknown).'),
@@ -708,6 +797,7 @@ export function registerTools(server, client, config, auth) {
708
797
  port: z.number().int(),
709
798
  protocol: z.string(),
710
799
  name: z.string().optional(),
800
+ tls_upgrade: z.boolean().optional().describe('TLS Upgrade (wss/https) on a WS or HTTP port, for browser clients.'),
711
801
  }))
712
802
  .optional()
713
803
  .describe('Ports you plan to pass to edgegap_create_app_version.'),
@@ -752,13 +842,16 @@ export function registerTools(server, client, config, auth) {
752
842
  if (mutating) {
753
843
  server.registerTool('edgegap_get_registry_credentials', {
754
844
  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.',
845
+ description: 'Get the push login for this organization\'s private Edgegap container registry ' +
846
+ '(registry.edgegap.com) and the exact docker login, build and push commands for your ' +
847
+ 'image. Use this when the server image is not in a registry yet. Edgegap only hands ' +
848
+ 'these credentials to the quick-start token the Unity/Unreal plugins use; with a ' +
849
+ 'regular API token this tool cannot fetch them and instead returns the steps to copy ' +
850
+ 'them from the dashboard\'s Container Registry page — ask the developer for them then, ' +
851
+ 'do not retry. When it does return a token, it is registry-scoped (push/pull images in ' +
852
+ 'this project), not the org API token: pass it to docker login via --password-stdin, ' +
853
+ 'never as a command-line argument, and do not write it into files. Call ' +
854
+ 'edgegap_validate_server_config before building.',
762
855
  inputSchema: {
763
856
  image_name: z
764
857
  .string()
@@ -775,24 +868,35 @@ export function registerTools(server, client, config, auth) {
775
868
  if (tag === 'latest') {
776
869
  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
870
  }
871
+ // Both wizard endpoints answer 403 to a regular API token: they belong
872
+ // to the plugins' quick-start flow. 403 is the token type, not a
873
+ // missing registry, so it must not trigger provisioning (which only
874
+ // fails with a second, more confusing 403). Only a 404 — a
875
+ // quick-start token whose project is not provisioned yet — does.
876
+ const unavailable = () => fail(registryCredentialsUnavailable(image_name, tag));
778
877
  let creds;
779
878
  try {
780
879
  creds = await client.getRegistryCredentials();
781
880
  }
782
881
  catch (err) {
783
- if (!(err instanceof EdgegapApiError) || err.status === 401)
882
+ if (!(err instanceof EdgegapApiError))
883
+ throw err;
884
+ if (err.status === 403)
885
+ return unavailable();
886
+ if (err.status !== 404)
784
887
  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');
888
+ try {
889
+ await client.initQuickStart('mcp');
890
+ }
891
+ catch (initErr) {
892
+ if (initErr instanceof EdgegapApiError && initErr.status === 403)
893
+ return unavailable();
894
+ throw initErr;
895
+ }
788
896
  creds = await client.getRegistryCredentials();
789
897
  }
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
- }
898
+ if (!creds.project || !creds.username || !creds.token)
899
+ return unavailable();
796
900
  const host = (creds.registry_url || 'registry.edgegap.com').replace(/^https?:\/\//, '').replace(/\/$/, '');
797
901
  const image = image_name ?? '<image-name>';
798
902
  const buildTag = tag ?? '<unique-build-tag>';
@@ -817,7 +921,7 @@ export function registerTools(server, client, config, auth) {
817
921
  },
818
922
  next_step: 'Export the token as EDGEGAP_REGISTRY_TOKEN in the shell that runs docker login ' +
819
923
  '(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}"), ` +
924
+ `Confirm the push with edgegap_list_registry_tags (image_name "${image}", without the project), ` +
821
925
  'then call edgegap_create_app_version with the values in for_create_app_version.',
822
926
  });
823
927
  }));
@@ -831,23 +935,65 @@ export function registerTools(server, client, config, auth) {
831
935
  inputSchema: {
832
936
  image_name: z
833
937
  .string()
834
- .describe('"<project>/<image>", e.g. "my-org-cv2l3w3vy6fg/my-game-server". Project comes from edgegap_get_registry_credentials.'),
938
+ .min(1)
939
+ .describe('The image name only, without the project, registry host or tag, e.g. "my-game-server". ' +
940
+ 'The API reads the project from your token; "<project>/my-game-server" is not found.'),
835
941
  page: z.number().int().min(1).optional(),
836
942
  limit: z.number().int().min(1).max(100).optional().describe('Default 20.'),
837
943
  },
838
944
  annotations: { readOnlyHint: true, openWorldHint: true },
839
945
  }, 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}".`);
946
+ // Agents often pass the full reference they pushed. Reduce it to what
947
+ // the API wants: no "registry.edgegap.com/" host, no ":tag".
948
+ const parts = image_name.replace(/@sha256:.*$/, '').split('/');
949
+ if (parts.length > 1 && /[.:]/.test(parts[0]))
950
+ parts.shift();
951
+ parts[parts.length - 1] = parts[parts.length - 1].replace(/:[^:]*$/, '');
952
+ let name = parts.join('/');
953
+ const query = { page, limit: limit ?? 20 };
954
+ const notFound = (err) => err instanceof EdgegapApiError && err.status === 404;
955
+ let res;
956
+ try {
957
+ try {
958
+ res = await client.listRegistryTags(name, query);
959
+ }
960
+ catch (err) {
961
+ // Nested image names are valid, so try the name as given first. If
962
+ // it is "<project>/<image>", that 404s; retry without the project.
963
+ if (!notFound(err) || !name.includes('/'))
964
+ throw err;
965
+ name = name.slice(name.indexOf('/') + 1);
966
+ res = await client.listRegistryTags(name, query);
967
+ }
968
+ }
969
+ catch (err) {
970
+ // The generic 404 hint points at applications, which is wrong here.
971
+ if (!notFound(err))
972
+ throw err;
973
+ return fail(`No image named "${name}" in this organization's Edgegap registry, so nothing has been ` +
974
+ 'pushed under that name. Check the name (image name only, as used after ' +
975
+ '"registry.edgegap.com/<project>/" in docker push), or push the image first.');
842
976
  }
843
- const res = await client.listRegistryTags(image_name, { page, limit: limit ?? 20 });
844
977
  const tags = (res.data ?? []).map((t) => ({
845
978
  tag: t.tag,
846
979
  pushed: t.last_push_at,
847
980
  size_mb: t.artifact?.size_mb,
848
981
  digest: t.artifact?.image_hash,
849
982
  }));
850
- return ok({ image_name, ...pageInfo(res.total_count, tags.length, page ?? 1), tags });
983
+ const hasNext = res.pagination?.has_next === true;
984
+ return ok({
985
+ image_name: name,
986
+ note: name !== image_name ? `Looked up "${name}". Pass the image name only next time.` : undefined,
987
+ total: res.count ?? tags.length,
988
+ ...(hasNext
989
+ ? {
990
+ showing: tags.length,
991
+ truncated: true,
992
+ next_step: `Only page ${page ?? 1} is shown. Call again with page: ${(page ?? 1) + 1} before concluding a tag is missing.`,
993
+ }
994
+ : {}),
995
+ tags,
996
+ });
851
997
  }));
852
998
  // ================================================== peer-to-peer relays ====
853
999
  // --------------------------------------------------------------- 14 ----
@@ -916,7 +1062,7 @@ export function registerTools(server, client, config, auth) {
916
1062
  'waits for readiness; use this to re-read a session or one created with wait_until_ready false.',
917
1063
  inputSchema: { session_id: z.string().describe('Returned by edgegap_create_relay_session.') },
918
1064
  annotations: { readOnlyHint: true, openWorldHint: true },
919
- }, async ({ session_id }) => guard(auth, async () => ok(compactRelay(await client.getRelaySession(session_id)))));
1065
+ }, async ({ session_id }) => guarded(auth, NOT_FOUND.relay, async () => ok(compactRelay(await client.getRelaySession(session_id)))));
920
1066
  if (mutating) {
921
1067
  // ------------------------------------------------------------- 16 ----
922
1068
  server.registerTool('edgegap_authorize_relay_user', {
@@ -928,7 +1074,7 @@ export function registerTools(server, client, config, auth) {
928
1074
  user_ip: z.string().min(3).describe('Public IP of the joining player.'),
929
1075
  },
930
1076
  annotations: { destructiveHint: false, idempotentHint: true, openWorldHint: true },
931
- }, async ({ session_id, user_ip }) => guard(auth, async () => {
1077
+ }, async ({ session_id, user_ip }) => guarded(auth, NOT_FOUND.relay, async () => {
932
1078
  const res = await client.authorizeRelayUser({ session_id, user_ip });
933
1079
  return ok({
934
1080
  session_id: res.session_id,
@@ -944,7 +1090,7 @@ export function registerTools(server, client, config, auth) {
944
1090
  'session you created for testing before ending your task.',
945
1091
  inputSchema: { session_id: z.string() },
946
1092
  annotations: { destructiveHint: true, idempotentHint: true, openWorldHint: true },
947
- }, async ({ session_id }) => guard(auth, async () => {
1093
+ }, async ({ session_id }) => guarded(auth, NOT_FOUND.relay, async () => {
948
1094
  await client.deleteRelaySession(session_id);
949
1095
  return ok({ session_id, result: 'deleted' });
950
1096
  }));
@@ -988,9 +1134,15 @@ export function registerTools(server, client, config, auth) {
988
1134
  ticket_expiration: z.string().optional().describe('Default "5m".'),
989
1135
  inspect: z.boolean().optional().describe('Expose the inspection API for debugging. Default true; turn off for production.'),
990
1136
  verify_version: z.boolean().optional().describe('Look up the application version first. Default true.'),
1137
+ allowed_cors_origins: z
1138
+ .array(z.string())
1139
+ .optional()
1140
+ .describe('Origins of web pages allowed to call the matchmaker, e.g. ["https://mygame.example.com", ' +
1141
+ '"http://localhost:8080"]. Required when game clients run in a browser (WebGL): browsers ' +
1142
+ 'block matchmaker calls from any origin not listed. Scheme and host only, no path.'),
991
1143
  },
992
1144
  annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
993
- }, async (args) => guard(auth, async () => {
1145
+ }, async (args) => guarded(auth, NOT_FOUND.app, async () => {
994
1146
  assertAppAllowed(config, args.application);
995
1147
  const { config: mmConfig, problems, cautions } = buildMatchmakerConfig(args);
996
1148
  if (args.verify_version !== false) {
@@ -1031,10 +1183,59 @@ export function registerTools(server, client, config, auth) {
1031
1183
  'The dashboard then shows the matchmaker API URL and auth token. Game clients call POST {api_url}/tickets ' +
1032
1184
  `with header "Authorization: <auth token>" and profile "${args.profile_name}", then poll GET {api_url}/memberships/{id} until it returns the server address.`,
1033
1185
  'That auth token is safe to ship in game clients: it grants no access to the Edgegap API.',
1186
+ args.allowed_cors_origins?.length
1187
+ ? `Browser clients are allowed from: ${args.allowed_cors_origins.join(', ')}. Add any other origin the game is served from (each staging or production URL) before uploading.`
1188
+ : 'If game clients run in a browser (WebGL), set allowed_cors_origins to the origin of every page that serves the game, including http://localhost:<port> for local testing, or browsers will block the matchmaker calls.',
1034
1189
  ],
1035
1190
  });
1036
1191
  }));
1037
1192
  }
1193
+ /**
1194
+ * What edgegap_get_registry_credentials says when Edgegap will not hand the
1195
+ * registry login to this token. Written as the manual path that works today,
1196
+ * so the agent asks the developer instead of retrying or guessing.
1197
+ */
1198
+ function registryCredentialsUnavailable(imageName, tag) {
1199
+ const image = imageName ?? '<image-name>';
1200
+ const buildTag = tag ?? '<unique-build-tag>';
1201
+ const ref = `registry.edgegap.com/<project>/${image}:${buildTag}`;
1202
+ return ('Edgegap does not give container registry credentials to a regular API token: the ' +
1203
+ 'endpoint only accepts the quick-start token the Unity/Unreal plugins use (it answered ' +
1204
+ '403). This is the token type, not a problem with the registry. Do not retry. Ask the ' +
1205
+ 'developer for the registry login instead:\n\n' +
1206
+ `1. In the dashboard (${DASHBOARD_URL}), open the Container Registry page and copy the ` +
1207
+ 'Project, Username and Token.\n' +
1208
+ '2. Log in with the token read from an environment variable, never as an argument:\n' +
1209
+ ` printf '%s' "$EDGEGAP_REGISTRY_TOKEN" | docker login registry.edgegap.com -u '<username>' --password-stdin\n` +
1210
+ `3. docker build --platform linux/amd64 -t ${ref} .\n` +
1211
+ `4. docker push ${ref}\n` +
1212
+ `5. Confirm with edgegap_list_registry_tags (image_name "${image}", without the project).\n` +
1213
+ '6. Call edgegap_create_app_version with docker_repository "registry.edgegap.com", ' +
1214
+ `docker_image "<project>/${image}", docker_tag "${buildTag}", and the same username and ` +
1215
+ 'token as registry_username/registry_token.\n\n' +
1216
+ 'Or push to any other registry Edgegap can pull from (Docker Hub, GHCR, ECR, GCR, GitLab) ' +
1217
+ 'and pass its registry_username/registry_token to edgegap_create_app_version.');
1218
+ }
1219
+ /**
1220
+ * What edgegap_create_app_version says when Edgegap could not log in to the
1221
+ * registry to verify the image. The agent should not be handed the registry
1222
+ * login just to get past this, so the dashboard route comes first.
1223
+ */
1224
+ function registryLoginNeeded(repository, hadLogin) {
1225
+ return (`Edgegap could not log in to ${repository} to verify the image, so the version was not ` +
1226
+ 'created. ' +
1227
+ (hadLogin
1228
+ ? 'The registry_username/registry_token given were rejected: check them.'
1229
+ : 'Edgegap pulls images with a registry login set on the version, not your API token — ' +
1230
+ 'this applies to your own registry.edgegap.com project too.') +
1231
+ '\n\nOptions:\n' +
1232
+ '1. Create the version again with verify_image false, then have the developer open it in ' +
1233
+ `the dashboard (${DASHBOARD_URL}) and add the registry username and token (for ` +
1234
+ 'registry.edgegap.com, the ones on the Container Registry page). Deployments fail to pull ' +
1235
+ 'until they do.\n' +
1236
+ '2. If the developer chooses to give them to you, pass registry_username and registry_token. ' +
1237
+ 'They are registry-scoped, not the org API token. Do not write them into files.');
1238
+ }
1038
1239
  /** Trims a relay session down to what a game client integration needs. */
1039
1240
  function compactRelay(s) {
1040
1241
  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.3",
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",
@@ -35,13 +35,13 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@modelcontextprotocol/sdk": "^1.30.0",
38
- "@modelcontextprotocol/server": "^2.0.0",
39
- "agents": "^0.23.0",
40
38
  "zod": "^4.6.2"
41
39
  },
42
40
  "devDependencies": {
43
41
  "@cloudflare/workers-types": "^5.20260911.1",
42
+ "@modelcontextprotocol/server": "^2.0.0",
44
43
  "@types/node": "^22.20.2",
44
+ "agents": "^0.23.0",
45
45
  "typescript": "^7.0.2",
46
46
  "wrangler": "^4.131.1"
47
47
  },