@edgegap/mcp 0.7.2 → 0.10.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 +9 -2
- package/dist/config.js +3 -0
- package/dist/index.js +7 -1
- package/dist/matchmaker.js +7 -2
- package/dist/skills.generated.js +46 -46
- package/dist/skillsinstall.js +194 -0
- package/dist/skillsversion.js +110 -0
- package/dist/tools.js +290 -33
- package/dist/version.js +1 -1
- package/package.json +4 -3
package/dist/tools.js
CHANGED
|
@@ -17,6 +17,7 @@ import { generateDockerfile, DockerfileInputError } from './dockerfile.js';
|
|
|
17
17
|
import { buildMatchmakerConfig, DASHBOARD_URL } from './matchmaker.js';
|
|
18
18
|
import { badImage, badTag, looksSecret, TAG_FIX } from './image.js';
|
|
19
19
|
import { SKILLS_PACK, findSkill, findSkillFile, fileIndex, mimeType, skillUri } from './skills.js';
|
|
20
|
+
import { SKILL_NAME_RE, compareVersions, latestPack, latestSkillVersions, servedPackStatus, skillsCheckFromEnv, } from './skillsversion.js';
|
|
20
21
|
/**
|
|
21
22
|
* The one definition of "dedicated server vs relay" this server gives agents.
|
|
22
23
|
* Used in the server instructions, the relay tool description, and every relay
|
|
@@ -158,9 +159,24 @@ const NOT_FOUND = {
|
|
|
158
159
|
'before it ran. If it is still running, check the request_id with edgegap_list_deployments.',
|
|
159
160
|
relay: 'no relay session with that session_id. It may already have been deleted.',
|
|
160
161
|
};
|
|
162
|
+
/**
|
|
163
|
+
* What a 403 means, per kind of resource. The API's own text is a bare "You
|
|
164
|
+
* are not authorized to access this resource", which reads like a bad token
|
|
165
|
+
* and sends agents to ask for a new one. A rejected token is a 401; a 403 is
|
|
166
|
+
* a token that works but may not use this feature.
|
|
167
|
+
*/
|
|
168
|
+
const FORBIDDEN = {
|
|
169
|
+
relay: 'the token is valid, but this organization cannot use relays. Relays are not enabled on ' +
|
|
170
|
+
'every plan or account; check the Relays page in the dashboard (https://app.edgegap.com) ' +
|
|
171
|
+
'or ask Edgegap support. A new token will not help. Consider a dedicated server ' +
|
|
172
|
+
'(edgegap_deploy) instead.',
|
|
173
|
+
generic: 'the token is valid, but this organization may not use this feature or resource. It may ' +
|
|
174
|
+
'not be enabled on the plan, or the resource belongs to another organization. A new token ' +
|
|
175
|
+
'will not help; check the feature in the dashboard (https://app.edgegap.com) or ask the developer.',
|
|
176
|
+
};
|
|
161
177
|
/** Wraps a handler so API errors come back as readable, self-correctable text
|
|
162
178
|
* rather than a protocol-level exception the agent cannot act on. */
|
|
163
|
-
function guard(auth, fn, notFound) {
|
|
179
|
+
function guard(auth, fn, notFound, forbidden) {
|
|
164
180
|
const handled = fn().catch((err) => {
|
|
165
181
|
if (err instanceof TokenUnavailableError) {
|
|
166
182
|
// Not a failure to correct — a decision the human made. Say so plainly
|
|
@@ -168,7 +184,7 @@ function guard(auth, fn, notFound) {
|
|
|
168
184
|
return fail(err.message);
|
|
169
185
|
}
|
|
170
186
|
if (err instanceof EdgegapApiError) {
|
|
171
|
-
const hint = errorHint(err, notFound);
|
|
187
|
+
const hint = errorHint(err, notFound, forbidden);
|
|
172
188
|
return fail(`${err.message}${hint ? `\n\nLikely cause: ${hint}` : ''}`);
|
|
173
189
|
}
|
|
174
190
|
return fail(redact(err.message ?? String(err), auth.current));
|
|
@@ -189,9 +205,9 @@ function guard(auth, fn, notFound) {
|
|
|
189
205
|
}
|
|
190
206
|
/** guard() with the 404 hint first, so it reads at the call site. */
|
|
191
207
|
function guarded(auth, notFound, fn) {
|
|
192
|
-
return guard(auth, fn, notFound);
|
|
208
|
+
return guard(auth, fn, notFound, notFound === NOT_FOUND.relay ? FORBIDDEN.relay : undefined);
|
|
193
209
|
}
|
|
194
|
-
function errorHint(err, notFound) {
|
|
210
|
+
function errorHint(err, notFound, forbidden) {
|
|
195
211
|
switch (err.status) {
|
|
196
212
|
case 401:
|
|
197
213
|
// Deliberately does not promise a re-prompt: the local server asks again
|
|
@@ -206,6 +222,8 @@ function errorHint(err, notFound) {
|
|
|
206
222
|
// Request ID provided", or a generic "could not understand" for logs),
|
|
207
223
|
// not 404. Their only input is the request_id, so a 400 means that.
|
|
208
224
|
return notFound === NOT_FOUND.deployment || notFound === NOT_FOUND.logs ? notFound : undefined;
|
|
225
|
+
case 403:
|
|
226
|
+
return forbidden ?? FORBIDDEN.generic;
|
|
209
227
|
case 404:
|
|
210
228
|
// Only the tool knows what was not found; no hint beats a wrong one.
|
|
211
229
|
return notFound;
|
|
@@ -243,6 +261,56 @@ function pageInfo(totalCount, returned, page) {
|
|
|
243
261
|
};
|
|
244
262
|
}
|
|
245
263
|
/** Trims a deployment status down to what an agent needs to act. */
|
|
264
|
+
/** The last `cap` characters of a deployment's container logs, or undefined
|
|
265
|
+
* if there are none or they cannot be read. Never throws. */
|
|
266
|
+
async function logTail(client, requestId, cap) {
|
|
267
|
+
try {
|
|
268
|
+
const res = await client.getDeploymentLogs(requestId);
|
|
269
|
+
const text = [res.logs, res.crash_logs].filter(Boolean).join('\n');
|
|
270
|
+
if (!text.trim())
|
|
271
|
+
return undefined;
|
|
272
|
+
return text.length > cap ? `...[truncated]...\n${text.slice(-cap)}` : text;
|
|
273
|
+
}
|
|
274
|
+
catch {
|
|
275
|
+
return undefined;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Stop is idempotent: stopping a deployment that has already stopped, or that
|
|
280
|
+
* Edgegap no longer knows, leaves nothing running, which is what was asked.
|
|
281
|
+
* Returns the success payload in that case, or undefined to report the error.
|
|
282
|
+
* An unknown request_id cannot be told apart from a cleaned-up one (both are a
|
|
283
|
+
* 400 or 404), so the result says so instead of claiming it was stopped.
|
|
284
|
+
*/
|
|
285
|
+
async function alreadyStopped(client, requestId, err) {
|
|
286
|
+
if (!(err instanceof EdgegapApiError) || ![400, 404, 409, 410].includes(err.status))
|
|
287
|
+
return undefined;
|
|
288
|
+
let status;
|
|
289
|
+
try {
|
|
290
|
+
status = await client.getDeployment(requestId);
|
|
291
|
+
}
|
|
292
|
+
catch (statusErr) {
|
|
293
|
+
if (statusErr instanceof EdgegapApiError && [400, 404].includes(statusErr.status)) {
|
|
294
|
+
return {
|
|
295
|
+
request_id: requestId,
|
|
296
|
+
result: 'not_running',
|
|
297
|
+
note: 'Edgegap has no running deployment with this request_id: it already stopped and was ' +
|
|
298
|
+
'cleaned up, or the request_id is wrong. Nothing is left to stop. If you expected it ' +
|
|
299
|
+
'to be running, check edgegap_list_deployments.',
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
return undefined;
|
|
303
|
+
}
|
|
304
|
+
const current = (status.current_status ?? '').toUpperCase();
|
|
305
|
+
if (status.running && !current.includes('TERMINAT'))
|
|
306
|
+
return undefined;
|
|
307
|
+
return {
|
|
308
|
+
request_id: requestId,
|
|
309
|
+
result: 'already_stopped',
|
|
310
|
+
status: status.current_status,
|
|
311
|
+
note: 'This deployment was already stopped or stopping. Nothing more to do.',
|
|
312
|
+
};
|
|
313
|
+
}
|
|
246
314
|
function compactDeployment(d) {
|
|
247
315
|
const ports = Object.entries(d.ports ?? {}).map(([key, p]) => ({
|
|
248
316
|
name: p.name ?? key,
|
|
@@ -433,7 +501,7 @@ function autoStop(maxDuration) {
|
|
|
433
501
|
function withHost(result, label) {
|
|
434
502
|
return { ...result, content: [{ type: 'text', text: `[${label}]` }, ...result.content] };
|
|
435
503
|
}
|
|
436
|
-
export function registerTools(server, client, config, auth) {
|
|
504
|
+
export function registerTools(server, client, config, auth, options = {}) {
|
|
437
505
|
const mutating = !config.readOnly;
|
|
438
506
|
// Every result names the API host it came from, first, so a session pointed
|
|
439
507
|
// at a custom EDGEGAP_BASE_URL can never be mistaken for production.
|
|
@@ -1090,10 +1158,16 @@ export function registerTools(server, client, config, auth) {
|
|
|
1090
1158
|
last = await client.getDeployment(request_id);
|
|
1091
1159
|
const status = (last.current_status ?? '').toUpperCase();
|
|
1092
1160
|
if (last.error || TERMINAL_BAD.some((s) => status.includes(s))) {
|
|
1161
|
+
// Fetched now, not left to the agent: a failed deployment is
|
|
1162
|
+
// cleaned up quickly and its logs go with it, so a separate
|
|
1163
|
+
// edgegap_get_deployment_logs call often finds nothing.
|
|
1164
|
+
const logs = await logTail(client, request_id, 3000);
|
|
1093
1165
|
return fail(`Deployment ${request_id} failed with status ${last.current_status}.\n` +
|
|
1094
1166
|
`${last.error_detail ?? 'No error detail returned.'}\n\n` +
|
|
1095
|
-
|
|
1096
|
-
|
|
1167
|
+
(logs
|
|
1168
|
+
? `Container output (tail):\n${logs}\n\nFix the image or port configuration before redeploying.`
|
|
1169
|
+
: `No container logs could be read (the container may never have started, or it ` +
|
|
1170
|
+
`was already cleaned up). Check the image, tag and ports before redeploying.`));
|
|
1097
1171
|
}
|
|
1098
1172
|
if (last.running || TERMINAL_OK.some((s) => status.includes(s))) {
|
|
1099
1173
|
return ok({
|
|
@@ -1104,9 +1178,15 @@ export function registerTools(server, client, config, auth) {
|
|
|
1104
1178
|
await new Promise((r) => setTimeout(r, intervalMs));
|
|
1105
1179
|
intervalMs = Math.min(intervalMs * 1.5, 10_000);
|
|
1106
1180
|
}
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1181
|
+
// Not an error: the wait ran out, the deployment did not fail. It is
|
|
1182
|
+
// usually still starting (large images pull slowly on a cold host).
|
|
1183
|
+
return ok({
|
|
1184
|
+
...(last ? compactDeployment(last) : { request_id }),
|
|
1185
|
+
ready: false,
|
|
1186
|
+
waited_seconds: Math.round((Date.now() - startedAt) / 1000),
|
|
1187
|
+
next_step: `Not ready within ${timeout_seconds ?? 180}s, and not failed: it may still be starting. ` +
|
|
1188
|
+
`Call edgegap_wait_for_deployment again, or edgegap_stop_deployment if it should not keep running.`,
|
|
1189
|
+
});
|
|
1110
1190
|
}));
|
|
1111
1191
|
// ---------------------------------------------------------------- 8 ----
|
|
1112
1192
|
tool('edgegap_list_deployments', {
|
|
@@ -1197,7 +1277,16 @@ export function registerTools(server, client, config, auth) {
|
|
|
1197
1277
|
await dry.client.stopDeployment(request_id);
|
|
1198
1278
|
return dryRunResult(dry.requests);
|
|
1199
1279
|
}
|
|
1200
|
-
|
|
1280
|
+
let res;
|
|
1281
|
+
try {
|
|
1282
|
+
res = await client.stopDeployment(request_id);
|
|
1283
|
+
}
|
|
1284
|
+
catch (err) {
|
|
1285
|
+
const gone = await alreadyStopped(client, request_id, err);
|
|
1286
|
+
if (gone)
|
|
1287
|
+
return ok(gone);
|
|
1288
|
+
throw err;
|
|
1289
|
+
}
|
|
1201
1290
|
return ok({ request_id, result: res.message ?? 'stop requested' });
|
|
1202
1291
|
}));
|
|
1203
1292
|
}
|
|
@@ -1464,7 +1553,7 @@ export function registerTools(server, client, config, auth) {
|
|
|
1464
1553
|
// missing registry, so it must not trigger provisioning (which only
|
|
1465
1554
|
// fails with a second, more confusing 403). Only a 404 — a
|
|
1466
1555
|
// quick-start token whose project is not provisioned yet — does.
|
|
1467
|
-
const unavailable = () =>
|
|
1556
|
+
const unavailable = () => manualStepsResult(registryCredentialsUnavailable(image_name, tag));
|
|
1468
1557
|
let creds;
|
|
1469
1558
|
try {
|
|
1470
1559
|
creds = await client.getRegistryCredentials();
|
|
@@ -1704,7 +1793,7 @@ export function registerTools(server, client, config, auth) {
|
|
|
1704
1793
|
`(status ${last.status ?? 'unknown'}). Call edgegap_get_relay_session to check again.`);
|
|
1705
1794
|
}
|
|
1706
1795
|
return ok({ ...compactRelay(last), waited_seconds: Math.round((Date.now() - startedAt) / 1000) });
|
|
1707
|
-
}));
|
|
1796
|
+
}, undefined, FORBIDDEN.relay));
|
|
1708
1797
|
}
|
|
1709
1798
|
// --------------------------------------------------------------- 15 ----
|
|
1710
1799
|
tool('edgegap_get_relay_session', {
|
|
@@ -1736,7 +1825,7 @@ export function registerTools(server, client, config, auth) {
|
|
|
1736
1825
|
error: r.error || undefined,
|
|
1737
1826
|
}));
|
|
1738
1827
|
return ok({ ...pageInfo(res.total_count, sessions.length, 1), sessions });
|
|
1739
|
-
}));
|
|
1828
|
+
}, undefined, FORBIDDEN.relay));
|
|
1740
1829
|
if (mutating) {
|
|
1741
1830
|
// ------------------------------------------------------------- 16 ----
|
|
1742
1831
|
tool('edgegap_authorize_relay_user', {
|
|
@@ -1847,8 +1936,8 @@ export function registerTools(server, client, config, auth) {
|
|
|
1847
1936
|
max_latency_ms: z.number().int().min(1).optional(),
|
|
1848
1937
|
}))
|
|
1849
1938
|
.optional()
|
|
1850
|
-
.describe('Rule relaxations after a player has waited this long, e.g. [{after_seconds:
|
|
1851
|
-
ticket_expiration: z.string().optional().describe('Default "
|
|
1939
|
+
.describe('Rule relaxations after a player has waited this long, e.g. [{after_seconds: 20, min_team_size: 1}]. Keep each below ticket_expiration.'),
|
|
1940
|
+
ticket_expiration: z.string().optional().describe('Default "30s", so a developer testing alone is matched or told to retry within 30 s instead of waiting minutes. Raise it only for production queues.'),
|
|
1852
1941
|
inspect: z.boolean().optional().describe('Expose the inspection API for debugging. Default true; turn off for production.'),
|
|
1853
1942
|
verify_version: z.boolean().optional().describe('Look up the application version first. Default true.'),
|
|
1854
1943
|
allowed_cors_origins: z
|
|
@@ -1910,7 +1999,7 @@ export function registerTools(server, client, config, auth) {
|
|
|
1910
1999
|
],
|
|
1911
2000
|
});
|
|
1912
2001
|
}));
|
|
1913
|
-
registerSkills(server, tool);
|
|
2002
|
+
registerSkills(server, tool, config, options);
|
|
1914
2003
|
}
|
|
1915
2004
|
// ==================================================================== skills ====
|
|
1916
2005
|
/**
|
|
@@ -1921,7 +2010,10 @@ export function registerTools(server, client, config, auth) {
|
|
|
1921
2010
|
* - resources, one per file: for clients that browse or @-mention resources.
|
|
1922
2011
|
* All three read the same bundle (src/skills.generated.ts). No token, no network.
|
|
1923
2012
|
*/
|
|
1924
|
-
function registerSkills(server, tool) {
|
|
2013
|
+
function registerSkills(server, tool, config, options) {
|
|
2014
|
+
const hosted = config.transport === 'hosted';
|
|
2015
|
+
const check = options.skillsCheck ?? skillsCheckFromEnv(typeof process === 'undefined' ? {} : process.env);
|
|
2016
|
+
const local = hosted ? undefined : options.localSkills;
|
|
1925
2017
|
const names = SKILLS_PACK.skills.map((s) => s.name);
|
|
1926
2018
|
const pack = `${SKILLS_PACK.version} (${SKILLS_PACK.commit.slice(0, 7)})`;
|
|
1927
2019
|
const howToFetch = (skill) => `Fetch any of these with edgegap_get_skill {skill: "${skill}", file: "<path>"}, or read the ` +
|
|
@@ -1937,21 +2029,27 @@ function registerSkills(server, tool) {
|
|
|
1937
2029
|
'(edgegap-eos-voice to add voice chat to it), edgegap-fusion-simplefps for the Photon Simple FPS sample, edgegap-godot for Godot 4 with a Godot server, ' +
|
|
1938
2030
|
'edgegap-colyseus for a Colyseus server, edgegap-nakama for a game with a Nakama backend, edgegap-playfab for a game that keeps PlayFab Matchmaking, ' +
|
|
1939
2031
|
'edgegap-threejs for a Three.js or other browser game with its own Node.js server, ' +
|
|
1940
|
-
'edgegap-manus for a browser game built with Manus, edgegap for any other engine or platform questions; it routes to the rest.
|
|
1941
|
-
'API call.',
|
|
2032
|
+
'edgegap-manus for a browser game built with Manus, edgegap for any other engine or platform questions; it routes to the rest. ' +
|
|
2033
|
+
'Also says whether a newer skills pack is on GitHub (reads one version number, no Edgegap API call).',
|
|
1942
2034
|
inputSchema: {},
|
|
1943
|
-
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint:
|
|
1944
|
-
}, async () =>
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
2035
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
|
|
2036
|
+
}, async () => {
|
|
2037
|
+
const status = servedPackStatus(await latestPack(check), hosted);
|
|
2038
|
+
return ok({
|
|
2039
|
+
pack,
|
|
2040
|
+
...status,
|
|
2041
|
+
source: SKILLS_PACK.source,
|
|
2042
|
+
skills: SKILLS_PACK.skills.map((s) => ({
|
|
2043
|
+
name: s.name,
|
|
2044
|
+
version: s.version,
|
|
2045
|
+
description: s.description,
|
|
2046
|
+
files: s.files.length,
|
|
2047
|
+
})),
|
|
2048
|
+
next_step: 'Load the skill that matches the project with edgegap_get_skill, then follow it. ' +
|
|
2049
|
+
'If the developer also has Edgegap skills installed in their agent (a skills folder or the Claude Code plugin), ' +
|
|
2050
|
+
'edgegap_update_skills checks whether those copies are current.',
|
|
2051
|
+
});
|
|
2052
|
+
});
|
|
1955
2053
|
tool('edgegap_get_skill', {
|
|
1956
2054
|
title: 'Load an Edgegap agent skill',
|
|
1957
2055
|
description: 'Load one Edgegap agent skill: its SKILL.md (the workflow to follow) by default, or one of ' +
|
|
@@ -1983,13 +2081,160 @@ function registerSkills(server, tool) {
|
|
|
1983
2081
|
return fail(`"${file}" is not a file in the ${skill.name} skill. Its files are:\n` +
|
|
1984
2082
|
skill.files.map((f) => `- ${f.path}`).join('\n'));
|
|
1985
2083
|
}
|
|
1986
|
-
const
|
|
2084
|
+
const status = found.path === 'SKILL.md' ? servedPackStatus(await latestPack(check), hosted) : undefined;
|
|
2085
|
+
const header = `${skill.name} ${skill.version} · ${found.path} · pack ${pack}` +
|
|
2086
|
+
(status?.update ? `\nNote: ${status.update}` : '');
|
|
1987
2087
|
const others = found.path === 'SKILL.md' ? fileIndex(skill) : [];
|
|
1988
2088
|
const footer = others.length
|
|
1989
2089
|
? `\n\n---\nOther files in this skill:\n${others.map((p) => `- ${p}`).join('\n')}\n\n${howToFetch(skill.name)}`
|
|
1990
2090
|
: '';
|
|
1991
2091
|
return { content: [{ type: 'text', text: `${header}\n\n${found.content}${footer}` }] };
|
|
1992
2092
|
});
|
|
2093
|
+
tool('edgegap_update_skills', {
|
|
2094
|
+
title: 'Check and update the installed Edgegap skills',
|
|
2095
|
+
description: 'Check whether the Edgegap agent skills installed in the developer\'s agent are the latest, and update them. ' +
|
|
2096
|
+
(hosted
|
|
2097
|
+
? 'This hosted server cannot see the developer\'s disk: pass installed_versions (each loaded skill\'s ' +
|
|
2098
|
+
'metadata.version from its SKILL.md frontmatter) and it compares them with the latest on GitHub and says how to update. '
|
|
2099
|
+
: 'Finds installs made with the skills CLI (user-wide or this project), the Claude Code plugin edgegap@edgegap, and skills ' +
|
|
2100
|
+
'copied by hand into an agent\'s skills folder, and compares each skill with the latest on GitHub. Without apply it only ' +
|
|
2101
|
+
'checks and changes nothing. With apply=true it runs each outdated install\'s own updater (npx skills update for the Edgegap ' +
|
|
2102
|
+
'skills only, or claude plugin update) and rewrites hand-copied skills from the files bundled in this server; ask the ' +
|
|
2103
|
+
'developer before applying. ') +
|
|
2104
|
+
'Skill text is never downloaded by this tool. The skills served by edgegap_get_skill need no update here.',
|
|
2105
|
+
inputSchema: {
|
|
2106
|
+
...(local
|
|
2107
|
+
? {
|
|
2108
|
+
apply: z
|
|
2109
|
+
.boolean()
|
|
2110
|
+
.optional()
|
|
2111
|
+
.describe('Run the updates for outdated installs. Omit or false to only check.'),
|
|
2112
|
+
}
|
|
2113
|
+
: {}),
|
|
2114
|
+
installed_versions: z
|
|
2115
|
+
.record(z.string(), z.string())
|
|
2116
|
+
.optional()
|
|
2117
|
+
.describe('Skill name → version of skills you have loaded from somewhere this server cannot see, e.g. ' +
|
|
2118
|
+
'{"edgegap-unity": "0.1.8"}. The version is metadata.version in the SKILL.md frontmatter.'),
|
|
2119
|
+
},
|
|
2120
|
+
annotations: { readOnlyHint: !local, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
2121
|
+
}, async (args) => {
|
|
2122
|
+
const apply = args.apply === true;
|
|
2123
|
+
const given = Object.entries(args.installed_versions ?? {}).filter(([n]) => SKILL_NAME_RE.test(n));
|
|
2124
|
+
const installs = local ? await local.findSkillsInstalls(local.env) : [];
|
|
2125
|
+
const wanted = [...installs.flatMap((i) => i.skills.map((s) => s.name)), ...given.map(([n]) => n)];
|
|
2126
|
+
const [packLatest, latest] = await Promise.all([latestPack(check), latestSkillVersions(wanted, check)]);
|
|
2127
|
+
const row = (name, installed) => {
|
|
2128
|
+
const l = latest[name];
|
|
2129
|
+
const status = !l?.version || !installed ? 'unknown' : compareVersions(installed, l.version) < 0 ? 'update available' : 'up to date';
|
|
2130
|
+
return {
|
|
2131
|
+
name,
|
|
2132
|
+
installed: installed ?? 'no version in its SKILL.md',
|
|
2133
|
+
latest: l?.version ?? 'unknown (not in the pack)',
|
|
2134
|
+
latest_from: l?.source === 'github' ? 'GitHub main' : l?.source === 'bundled' ? 'this server\'s bundle (GitHub not reachable)' : 'unknown',
|
|
2135
|
+
status,
|
|
2136
|
+
};
|
|
2137
|
+
};
|
|
2138
|
+
const report = installs.map((i) => ({ install: i, rows: i.skills.map((s) => row(s.name, s.version)) }));
|
|
2139
|
+
const outdatedOf = (rows) => rows.filter((r) => r.status !== 'up to date').map((r) => r.name);
|
|
2140
|
+
const result = {
|
|
2141
|
+
latest_pack: packLatest.version ?? `unknown: ${packLatest.error}`,
|
|
2142
|
+
installs: report.map(({ install, rows }) => ({ where: install.where, kind: install.kind, skills: rows })),
|
|
2143
|
+
};
|
|
2144
|
+
if (given.length)
|
|
2145
|
+
result.loaded_skills = given.map(([n, v]) => row(n, v));
|
|
2146
|
+
const anyOutdated = report.some(({ rows }) => outdatedOf(rows).length) || given.some(([n, v]) => row(n, v).status === 'update available');
|
|
2147
|
+
const howToUpdate = 'Reinstall the way they were installed: npx skills add edgegap/llm-agent-skills --skill "*" (add -g for user-wide); ' +
|
|
2148
|
+
'in Claude Code, /plugin marketplace update edgegap then /plugin update edgegap@edgegap; or copy the skills folders from ' +
|
|
2149
|
+
'github.com/edgegap/llm-agent-skills again.';
|
|
2150
|
+
if (given.some(([n, v]) => row(n, v).status === 'update available'))
|
|
2151
|
+
result.how_to_update = howToUpdate;
|
|
2152
|
+
if (!local) {
|
|
2153
|
+
result.note = hosted
|
|
2154
|
+
? 'This hosted server cannot see the developer\'s installed skills; only installed_versions was checked.'
|
|
2155
|
+
: 'This server does not look for installed skills; only installed_versions was checked.';
|
|
2156
|
+
if (anyOutdated)
|
|
2157
|
+
result.how_to_update = howToUpdate;
|
|
2158
|
+
return ok(result);
|
|
2159
|
+
}
|
|
2160
|
+
if (installs.length === 0) {
|
|
2161
|
+
result.found = 'No Edgegap skills installed in this machine\'s agent folders, project or Claude Code plugins.';
|
|
2162
|
+
if (anyOutdated)
|
|
2163
|
+
result.how_to_update = howToUpdate;
|
|
2164
|
+
return ok(result);
|
|
2165
|
+
}
|
|
2166
|
+
if (!anyOutdated) {
|
|
2167
|
+
result.status = 'Every installed Edgegap skill is current.';
|
|
2168
|
+
return ok(result);
|
|
2169
|
+
}
|
|
2170
|
+
const plan = report.flatMap(({ install, rows }) => {
|
|
2171
|
+
const names = outdatedOf(rows);
|
|
2172
|
+
if (!names.length)
|
|
2173
|
+
return [];
|
|
2174
|
+
if (install.kind === 'copy') {
|
|
2175
|
+
return names.map((n) => {
|
|
2176
|
+
const bundled = SKILLS_PACK.skills.find((s) => s.name === n)?.version;
|
|
2177
|
+
const r = rows.find((x) => x.name === n);
|
|
2178
|
+
const canCopy = bundled && (r.installed === 'no version in its SKILL.md' || compareVersions(r.installed, bundled) < 0);
|
|
2179
|
+
return {
|
|
2180
|
+
skill: install.skills.find((s) => s.name === n),
|
|
2181
|
+
action: canCopy
|
|
2182
|
+
? `rewrite ${n} in ${install.skills.find((s) => s.name === n).dir} from this server's bundle (${bundled})`
|
|
2183
|
+
: `${n}: GitHub has ${r.latest} but this server bundles ${bundled ?? 'nothing newer'}; recopy it from github.com/edgegap/llm-agent-skills`,
|
|
2184
|
+
canCopy: Boolean(canCopy),
|
|
2185
|
+
};
|
|
2186
|
+
});
|
|
2187
|
+
}
|
|
2188
|
+
const commands = local.updateCommands(install, names);
|
|
2189
|
+
return [{ commands, action: commands.map((c) => c.join(' ')).join(' && ') }];
|
|
2190
|
+
});
|
|
2191
|
+
if (!apply) {
|
|
2192
|
+
result.would_run = plan.map((p) => p.action);
|
|
2193
|
+
result.next_step = config.readOnly
|
|
2194
|
+
? 'Read-only mode (EDGEGAP_READ_ONLY): this server will not apply updates. Run the commands above yourself.'
|
|
2195
|
+
: 'Ask the developer, then call edgegap_update_skills again with apply=true to run these.';
|
|
2196
|
+
return ok(result);
|
|
2197
|
+
}
|
|
2198
|
+
if (config.readOnly) {
|
|
2199
|
+
return fail('Read-only mode (EDGEGAP_READ_ONLY) is on, so skills are not updated from here. Call without apply to see the commands to run yourself.');
|
|
2200
|
+
}
|
|
2201
|
+
const applied = [];
|
|
2202
|
+
let failed = false;
|
|
2203
|
+
for (const p of plan) {
|
|
2204
|
+
if (p.commands) {
|
|
2205
|
+
for (const cmd of p.commands) {
|
|
2206
|
+
try {
|
|
2207
|
+
const out = await local.env.run(cmd[0], cmd.slice(1), local.env.cwd);
|
|
2208
|
+
applied.push(`ran: ${cmd.join(' ')}${out ? `\n${out.split('\n').slice(-10).join('\n')}` : ''}`);
|
|
2209
|
+
}
|
|
2210
|
+
catch (err) {
|
|
2211
|
+
failed = true;
|
|
2212
|
+
applied.push(`failed: ${err.message.split('\n').slice(0, 12).join('\n')}`);
|
|
2213
|
+
break;
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
else if (p.canCopy && p.skill) {
|
|
2218
|
+
try {
|
|
2219
|
+
applied.push(`updated: ${await local.replaceFromBundle(local.env, p.skill)}`);
|
|
2220
|
+
}
|
|
2221
|
+
catch (err) {
|
|
2222
|
+
failed = true;
|
|
2223
|
+
applied.push(`skipped: ${err.message}`);
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
else {
|
|
2227
|
+
applied.push(`not updated: ${p.action}`);
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
const after = await local.findSkillsInstalls(local.env);
|
|
2231
|
+
result.applied = applied;
|
|
2232
|
+
result.after = after.map((i) => ({ where: i.where, skills: i.skills.map((s) => row(s.name, s.version)) }));
|
|
2233
|
+
result.reload =
|
|
2234
|
+
'The running agent session keeps the skills it already loaded. Start a new session ' +
|
|
2235
|
+
'(in Claude Code, /reload-plugins also works for the plugin) to use the update.';
|
|
2236
|
+
return failed ? { ...ok(result), isError: true } : ok(result);
|
|
2237
|
+
});
|
|
1993
2238
|
for (const skill of SKILLS_PACK.skills) {
|
|
1994
2239
|
// A prompt per skill: in Claude Code these show up as slash commands.
|
|
1995
2240
|
server.registerPrompt(skill.name, {
|
|
@@ -2030,6 +2275,18 @@ function registerSkills(server, tool) {
|
|
|
2030
2275
|
* registry login to this token. Written as the manual path that works today,
|
|
2031
2276
|
* so the agent asks the developer instead of retrying or guessing.
|
|
2032
2277
|
*/
|
|
2278
|
+
/**
|
|
2279
|
+
* The registry tool's answer for a regular API token. Not an error: the tool
|
|
2280
|
+
* did what it can for that token type, and the steps are the next action.
|
|
2281
|
+
* Reported as a failure it counted every regular-token developer as a broken
|
|
2282
|
+
* call, and some agents retried it.
|
|
2283
|
+
*/
|
|
2284
|
+
function manualStepsResult(steps) {
|
|
2285
|
+
return {
|
|
2286
|
+
content: [{ type: 'text', text: `status: manual_steps_required (no credentials returned)\n\n${steps}` }],
|
|
2287
|
+
structuredContent: { status: 'manual_steps_required', credentials_returned: false, steps },
|
|
2288
|
+
};
|
|
2289
|
+
}
|
|
2033
2290
|
function registryCredentialsUnavailable(imageName, tag) {
|
|
2034
2291
|
const image = imageName ?? '<image-name>';
|
|
2035
2292
|
const buildTag = tag ?? '<unique-build-tag>';
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edgegap/mcp",
|
|
3
3
|
"mcpName": "dev.edgegap/mcp",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.10.0",
|
|
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",
|
|
8
8
|
"build": "tsc && chmod +x dist/index.js dist/http.js",
|
|
9
9
|
"typecheck": "tsc --noEmit",
|
|
10
10
|
"typecheck:worker": "tsc -p worker/tsconfig.json --noEmit",
|
|
11
|
-
"test": "node --test test/unit.test.mjs && node test/package.mjs && node test/skills.mjs && node test/smoke.mjs && node test/guards.mjs && node test/elicit.mjs && node test/newtools.mjs && node test/http.mjs && node test/spec.mjs && node test/snapshot.mjs",
|
|
11
|
+
"test": "node --test test/unit.test.mjs && node test/package.mjs && node test/skills.mjs && node test/updateskills.mjs && node test/smoke.mjs && node test/guards.mjs && node test/elicit.mjs && node test/newtools.mjs && node test/http.mjs && node test/spec.mjs && node test/snapshot.mjs",
|
|
12
12
|
"test:unit": "node --test test/unit.test.mjs",
|
|
13
13
|
"snapshot:update": "node test/snapshot.mjs --update",
|
|
14
14
|
"scan": "node scripts/scan-repo.mjs",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"prepublishOnly": "npm run build",
|
|
20
20
|
"sync-skills": "node scripts/sync-skills.mjs",
|
|
21
21
|
"check-skills": "node scripts/sync-skills.mjs --check",
|
|
22
|
-
"test:worker": "node test/worker-telemetry.mjs"
|
|
22
|
+
"test:worker": "node test/worker-telemetry.mjs",
|
|
23
|
+
"bundle": "node scripts/build-mcpb.mjs"
|
|
23
24
|
},
|
|
24
25
|
"keywords": [
|
|
25
26
|
"mcp",
|