@edgegap/mcp 0.2.0 → 0.2.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
@@ -1,303 +1,341 @@
1
- # edgegap-mcp
2
-
3
- An MCP server for Edgegap that lets a coding agent take a developer from "I
4
- have a headless server build" to "players are connected to it" without the
5
- developer reading the API reference: checking the Dockerfile and ports, pushing
6
- to Edgegap's registry, deploying, and — for peer-to-peer games — opening a relay
7
- instead.
8
-
9
- Eighteen tools, hand-picked. Not generated from the OpenAPI spec — see
10
- [Design decisions](#design-decisions) for why.
11
-
12
- ## Install
13
-
14
- Two ways to run it. Pick based on how much you care about where your token
15
- goes — see [Where your token goes](#where-your-token-goes).
16
-
17
- ### Remote endpoint
18
-
19
- Hosted by Edgegap as a Cloudflare Worker. Nothing to install.
20
-
21
- ```json
22
- {
23
- "mcpServers": {
24
- "edgegap": {
25
- "type": "http",
26
- "url": "https://mcp.edgegap.dev/mcp",
27
- "headers": { "Authorization": "token YOUR_API_TOKEN" }
28
- }
29
- }
30
- }
31
- ```
32
-
33
- Also works as a custom connector in claude.ai: add
34
- `https://mcp.edgegap.dev/mcp` and supply the same token.
35
-
36
- ### Local
37
-
38
- Runs on your own machine, spawned by your editor. One line in your MCP client
39
- config, nothing to clone, nothing to build.
40
-
41
- ```json
42
- {
43
- "mcpServers": {
44
- "edgegap": {
45
- "command": "npx",
46
- "args": ["-y", "@edgegap/mcp"]
47
- }
48
- }
49
- }
50
- ```
51
-
52
- Works in Claude Code, Cursor, Codex, and VS Code. Pin a version in production
53
- (`@edgegap/mcp@0.1.5`) rather than floating on latest.
54
-
55
- Registered in the official MCP registry as `dev.edgegap/mcp`.
56
-
57
- > **Node version:** the local server needs Node 18+. Deploying your own copy of
58
- > the Cloudflare Worker needs Node 22+, because `wrangler` requires it.
59
-
60
- ## Where your token goes
61
-
62
- This differs by mode, and the difference is the reason both modes exist.
63
-
64
- **Local.** The server runs as a process on your own computer. The first tool
65
- call asks you for a token, shows what it authorises, and requires an explicit
66
- acknowledgement before accepting it. Where that token then lives, exhaustively:
67
-
68
- - one variable in that process's memory, for the life of your editor session
69
-
70
- That is the whole list. Not on disk. Not in a config file. Not in logs. Not on
71
- any Edgegap server — the only thing sent to Edgegap is the API call itself,
72
- exactly as if you had run `curl`. Closing your editor revokes this server's
73
- access completely.
74
-
75
- **Remote.** Your token is sent to `mcp.edgegap.dev` on every request and
76
- forwarded from there to the Edgegap API. It transits infrastructure Edgegap
77
- operates. The worker holds it for the life of the request and does not persist
78
- it, but that is a "we don't store it" claim rather than a "we never see it"
79
- claim. The two are different, and only local mode makes the second one.
80
-
81
- Generate a token at <https://app.edgegap.com/user-settings?tab=tokens>.
82
-
83
- In local mode, setting `EDGEGAP_API_TOKEN` takes precedence over the prompt,
84
- for CI and for clients that cannot show prompts. Do not pass a token as a
85
- command-line argument — arguments are visible to other processes via `ps`, and
86
- the server warns if it detects one.
87
-
88
- **Which to use.** Remote for a first try, a demo, or a supervised session where
89
- setup friction matters more than custody. Local for anything unattended,
90
- anything in an organization with a live game in it, and anything where you
91
- would rather not extend trust you don't have to. The guardrails described below
92
- exist only in local mode.
93
-
94
- ## Read this before connecting an agent
95
-
96
- **The Edgegap API token cannot be scoped.** One token authorises every
97
- application, every version, every running deployment, and your usage across the
98
- whole organization. There is no deploy-only token and no per-application token.
99
-
100
- Consequences worth being deliberate about:
101
-
102
- - An agent holding this token can stop production deployments, not just the
103
- test ones it created.
104
- - Prompt injection reaching the agent — from a repo file, an issue, a fetched
105
- page — reaches the token too.
106
- - Anything the agent logs, echoes, or sends to a model provider is a place the
107
- token could end up. This server does not log it, but it cannot control what
108
- the rest of the agent does.
109
- - On the remote endpoint, the same unscoped token is additionally handled by
110
- Edgegap's worker on every call.
111
-
112
- Recommended setup, in decreasing order of caution:
113
-
114
- | Situation | Setup |
115
- | --- | --- |
116
- | Unattended or autonomous agent | Local mode. Separate non-production organization, plus `EDGEGAP_READ_ONLY=1` |
117
- | Supervised agent, live game in the org | Local mode. `EDGEGAP_APP_ALLOWLIST` scoped to the app being worked on, plus `EDGEGAP_MAX_DURATION_MINUTES`. Read [Scope of the allowlist](#scope-of-the-allowlist) first — deployments that are already running are not covered |
118
- | Solo developer, no production workload | Either mode. Defaults are fine; revoke the token when finished |
119
-
120
- The allowlist and read-only flag are enforced in the local server, which means
121
- they protect against an agent that makes a mistake, not against one that has
122
- been compromised into calling the API directly. They narrow the blast radius;
123
- they do not remove it.
124
-
125
- ### Scope of the allowlist
126
-
127
- `EDGEGAP_APP_ALLOWLIST` is enforced by the five tools that take an application
128
- name: `edgegap_create_app`, `edgegap_list_app_versions`,
129
- `edgegap_create_app_version`, `edgegap_deploy`, and
130
- `edgegap_build_matchmaker_config`.
131
-
132
- Relay sessions and the container registry belong to the organization, not to an
133
- application, so the relay and registry tools are not covered by it either.
134
-
135
- It is **not** enforced by the five tools keyed on `request_id`:
136
- `edgegap_get_deployment`, `edgegap_wait_for_deployment`,
137
- `edgegap_list_deployments`, `edgegap_stop_deployment`, and
138
- `edgegap_get_deployment_logs`. An agent running with an allowlist set can list
139
- every deployment in the organization and then inspect, read the logs of, or stop
140
- any of them — including deployments belonging to applications outside the list.
141
-
142
- So the allowlist scopes what an agent can **create and deploy into**, not what it
143
- can **touch once running**. That is narrower than earlier versions of this
144
- document implied.
145
-
146
- For a stronger guarantee today, use `EDGEGAP_READ_ONLY=1`, which never registers
147
- the mutating tools at all, or point the agent at a separate non-production
148
- organization. Both are unaffected by this gap.
149
-
150
- Reported by Syed Anas Mohiuddin, September 2026.
151
-
152
- ### Environment variables
153
-
154
- These configure the local server. On the remote endpoint they are set by
155
- Edgegap and cannot be changed per developer — if you need any of them, run
156
- locally.
157
-
158
- | Variable | Default | Purpose |
159
- | --- | --- | --- |
160
- | `EDGEGAP_API_TOKEN` | *(prompted)* | API token. Optional — omit it and the developer is asked at first use. The `token ` prefix is added for you. |
161
- | `EDGEGAP_READ_ONLY` | `0` | Set to `1` and the eight mutating tools (●, below) are never registered. The agent cannot see them, so it cannot be talked into calling them. |
162
- | `EDGEGAP_APP_ALLOWLIST` | *(empty)* | Comma-separated application names. When set, the five application-keyed tools refuse to touch anything else. Does **not** scope the five `request_id`-keyed tools — see [Scope of the allowlist](#scope-of-the-allowlist). |
163
- | `EDGEGAP_MAX_DURATION_MINUTES` | `60` | Ceiling on `max_duration` the agent may set on a version. Caps runaway cost from an unattended agent. |
164
- | `EDGEGAP_TIMEOUT_MS` | `30000` | Per-request HTTP timeout. |
165
-
166
- ## Tools
167
-
168
- Eighteen tools, grouped by where they fall on the path. The same set in both
169
- modes; `EDGEGAP_READ_ONLY=1` hides the ● ones.
170
-
171
- **Before the first deploy** — getting a headless build into a correct image and
172
- into a registry, which is where agent-driven onboarding actually stalls.
173
-
174
- | Tool | Mutating | What it's for |
175
- | --- | --- | --- |
176
- | `edgegap_validate_server_config` | | Static check of a Dockerfile, ports, resources and tag against Edgegap's requirements: linux/amd64, Unreal not running as root, Unity `-batchmode -nographics`, loopback binds, EXPOSE vs. version ports, protocol vs. netcode transport, `latest` tags. Returns Edgegap's reference Unity/Unreal Dockerfile when there is none yet or it fails. No API call. |
177
- | `edgegap_get_registry_credentials` | ● | Push credentials for the org's private `registry.edgegap.com` project, plus the exact login/build/push commands and the values to pass to `edgegap_create_app_version`. Provisions the project on first use. |
178
- | `edgegap_list_registry_tags` | | Confirm a pushed tag landed before registering it. |
179
-
180
- **Dedicated servers** — the original golden path.
181
-
182
- | Tool | Mutating | What it's for |
183
- | --- | --- | --- |
184
- | `edgegap_list_apps` | | Orient before doing anything. Prevents duplicate applications. |
185
- | `edgegap_create_app` | ● | Create the container for versions. |
186
- | `edgegap_list_app_versions` | | Find a deployable version, or copy settings from a working one. |
187
- | `edgegap_create_app_version` | ● | Register a container image with CPU, memory, and ports. |
188
- | `edgegap_deploy` | ● | Start one instance near specified players. |
189
- | `edgegap_get_deployment` | | Single status read. |
190
- | `edgegap_wait_for_deployment` | | Poll to ready with backoff, then return the connection address. |
191
- | `edgegap_list_deployments` | | Find orphaned servers from earlier sessions. |
192
- | `edgegap_stop_deployment` | ● | Graceful SIGTERM, one deployment at a time. |
193
- | `edgegap_get_deployment_logs` | | Container output and crash exit code after a failure. |
194
-
195
- **Peer-to-peer relays** — for co-op and host-client games, which need no server
196
- image at all.
197
-
198
- | Tool | Mutating | What it's for |
199
- | --- | --- | --- |
200
- | `edgegap_create_relay_session` | ● | Open a relay session for a set of player IPs, wait until it is ready, and return the relay address, ports, and per-player authorization tokens. |
201
- | `edgegap_get_relay_session` | | Re-read a session. |
202
- | `edgegap_authorize_relay_user` | ● | Add a player who joins after the session was created. |
203
- | `edgegap_delete_relay_session` | ● | Close a session. |
204
-
205
- **Matchmaking**
206
-
207
- | Tool | Mutating | What it's for |
208
- | --- | --- | --- |
209
- | `edgegap_build_matchmaker_config` | | Generate a basic matchmaker configuration (teams, team size, optional latency rule and expansions) checked against the application version it deploys. Edgegap has no API for creating a matchmaker, so the developer uploads the result in the dashboard. |
210
-
211
- ## Design decisions
212
-
213
- **Curated, not generated.** The Edgegap API has roughly sixty operations.
214
- Auto-generating one tool per operation puts all sixty descriptions into the
215
- agent's context on every turn and measurably degrades tool selection. These
216
- cover the path that converts a new developer — including the steps before the
217
- first deploy, which are where that path used to end.
218
-
219
- **`wait_for_deployment` is a tool, not a loop.** Left to itself an agent will
220
- call a status endpoint in a tight loop, burn turns, and give up early. Folding
221
- the polling and backoff into one call removes the most common failure in
222
- agent-driven deploys.
223
-
224
- **Errors are written for self-correction.** A 424 comes back saying the image
225
- could not be pulled and which fields to check. A 422 says to try different
226
- coordinates or lower the resource request. The agent can act on these without a
227
- round trip to the human.
228
-
229
- **Local validation before the wire.** The memory-to-CPU ratio and the missing
230
- player location are caught here rather than surfacing as an opaque 400.
231
- `edgegap_validate_server_config` extends this to the image itself, before a
232
- build and push are spent discovering a problem.
233
-
234
- **The registry token is handed to the agent; the API token never is.** The agent
235
- has to run `docker login`, so the registry token is returned in the tool result.
236
- It is scoped to the org's registry project, and the returned command reads it
237
- from an environment variable over `--password-stdin` so it stays off command
238
- lines and out of shell history. The tool is hidden in read-only mode.
239
-
240
- **The registry credentials endpoint is not in the public spec.** It is
241
- `GET /v1/wizard/registry-credentials`, the same call the Unity plugin makes,
242
- preceded by `POST /v1/wizard/init-quick-start` when the project is not yet
243
- provisioned.
244
-
245
- **Bulk operations are deliberately absent.** `stop` takes one `request_id`.
246
- There is no bulk-stop tool, because an agent with a filter expression and a bug
247
- can stop a production fleet.
248
-
249
- **Both a hosted endpoint and a local package.** The hosted endpoint removes
250
- every step between finding this server and calling a tool, which is where most
251
- developers drop out. The local package is the only way to run the server
252
- without extending custody of an unscoped token to a third party, including us.
253
- Neither one dominates the other, so both ship. See `worker/DECISION.md` for the
254
- longer version.
255
-
256
- ## Scope
257
-
258
- Not exposed, on purpose: private fleets, smart fleets, endpoint storage,
259
- ACL/whitelist entries, deployment tags, metrics, registry tag deletion, DNS
260
- configuration, and matchmaker lifecycle (start, stop, delete).
261
-
262
- These belong to studios already operating on the platform, not to a developer
263
- getting a first game online. Relays, registry push, and a basic matchmaker
264
- config were moved in scope because agents hit them before the first deploy,
265
- not after.
266
-
267
- ## Known limitation: asking for the token at all
268
-
269
- This applies to local mode, where the token is collected through elicitation
270
- rather than read from config.
271
-
272
- The MCP specification says servers should not use elicitation to collect
273
- sensitive data, and an API token is sensitive. This server does it anyway,
274
- because requiring a token in a config file before anything works is the largest
275
- drop in the onboarding funnel, and the whole point of the server is to remove
276
- setup friction.
277
-
278
- That is a deliberate trade rather than a pattern to copy. What makes it
279
- defensible is the set of mitigations in `src/auth.ts` — memory-only storage,
280
- plain-language disclosure, required acknowledgement, redaction from all output,
281
- and the environment variable always winning when present. Removing any of them
282
- breaks the trade.
283
-
284
- The real fix is on Edgegap's side and would improve both modes: scoped,
285
- revocable, deploy-only credentials, issued through OAuth rather than pasted as
286
- a secret. Until those exist, the interactive prompt is a workaround and is
287
- labelled as one in the code.
288
-
289
- ## Development
290
-
291
- ```bash
292
- npm run typecheck
293
- node smoke.mjs # handshake, tool registration, read-only mode
294
- node guards.mjs # local validation and allowlist enforcement
295
- node elicit.mjs # token prompt: accept, refuse acknowledgement, decline, no support
296
- node newtools.mjs # validator, registry, relay, matchmaker tools against a local mock API
297
- ```
298
-
299
- None of these reach Edgegap. `newtools.mjs` points `EDGEGAP_BASE_URL` at a
300
- mock server on localhost. `elicit.mjs` asserts that the prompt states
301
- the org-wide scope, that the acknowledgement is required, that the token never
302
- appears in tool output, and that declining produces a stop-and-report message
303
- rather than a retry loop.
1
+ # edgegap-mcp
2
+
3
+ An MCP server for Edgegap that lets a coding agent take a developer from "I
4
+ have a headless server build" to "players are connected to it" without the
5
+ developer reading the API reference: writing and checking the Dockerfile,
6
+ pushing to Edgegap's registry, and deploying an authoritative dedicated server.
7
+ Relays are there too, for games built host-client, but they are not the default
8
+ — see [Dedicated servers vs relays](#dedicated-servers-vs-relays).
9
+
10
+ Nineteen tools, hand-picked. Not generated from the OpenAPI spec — see
11
+ [Design decisions](#design-decisions) for why.
12
+
13
+ ## Install
14
+
15
+ Two ways to run it. Pick based on how much you care about where your token
16
+ goes — see [Where your token goes](#where-your-token-goes).
17
+
18
+ ### Remote endpoint
19
+
20
+ Hosted by Edgegap as a Cloudflare Worker. Nothing to install.
21
+
22
+ ```json
23
+ {
24
+ "mcpServers": {
25
+ "edgegap": {
26
+ "type": "http",
27
+ "url": "https://mcp.edgegap.dev/mcp",
28
+ "headers": { "Authorization": "token YOUR_API_TOKEN" }
29
+ }
30
+ }
31
+ }
32
+ ```
33
+
34
+ Also works as a custom connector in claude.ai: add
35
+ `https://mcp.edgegap.dev/mcp` and supply the same token.
36
+
37
+ ### Local
38
+
39
+ Runs on your own machine, spawned by your editor. One line in your MCP client
40
+ config, nothing to clone, nothing to build.
41
+
42
+ ```json
43
+ {
44
+ "mcpServers": {
45
+ "edgegap": {
46
+ "command": "npx",
47
+ "args": ["-y", "@edgegap/mcp"]
48
+ }
49
+ }
50
+ }
51
+ ```
52
+
53
+ Works in Claude Code, Cursor, Codex, and VS Code. Pin a version in production
54
+ (`@edgegap/mcp@0.1.5`) rather than floating on latest.
55
+
56
+ Registered in the official MCP registry as `dev.edgegap/mcp`.
57
+
58
+ > **Node version:** the local server needs Node 18+. Deploying your own copy of
59
+ > the Cloudflare Worker needs Node 22+, because `wrangler` requires it.
60
+
61
+ ## Where your token goes
62
+
63
+ This differs by mode, and the difference is the reason both modes exist.
64
+
65
+ **Local.** The server runs as a process on your own computer. The first tool
66
+ call asks you for a token, shows what it authorises, and requires an explicit
67
+ acknowledgement before accepting it. Where that token then lives, exhaustively:
68
+
69
+ - one variable in that process's memory, for the life of your editor session
70
+
71
+ That is the whole list. Not on disk. Not in a config file. Not in logs. Not on
72
+ any Edgegap server — the only thing sent to Edgegap is the API call itself,
73
+ exactly as if you had run `curl`. Closing your editor revokes this server's
74
+ access completely.
75
+
76
+ **Remote.** Your token is sent to `mcp.edgegap.dev` on every request and
77
+ forwarded from there to the Edgegap API. It transits infrastructure Edgegap
78
+ operates. The worker holds it for the life of the request and does not persist
79
+ it, but that is a "we don't store it" claim rather than a "we never see it"
80
+ claim. The two are different, and only local mode makes the second one.
81
+
82
+ Generate a token at <https://app.edgegap.com/user-settings?tab=tokens>.
83
+
84
+ In local mode, setting `EDGEGAP_API_TOKEN` takes precedence over the prompt,
85
+ for CI and for clients that cannot show prompts. Do not pass a token as a
86
+ command-line argument — arguments are visible to other processes via `ps`, and
87
+ the server warns if it detects one.
88
+
89
+ **Which to use.** Remote for a first try, a demo, or a supervised session where
90
+ setup friction matters more than custody. Local for anything unattended,
91
+ anything in an organization with a live game in it, and anything where you
92
+ would rather not extend trust you don't have to. The guardrails described below
93
+ exist only in local mode.
94
+
95
+ ## Read this before connecting an agent
96
+
97
+ **The Edgegap API token cannot be scoped.** One token authorises every
98
+ application, every version, every running deployment, and your usage across the
99
+ whole organization. There is no deploy-only token and no per-application token.
100
+
101
+ Consequences worth being deliberate about:
102
+
103
+ - An agent holding this token can stop production deployments, not just the
104
+ test ones it created.
105
+ - Prompt injection reaching the agent — from a repo file, an issue, a fetched
106
+ page — reaches the token too.
107
+ - Anything the agent logs, echoes, or sends to a model provider is a place the
108
+ token could end up. This server does not log it, but it cannot control what
109
+ the rest of the agent does.
110
+ - On the remote endpoint, the same unscoped token is additionally handled by
111
+ Edgegap's worker on every call.
112
+
113
+ Recommended setup, in decreasing order of caution:
114
+
115
+ | Situation | Setup |
116
+ | --- | --- |
117
+ | Unattended or autonomous agent | Local mode. Separate non-production organization, plus `EDGEGAP_READ_ONLY=1` |
118
+ | Supervised agent, live game in the org | Local mode. `EDGEGAP_APP_ALLOWLIST` scoped to the app being worked on, plus `EDGEGAP_MAX_DURATION_MINUTES`. Read [Scope of the allowlist](#scope-of-the-allowlist) first — deployments that are already running are not covered |
119
+ | Solo developer, no production workload | Either mode. Defaults are fine; revoke the token when finished |
120
+
121
+ The allowlist and read-only flag are enforced in the local server, which means
122
+ they protect against an agent that makes a mistake, not against one that has
123
+ been compromised into calling the API directly. They narrow the blast radius;
124
+ they do not remove it.
125
+
126
+ ### Scope of the allowlist
127
+
128
+ `EDGEGAP_APP_ALLOWLIST` is enforced by the five tools that take an application
129
+ name: `edgegap_create_app`, `edgegap_list_app_versions`,
130
+ `edgegap_create_app_version`, `edgegap_deploy`, and
131
+ `edgegap_build_matchmaker_config`.
132
+
133
+ Relay sessions and the container registry belong to the organization, not to an
134
+ application, so the relay and registry tools are not covered by it either.
135
+
136
+ It is **not** enforced by the five tools keyed on `request_id`:
137
+ `edgegap_get_deployment`, `edgegap_wait_for_deployment`,
138
+ `edgegap_list_deployments`, `edgegap_stop_deployment`, and
139
+ `edgegap_get_deployment_logs`. An agent running with an allowlist set can list
140
+ every deployment in the organization and then inspect, read the logs of, or stop
141
+ any of them — including deployments belonging to applications outside the list.
142
+
143
+ So the allowlist scopes what an agent can **create and deploy into**, not what it
144
+ can **touch once running**. That is narrower than earlier versions of this
145
+ document implied.
146
+
147
+ For a stronger guarantee today, use `EDGEGAP_READ_ONLY=1`, which never registers
148
+ the mutating tools at all, or point the agent at a separate non-production
149
+ organization. Both are unaffected by this gap.
150
+
151
+ Reported by Syed Anas Mohiuddin, September 2026.
152
+
153
+ ### Environment variables
154
+
155
+ These configure the local server. On the remote endpoint they are set by
156
+ Edgegap and cannot be changed per developer — if you need any of them, run
157
+ locally.
158
+
159
+ | Variable | Default | Purpose |
160
+ | --- | --- | --- |
161
+ | `EDGEGAP_API_TOKEN` | *(prompted)* | API token. Optional — omit it and the developer is asked at first use. The `token ` prefix is added for you. |
162
+ | `EDGEGAP_READ_ONLY` | `0` | Set to `1` and the eight mutating tools (●, below) are never registered. The agent cannot see them, so it cannot be talked into calling them. |
163
+ | `EDGEGAP_APP_ALLOWLIST` | *(empty)* | Comma-separated application names. When set, the five application-keyed tools refuse to touch anything else. Does **not** scope the five `request_id`-keyed tools — see [Scope of the allowlist](#scope-of-the-allowlist). |
164
+ | `EDGEGAP_MAX_DURATION_MINUTES` | `60` | Ceiling on `max_duration` the agent may set on a version. Caps runaway cost from an unattended agent. |
165
+ | `EDGEGAP_TIMEOUT_MS` | `30000` | Per-request HTTP timeout. |
166
+
167
+ ## Dedicated servers vs relays
168
+
169
+ Edgegap hosts multiplayer games two ways, and they are not interchangeable.
170
+ **This server recommends a dedicated server by default**, and tells the agent so
171
+ in its instructions, in the tool descriptions, and in every relay result.
172
+
173
+ | | Dedicated (authoritative) server | Relay |
174
+ | --- | --- | --- |
175
+ | What Edgegap runs | Your headless server build, near the players | Only a traffic forwarder; no game code |
176
+ | Who owns the game state | The server | One player's game (the host) |
177
+ | Cheating | Much harder: the server decides | The host can change anything |
178
+ | Fairness | Every player is one hop from the server | The host has zero latency; everyone else has two hops |
179
+ | Host quits | Match continues | Match ends, unless the game implements host migration |
180
+ | Limited by | The server's allocated CPU and memory | The host's PC and home upload bandwidth |
181
+ | Needs | A server image (`edgegap_generate_dockerfile` writes the Dockerfile) | Netcode built as a listen server (host-client) |
182
+ | Tools | `edgegap_deploy`, matchmaker | `edgegap_create_relay_session` |
183
+
184
+ Agents left alone tend to pick relays because they need no server image. That
185
+ saves the agent work, not the developer's game, so the relay tool tells the
186
+ agent to use it only when the developer has chosen host-client, or the netcode
187
+ is already a listen server and moving to a dedicated server is not an option —
188
+ and to ask when that is unclear.
189
+
190
+ ## Tools
191
+
192
+ Nineteen tools, grouped by where they fall on the path. The same set in both
193
+ modes; `EDGEGAP_READ_ONLY=1` hides the ● ones.
194
+
195
+ **Before the first deploy** — getting a headless build into a correct image and
196
+ into a registry, which is where agent-driven onboarding actually stalls.
197
+
198
+ | Tool | Mutating | What it's for |
199
+ | --- | --- | --- |
200
+ | `edgegap_generate_dockerfile` | | Write a Dockerfile for this project's build: its build folder, binary or start script, ports and launch arguments, with the right headless flags, non-root user (Unreal), CRLF fix for start scripts, and matching EXPOSE lines. Lists anything it had to assume, returns the ports for `edgegap_create_app_version`, and is checked against the validator before it is returned. Unity, Unreal, Godot, or any other engine. No API call. |
201
+ | `edgegap_validate_server_config` | | Static check of an existing Dockerfile, ports, resources and tag against Edgegap's requirements: linux/amd64, Unreal not running as root, Unity `-batchmode -nographics`, loopback binds, EXPOSE vs. version ports, protocol vs. netcode transport, `latest` tags. Returns a known-good Dockerfile for the engine when the one checked fails. No API call. |
202
+ | `edgegap_get_registry_credentials` | ● | Push credentials for the org's private `registry.edgegap.com` project, plus the exact login/build/push commands and the values to pass to `edgegap_create_app_version`. Provisions the project on first use. |
203
+ | `edgegap_list_registry_tags` | | Confirm a pushed tag landed before registering it. |
204
+
205
+ **Dedicated servers** — the recommended way to host a match.
206
+
207
+ | Tool | Mutating | What it's for |
208
+ | --- | --- | --- |
209
+ | `edgegap_list_apps` | | Orient before doing anything. Prevents duplicate applications. |
210
+ | `edgegap_create_app` | ● | Create the container for versions. |
211
+ | `edgegap_list_app_versions` | | Find a deployable version, or copy settings from a working one. |
212
+ | `edgegap_create_app_version` | ● | Register a container image with CPU, memory, and ports. |
213
+ | `edgegap_deploy` | ● | Start one authoritative server near specified players. |
214
+ | `edgegap_get_deployment` | | Single status read. |
215
+ | `edgegap_wait_for_deployment` | | Poll to ready with backoff, then return the connection address. |
216
+ | `edgegap_list_deployments` | | Find orphaned servers from earlier sessions. |
217
+ | `edgegap_stop_deployment` | ● | Graceful SIGTERM, one deployment at a time. |
218
+ | `edgegap_get_deployment_logs` | | Container output and crash exit code after a failure. |
219
+
220
+ **Matchmaking** — puts players into dedicated servers.
221
+
222
+ | Tool | Mutating | What it's for |
223
+ | --- | --- | --- |
224
+ | `edgegap_build_matchmaker_config` | | Generate a basic matchmaker configuration (teams, team size, optional latency rule and expansions) checked against the application version it deploys. Edgegap has no API for creating a matchmaker, so the developer uploads the result in the dashboard. |
225
+
226
+ **Relays** — only for games built host-client; not a game server. See
227
+ [Dedicated servers vs relays](#dedicated-servers-vs-relays).
228
+
229
+ | Tool | Mutating | What it's for |
230
+ | --- | --- | --- |
231
+ | `edgegap_create_relay_session` | ● | Open a relay session for a set of player IPs, wait until it is ready, and return the relay address, ports, and per-player authorization tokens, plus the trade-offs to raise with the developer. |
232
+ | `edgegap_get_relay_session` | | Re-read a session. |
233
+ | `edgegap_authorize_relay_user` | ● | Add a player who joins after the session was created. |
234
+ | `edgegap_delete_relay_session` | ● | Close a session. |
235
+
236
+ ## Design decisions
237
+
238
+ **Curated, not generated.** The Edgegap API has roughly sixty operations.
239
+ Auto-generating one tool per operation puts all sixty descriptions into the
240
+ agent's context on every turn and measurably degrades tool selection. These
241
+ cover the path that converts a new developer — including the steps before the
242
+ first deploy, which are where that path used to end.
243
+
244
+ **`wait_for_deployment` is a tool, not a loop.** Left to itself an agent will
245
+ call a status endpoint in a tight loop, burn turns, and give up early. Folding
246
+ the polling and backoff into one call removes the most common failure in
247
+ agent-driven deploys.
248
+
249
+ **Errors are written for self-correction.** A 424 comes back saying the image
250
+ could not be pulled and which fields to check. A 422 says to try different
251
+ coordinates or lower the resource request. The agent can act on these without a
252
+ round trip to the human.
253
+
254
+ **Local validation before the wire.** The memory-to-CPU ratio and the missing
255
+ player location are caught here rather than surfacing as an opaque 400.
256
+ `edgegap_validate_server_config` extends this to the image itself, before a
257
+ build and push are spent discovering a problem.
258
+
259
+ **Generated Dockerfiles are validated before they are returned.**
260
+ `edgegap_generate_dockerfile` runs its own output through
261
+ `edgegap_validate_server_config` and refuses to return anything that fails, so
262
+ the two tools cannot disagree. Every value it writes into the Dockerfile (paths,
263
+ binary name, launch arguments) is restricted to characters that cannot start a
264
+ new instruction or escape into a shell. The Unity template leaves out the `env`
265
+ dump from Edgegap's plugin Dockerfile, which writes hidden environment variables
266
+ into container logs.
267
+
268
+ **The same instructions on both transports.** The hosted Worker used to start
269
+ without server instructions, so hosted agents never saw the golden path. Both
270
+ entry points now use `serverInstructions()` from `src/tools.ts`.
271
+
272
+ **The registry token is handed to the agent; the API token never is.** The agent
273
+ has to run `docker login`, so the registry token is returned in the tool result.
274
+ It is scoped to the org's registry project, and the returned command reads it
275
+ from an environment variable over `--password-stdin` so it stays off command
276
+ lines and out of shell history. The tool is hidden in read-only mode.
277
+
278
+ **The registry credentials endpoint is not in the public spec.** It is
279
+ `GET /v1/wizard/registry-credentials`, the same call the Unity plugin makes,
280
+ preceded by `POST /v1/wizard/init-quick-start` when the project is not yet
281
+ provisioned.
282
+
283
+ **Bulk operations are deliberately absent.** `stop` takes one `request_id`.
284
+ There is no bulk-stop tool, because an agent with a filter expression and a bug
285
+ can stop a production fleet.
286
+
287
+ **Both a hosted endpoint and a local package.** The hosted endpoint removes
288
+ every step between finding this server and calling a tool, which is where most
289
+ developers drop out. The local package is the only way to run the server
290
+ without extending custody of an unscoped token to a third party, including us.
291
+ Neither one dominates the other, so both ship. See `worker/DECISION.md` for the
292
+ longer version.
293
+
294
+ ## Scope
295
+
296
+ Not exposed, on purpose: private fleets, smart fleets, endpoint storage,
297
+ ACL/whitelist entries, deployment tags, metrics, registry tag deletion, DNS
298
+ configuration, and matchmaker lifecycle (start, stop, delete).
299
+
300
+ These belong to studios already operating on the platform, not to a developer
301
+ getting a first game online. Dockerfile generation and validation, registry
302
+ push, a basic matchmaker config, and relays were moved in scope because agents
303
+ hit them before the first deploy, not after.
304
+
305
+ ## Known limitation: asking for the token at all
306
+
307
+ This applies to local mode, where the token is collected through elicitation
308
+ rather than read from config.
309
+
310
+ The MCP specification says servers should not use elicitation to collect
311
+ sensitive data, and an API token is sensitive. This server does it anyway,
312
+ because requiring a token in a config file before anything works is the largest
313
+ drop in the onboarding funnel, and the whole point of the server is to remove
314
+ setup friction.
315
+
316
+ That is a deliberate trade rather than a pattern to copy. What makes it
317
+ defensible is the set of mitigations in `src/auth.ts` — memory-only storage,
318
+ plain-language disclosure, required acknowledgement, redaction from all output,
319
+ and the environment variable always winning when present. Removing any of them
320
+ breaks the trade.
321
+
322
+ The real fix is on Edgegap's side and would improve both modes: scoped,
323
+ revocable, deploy-only credentials, issued through OAuth rather than pasted as
324
+ a secret. Until those exist, the interactive prompt is a workaround and is
325
+ labelled as one in the code.
326
+
327
+ ## Development
328
+
329
+ ```bash
330
+ npm run typecheck
331
+ node smoke.mjs # handshake, tool registration, read-only mode
332
+ node guards.mjs # local validation and allowlist enforcement
333
+ node elicit.mjs # token prompt: accept, refuse acknowledgement, decline, no support
334
+ node newtools.mjs # validator, registry, relay, matchmaker tools against a local mock API
335
+ ```
336
+
337
+ None of these reach Edgegap. `newtools.mjs` points `EDGEGAP_BASE_URL` at a
338
+ mock server on localhost. `elicit.mjs` asserts that the prompt states
339
+ the org-wide scope, that the acknowledgement is required, that the token never
340
+ appears in tool output, and that declining produces a stop-and-report message
341
+ rather than a retry loop.