@edgegap/mcp 0.3.3 โ†’ 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -157,7 +157,7 @@ To keep your API token on your own machine, run the server locally instead. Leav
157
157
  }
158
158
  ```
159
159
 
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`.
160
+ Needs Node 18+. Pin a version in production (`@edgegap/mcp@0.5.0`) rather than floating on latest. Registered in the official MCP registry as `dev.edgegap/mcp`.
161
161
 
162
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`:
163
163
 
@@ -169,9 +169,37 @@ The local server can also limit what an agent can do. These variables have no ef
169
169
  | `EDGEGAP_MAX_DURATION_MINUTES` | `60` | Ceiling on `max_duration` the agent may set on a version. |
170
170
  | `EDGEGAP_TIMEOUT_MS` | `30000` | Per-request HTTP timeout. |
171
171
 
172
+ ## ๐Ÿ“š Skills
173
+
174
+ The server includes the [Edgegap agent skills](https://github.com/edgegap/edgegap-agent-skills): tested, step-by-step workflows for getting a multiplayer game online, with templates (Dockerfiles, matchmaker configs, Unity C# and Unreal C++ drop-ins) and known pitfalls. Any agent connected to Edgegap MCP gets them, with no separate install and no token needed, and is told to load the matching skill before working on a game project.
175
+
176
+ | Skill | For |
177
+ | --- | --- |
178
+ | `edgegap` | Start here for any engine other than Unity or Unreal Engine, or platform questions. Routes to the rest. |
179
+ | `edgegap-unity` | Unity end to end: server build, matchmaker, client, end-to-end test. |
180
+ | `edgegap-unreal` | Unreal Engine end to end: source engine, Linux server, matchmaker, end-to-end test. |
181
+ | `edgegap-server-design` | Authoritative server design and the deployment lifecycle. |
182
+ | `edgegap-containerize` | The container contract, Dockerfiles, registries, app versions. |
183
+ | `edgegap-local-testing` | Parity tests on your machine, then one smoke-test deployment. |
184
+ | `edgegap-troubleshoot` | Pull errors, crash loops, out-of-memory, clients that can't connect. |
185
+ | `edgegap-deployments-api` | Backend code that deploys servers: webhooks, cleanup, Nakama, PlayFab, UGS, EOS. |
186
+ | `edgegap-launch` | Launch checklist, rollouts, caching, cost control. |
187
+
188
+ They're served three ways, so every MCP client can reach them:
189
+
190
+ - **Tools:** `edgegap_list_skills` and `edgegap_get_skill`, which loads a skill's `SKILL.md`, or one of its reference documents or templates with `file`.
191
+ - **Prompts:** one per skill, named after it. In Claude Code they show up as slash commands, e.g. `/mcp__edgegap__edgegap-unity`.
192
+ - **Resources:** one per file, at `edgegap-skill://<skill>/<path>`, e.g. `edgegap-skill://edgegap-unity/references/deploy.md`.
193
+
194
+ Each release bundles the skills at the commit pinned in `scripts/skills-pin.txt`; `edgegap_context` reports which pack is loaded. If you also installed the skills locally (the Claude Code plugin or `npx skills add`), they're the same pack.
195
+
172
196
  ## ๐Ÿงฐ Tools
173
197
 
174
- Your agent picks the right tool from your request. You don't need to name them, but knowing what's available helps you ask. Tools marked โ— change something in your account and are hidden when `EDGEGAP_READ_ONLY=1`.
198
+ Your agent picks the right tool from your request. You don't need to name them, but knowing what's available helps you ask. Tools marked โ— change something in your account, accept `dry_run`, and are hidden when `EDGEGAP_READ_ONLY=1`.
199
+
200
+ | Tool | What it does |
201
+ | --- | --- |
202
+ | `edgegap_context` | Shows which API this server talks to, its version, local or hosted, and the guardrails in force. No API call; never shows the token. |
175
203
 
176
204
  ### Before Your First Deployment
177
205
 
@@ -190,12 +218,12 @@ Your agent picks the right tool from your request. You don't need to name them,
190
218
  | `edgegap_create_app` โ— | Creates an application. |
191
219
  | `edgegap_list_app_versions` | Lists versions with their image, resources, ports (with TLS Upgrade), and whether a registry login is set. |
192
220
  | `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://`. |
193
- | `edgegap_deploy` โ— | Deploys an authoritative dedicated server close to your players. |
221
+ | `edgegap_deploy` โ— | Deploys an authoritative dedicated server close to your players. Always tagged `edgegap-mcp`, and reports when Edgegap will stop it. |
194
222
  | `edgegap_wait_for_deployment` | Waits until the server is ready and returns the connection address. |
195
223
  | `edgegap_get_deployment` | Reads a deployment's status. |
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). |
224
+ | `edgegap_list_deployments` | Lists running deployments, filtered by application, version, status, tags and more, and sorted by age. Finds servers left running; `only_agent_deployments: true` lists every one an agent started. See [Filter Deployments](https://docs.edgegap.com/learn/orchestration/deployments#filter-deployments). |
197
225
  | `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. |
198
- | `edgegap_stop_deployment` โ— | Stops one deployment. |
226
+ | `edgegap_stop_deployment` โ— | Stops one deployment, by its exact request ID. No bulk stop. |
199
227
 
200
228
  ### Matchmaking
201
229
 
@@ -227,6 +255,24 @@ A relay is not a game server: it forwards traffic while one player's game hosts
227
255
  * *"My deployment failed. Read the logs and tell me why."*
228
256
  * *"My game uses host-client networking. Set up an Edgegap relay for two players."*
229
257
 
258
+ ## ๐Ÿ›ก๏ธ Guardrails
259
+
260
+ Your API token can do anything in your organization, so the server adds its own limits around what an agent does with it. They apply in both the local server and the hosted endpoint.
261
+
262
+ | Guardrail | What it does |
263
+ | --- | --- |
264
+ | Dry run | Every tool that changes something takes `dry_run: true`: it returns the exact method, host, path and body, with the token, registry tokens and env values masked, and sends nothing. Local checks still run. |
265
+ | No token in containers | A deploy or version is refused, with nothing sent, if your API token appears in an env var name or value, a tag, or a webhook URL. Env values are never echoed back. |
266
+ | Agent tag | Every deployment gets the `edgegap-mcp` tag, even when the agent passes its own tags. `edgegap_list_deployments` with `only_agent_deployments: true` finds them all. |
267
+ | Auto-stop | Every deploy reports when Edgegap will stop it: the version's `max_duration`, capped at `EDGEGAP_MAX_DURATION_MINUTES` (default 60) for versions the agent creates. Edgegap has no per-deployment time limit, so a version made elsewhere can run up to its own limit (1440 minutes by default); the result warns when it is over an hour or unlimited. |
268
+ | Strict stop | `edgegap_stop_deployment` stops one deployment by its exact request ID. Empty IDs, wildcards and lists are refused. There is no bulk stop. |
269
+ | Host on every result | Every result starts with the API host, e.g. `[api.edgegap.com]`, or `[custom ยท host]` when `EDGEGAP_BASE_URL` points elsewhere. A base URL naming `api.edgegap.com` must be exactly `https://api.edgegap.com`, or the server refuses to start. |
270
+ | Redaction | The token is stripped from every error before it reaches the agent. |
271
+
272
+ The server identifies itself with `User-Agent: edgegap-mcp/<version> (<MCP client name>)` on every API call.
273
+
274
+ **Usage analytics.** The local server and the self-hosted Docker image send nothing beyond the API calls themselves. The hosted endpoint at `mcp.edgegap.dev` sends usage events to Edgegap's PostHog: which MCP client connected, which tool, prompt or skill resource was used, whether a call succeeded (with the API status code if not), how long it took, and whether it was a dry run, plus the server version and Cloudflare's country code. It never sends your token, tool arguments (IP addresses, env vars, app or image names), results or error text, and GeoIP is off. Events from one token are grouped under a keyed, non-reversible hash of it. To opt out, send the header `X-Edgegap-Telemetry: off` (or `DNT: 1`), or use the local server.
275
+
230
276
  ## ๐Ÿšจ Troubleshooting
231
277
 
232
278
  Review common error codes and learn how to unlock your integration.
@@ -284,8 +330,17 @@ npm test # mock-API tests; none reach Edgegap
284
330
  npm run typecheck:worker
285
331
  ```
286
332
 
333
+ To update the bundled skills to the latest commit of [edgegap-agent-skills](https://github.com/edgegap/edgegap-agent-skills), then release as usual:
334
+
335
+ ```bash
336
+ npm run sync-skills -- --ref main
337
+ npm run check-skills # exit 1 if src/skills.generated.ts differs from the pin
338
+ ```
339
+
287
340
  | Test | Covers |
288
341
  | --- | --- |
342
+ | `test/package.mjs` | Packaging: one `bin`, runtime dependencies, versions in step |
343
+ | `test/skills.mjs` | Skills over MCP: tools, prompts, resources, path safety, bundle matches the pin |
289
344
  | `test/smoke.mjs` | Handshake, tool registration, read-only mode |
290
345
  | `test/guards.mjs` | Local validation and allowlist enforcement |
291
346
  | `test/elicit.mjs` | Token prompt: accept, refuse acknowledgement, decline, no support |
package/dist/client.js CHANGED
@@ -6,6 +6,29 @@
6
6
  * picking the wrong one. This wraps only what the golden path needs.
7
7
  */
8
8
  import { redact } from './config.js';
9
+ import { VERSION } from './version.js';
10
+ const SECRET_KEYS = /^(private_token|registry_token|token|password|secret|api_key)$/i;
11
+ /**
12
+ * Deep copy of a request body with secrets masked: registry tokens and the
13
+ * like by key name, every environment variable value (we never echo those),
14
+ * and the API token anywhere it appears.
15
+ */
16
+ export function maskSecrets(value, apiToken) {
17
+ if (typeof value === 'string') {
18
+ return apiToken && value.includes(apiToken) ? value.split(apiToken).join('***') : value;
19
+ }
20
+ if (Array.isArray(value))
21
+ return value.map((v) => maskSecrets(v, apiToken));
22
+ if (!value || typeof value !== 'object')
23
+ return value;
24
+ const obj = value;
25
+ const isEnvVar = typeof obj.key === 'string' && 'value' in obj;
26
+ const out = {};
27
+ for (const [k, v] of Object.entries(obj)) {
28
+ out[k] = (SECRET_KEYS.test(k) && v != null) || (isEnvVar && k === 'value') ? '***' : maskSecrets(v, apiToken);
29
+ }
30
+ return out;
31
+ }
9
32
  export class EdgegapApiError extends Error {
10
33
  status;
11
34
  apiMessage;
@@ -21,9 +44,29 @@ export class EdgegapApiError extends Error {
21
44
  export class EdgegapClient {
22
45
  config;
23
46
  auth;
24
- constructor(config, auth) {
47
+ options;
48
+ constructor(config, auth, options = {}) {
25
49
  this.config = config;
26
50
  this.auth = auth;
51
+ this.options = options;
52
+ }
53
+ /**
54
+ * A client that records requests instead of sending them, for dry runs.
55
+ * Tools call it exactly as they call the real one, so the request shown is
56
+ * the request that would be sent โ€” not a second copy of the path logic.
57
+ */
58
+ dryRun() {
59
+ const requests = [];
60
+ const client = new EdgegapClient(this.config, this.auth, {
61
+ ...this.options,
62
+ recorder: (r) => requests.push(r),
63
+ });
64
+ return { client, requests };
65
+ }
66
+ /** "edgegap-mcp/<version> (<client>)". Nothing else identifying is sent. */
67
+ userAgent() {
68
+ const client = this.options.clientName?.();
69
+ return `edgegap-mcp/${VERSION}${client ? ` (${client.replace(/[^\w .\-/]/g, '')})` : ''}`;
27
70
  }
28
71
  async request(method, version, path, options = {}) {
29
72
  const base = version === 'v2' ? this.config.baseUrlV2 : this.config.baseUrlV1;
@@ -33,6 +76,18 @@ export class EdgegapClient {
33
76
  url.searchParams.set(key, String(value));
34
77
  }
35
78
  }
79
+ if (this.options.recorder) {
80
+ // Dry run: record and stop. Never ask for or read the token here โ€” the
81
+ // header is shown masked, and a dry run must not trigger the prompt.
82
+ this.options.recorder({
83
+ method,
84
+ host: url.host,
85
+ path: url.pathname + url.search,
86
+ headers: { Authorization: 'token ***', 'Content-Type': 'application/json', 'User-Agent': this.userAgent() },
87
+ ...(options.body === undefined ? {} : { body: maskSecrets(options.body, this.auth.current) }),
88
+ });
89
+ return {};
90
+ }
36
91
  // Resolved per request rather than at construction: the developer may not
37
92
  // have been asked for a token yet.
38
93
  const token = await this.auth.get();
@@ -47,7 +102,7 @@ export class EdgegapClient {
47
102
  Authorization: `token ${token}`,
48
103
  'Content-Type': 'application/json',
49
104
  Accept: 'application/json',
50
- 'User-Agent': 'edgegap-mcp',
105
+ 'User-Agent': this.userAgent(),
51
106
  },
52
107
  body: options.body === undefined ? undefined : JSON.stringify(options.body),
53
108
  signal: controller.signal,
@@ -92,6 +147,10 @@ export class EdgegapClient {
92
147
  listAppVersions(appName) {
93
148
  return this.request('GET', 'v1', `/v1/app/${encodeURIComponent(appName)}/versions`);
94
149
  }
150
+ /** One version. The response is the version itself, not wrapped. */
151
+ getAppVersion(appName, versionName) {
152
+ return this.request('GET', 'v1', `/v1/app/${encodeURIComponent(appName)}/version/${encodeURIComponent(versionName)}`);
153
+ }
95
154
  createAppVersion(appName, body) {
96
155
  return this.request('POST', 'v1', `/v1/app/${encodeURIComponent(appName)}/version`, { body });
97
156
  }
package/dist/config.js CHANGED
@@ -4,6 +4,42 @@
4
4
  * Everything here exists to keep the blast radius of an autonomous agent small.
5
5
  * The Edgegap API token is org-wide, so the server layers its own limits on top.
6
6
  */
7
+ /** Edgegap's production API. A base URL naming this host must be exactly it. */
8
+ export const DEFAULT_API_HOST = 'api.edgegap.com';
9
+ /**
10
+ * Validates EDGEGAP_BASE_URL and returns it without a trailing slash.
11
+ *
12
+ * The token travels in a header to whatever host this names, so a typo or a
13
+ * plain-http URL is a credential leak, not a misconfiguration. A URL naming
14
+ * Edgegap's own host must be https; anything else is labelled "custom" on
15
+ * every tool result (see hostLabel) so it cannot go unnoticed.
16
+ */
17
+ export function parseBaseUrl(raw) {
18
+ const value = raw?.trim() || `https://${DEFAULT_API_HOST}`;
19
+ let url;
20
+ try {
21
+ url = new URL(value);
22
+ }
23
+ catch {
24
+ throw new ConfigError(`EDGEGAP_BASE_URL "${value}" is not a valid URL.`);
25
+ }
26
+ if (url.protocol !== 'https:' && url.protocol !== 'http:') {
27
+ throw new ConfigError(`EDGEGAP_BASE_URL must be an http(s) URL, not ${url.protocol}`);
28
+ }
29
+ if (url.hostname === DEFAULT_API_HOST && (url.protocol !== 'https:' || url.port !== '')) {
30
+ throw new ConfigError(`EDGEGAP_BASE_URL names ${DEFAULT_API_HOST} but is not https://${DEFAULT_API_HOST}. ` +
31
+ 'The API token would be sent unencrypted or to the wrong port. Use https.');
32
+ }
33
+ if (url.username || url.password) {
34
+ throw new ConfigError('EDGEGAP_BASE_URL must not contain a username or password.');
35
+ }
36
+ return value.replace(/\/+$/, '');
37
+ }
38
+ /** "api.edgegap.com", or "custom ยท <host>" when EDGEGAP_BASE_URL points elsewhere. */
39
+ export function hostLabel(config) {
40
+ const host = new URL(config.baseUrlV1).host;
41
+ return host === DEFAULT_API_HOST ? host : `custom ยท ${host}`;
42
+ }
7
43
  export class ConfigError extends Error {
8
44
  }
9
45
  function parseList(raw) {
@@ -30,8 +66,9 @@ export function loadConfig(env = process.env) {
30
66
  const envToken = raw ? stripTokenPrefix(raw) || undefined : undefined;
31
67
  return {
32
68
  envToken,
33
- baseUrlV1: env.EDGEGAP_BASE_URL?.trim() || 'https://api.edgegap.com',
34
- baseUrlV2: (env.EDGEGAP_BASE_URL?.trim() || 'https://api.edgegap.com') + '/v2',
69
+ baseUrlV1: parseBaseUrl(env.EDGEGAP_BASE_URL),
70
+ baseUrlV2: parseBaseUrl(env.EDGEGAP_BASE_URL) + '/v2',
71
+ transport: 'local',
35
72
  readOnly: env.EDGEGAP_READ_ONLY === '1' || env.EDGEGAP_READ_ONLY === 'true',
36
73
  appAllowlist: parseList(env.EDGEGAP_APP_ALLOWLIST),
37
74
  maxDurationCeiling: parseIntEnv(env.EDGEGAP_MAX_DURATION_MINUTES, 60),
package/dist/http.js CHANGED
@@ -16,6 +16,7 @@ import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/
16
16
  import { loadConfig, ConfigError } from './config.js';
17
17
  import { EdgegapClient } from './client.js';
18
18
  import { registerTools, serverInstructions } from './tools.js';
19
+ import { VERSION } from './version.js';
19
20
  import { StaticTokenProvider } from './auth.js';
20
21
  import { extractToken, unavailableMessage } from './hosted.js';
21
22
  const MAX_BODY_BYTES = 1_000_000;
@@ -52,7 +53,7 @@ function main() {
52
53
  let config;
53
54
  try {
54
55
  // No ambient credential, by design: every token comes from the request.
55
- config = { ...loadConfig(), envToken: undefined };
56
+ config = { ...loadConfig(), envToken: undefined, transport: 'hosted' };
56
57
  }
57
58
  catch (err) {
58
59
  if (err instanceof ConfigError) {
@@ -91,8 +92,11 @@ function main() {
91
92
  }
92
93
  const { token, problem } = extractToken(req.headers.authorization);
93
94
  const auth = new StaticTokenProvider(token, problem ? unavailableMessage(problem) : undefined);
94
- const server = new McpServer({ name: 'edgegap', version: '0.3.3' }, { instructions: serverInstructions('hosted') });
95
- registerTools(server, new EdgegapClient(config, auth), config, auth);
95
+ const server = new McpServer({ name: 'edgegap', version: VERSION }, { instructions: serverInstructions('hosted') });
96
+ const client = new EdgegapClient(config, auth, {
97
+ clientName: () => server.server.getClientVersion()?.name,
98
+ });
99
+ registerTools(server, client, config, auth);
96
100
  const transport = new StreamableHTTPServerTransport({
97
101
  sessionIdGenerator: undefined,
98
102
  enableJsonResponse: true,
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
15
15
  import { loadConfig, ConfigError } from './config.js';
16
16
  import { EdgegapClient } from './client.js';
17
17
  import { registerTools, serverInstructions } from './tools.js';
18
+ import { VERSION } from './version.js';
18
19
  import { TokenProvider, warnIfTokenInArgv } from './auth.js';
19
20
  async function main() {
20
21
  let config;
@@ -29,12 +30,15 @@ async function main() {
29
30
  }
30
31
  throw err;
31
32
  }
32
- const server = new McpServer({ name: 'edgegap', version: '0.3.3' }, { instructions: serverInstructions('local') });
33
+ const server = new McpServer({ name: 'edgegap', version: VERSION }, { instructions: serverInstructions('local') });
33
34
  warnIfTokenInArgv();
34
35
  const auth = new TokenProvider(config);
35
36
  auth.attach(server.server);
36
37
  auth.installExitHandlers();
37
- registerTools(server, new EdgegapClient(config, auth), config, auth);
38
+ const client = new EdgegapClient(config, auth, {
39
+ clientName: () => server.server.getClientVersion()?.name,
40
+ });
41
+ registerTools(server, client, config, auth);
38
42
  if (!config.envToken) {
39
43
  process.stderr.write('[edgegap-mcp] no token configured: you will be asked for one at first ' +
40
44
  'use. It stays in memory on this machine and is never written to disk ' +