@edgegap/mcp 0.7.1 → 0.9.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/dist/skills.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The Edgegap agent skills, served by this MCP server.
3
3
  *
4
- * The skills (github.com/edgegap/edgegap-agent-skills) are the workflows,
4
+ * The skills (github.com/edgegap/llm-agent-skills) are the workflows,
5
5
  * templates and pitfalls an agent needs to take a game from "works on my
6
6
  * machine" to matched players on a dedicated server. Serving them here means
7
7
  * every agent connected to Edgegap MCP has them, whether or not it can install
@@ -43,6 +43,10 @@ export function mimeType(path) {
43
43
  return 'application/xml';
44
44
  if (/\.(ts|mjs)$/.test(path))
45
45
  return 'text/javascript';
46
+ if (path.endsWith('.html'))
47
+ return 'text/html';
48
+ if (path.endsWith('.css'))
49
+ return 'text/css';
46
50
  return 'text/plain';
47
51
  }
48
52
  /** The skill's other files, so an agent knows what it can fetch next. */
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Finds the copies of the Edgegap skills installed on this machine and updates
3
+ * them. Local (stdio) server only: it reads the developer's home and project
4
+ * folders and can run their package managers, which neither the hosted Worker
5
+ * nor a self-hosted container can or should do.
6
+ *
7
+ * Updates come from two places only: the developer's own package manager (the
8
+ * skills CLI, `claude plugin update`), or the files bundled in this release of
9
+ * @edgegap/mcp. Skill text is never downloaded here.
10
+ */
11
+ import { execFile } from 'node:child_process';
12
+ import { lstat, mkdir, readFile, writeFile } from 'node:fs/promises';
13
+ import { homedir } from 'node:os';
14
+ import { dirname, join, resolve, sep } from 'node:path';
15
+ import { SKILLS_PACK } from './skills.js';
16
+ import { SKILL_NAME_RE, compareVersions, skillVersionOf } from './skillsversion.js';
17
+ export function defaultSkillsEnv() {
18
+ return {
19
+ home: homedir(),
20
+ cwd: process.cwd(),
21
+ platform: process.platform,
22
+ readText: (path) => readFile(path, 'utf8').catch(() => undefined),
23
+ writeText: async (path, text) => {
24
+ await mkdir(dirname(path), { recursive: true });
25
+ await writeFile(path, text, 'utf8');
26
+ },
27
+ isManaged: async (dir) => {
28
+ const link = await lstat(dir).then((s) => s.isSymbolicLink()).catch(() => false);
29
+ const git = await lstat(join(dir, '.git')).then(() => true).catch(() => false);
30
+ return link || git;
31
+ },
32
+ run: (cmd, args, cwd) => new Promise((resolvePromise, reject) => {
33
+ // npx and claude are .cmd shims on Windows, which only start through a
34
+ // shell. Every argument here is a fixed flag or a name matching
35
+ // SKILL_NAME_RE, so nothing reaches the shell that could be parsed.
36
+ const win = process.platform === 'win32';
37
+ const child = execFile(cmd, args, {
38
+ cwd,
39
+ shell: win,
40
+ env: { ...process.env, NO_COLOR: '1', FORCE_COLOR: '0', CI: '1' },
41
+ timeout: 120_000,
42
+ killSignal: 'SIGKILL',
43
+ maxBuffer: 4 * 1024 * 1024,
44
+ windowsHide: true,
45
+ }, (err, stdout, stderr) => {
46
+ const out = `${stdout}${stderr}`.replace(/\x1b\[[0-9;?]*[A-Za-z]|\r/g, '').trim();
47
+ if (err)
48
+ reject(new Error(`${cmd} ${args.join(' ')} failed: ${err.message}\n${out}`));
49
+ else
50
+ resolvePromise(out);
51
+ });
52
+ // A prompting CLI fails at once on a closed stdin instead of hanging until the timeout.
53
+ child.stdin?.end();
54
+ }),
55
+ };
56
+ }
57
+ const SOURCE_RE = /^(https:\/\/github\.com\/|git@github\.com:|github:)?edgegap\/(llm-agent-skills|edgegap-agent-skills)(\.git)?\/?$/i;
58
+ // The skills CLI keeps one copy in .agents/skills when it installs for several
59
+ // agents, and copies into the agent's own folder when it installs for one.
60
+ const SKILL_DIRS = ['.agents/skills', '.claude/skills', '.codex/skills', '.cursor/skills', '.config/opencode/skills'];
61
+ const PLUGIN_ID = 'edgegap@edgegap';
62
+ function parseJson(text) {
63
+ if (!text)
64
+ return undefined;
65
+ try {
66
+ return JSON.parse(text);
67
+ }
68
+ catch {
69
+ return undefined;
70
+ }
71
+ }
72
+ /** Skill names a skills CLI lock file records as coming from the Edgegap skills repo. */
73
+ function namesInLock(text) {
74
+ const lock = parseJson(text);
75
+ return Object.entries(lock?.skills ?? {})
76
+ .filter(([name, s]) => SKILL_NAME_RE.test(name) && (SOURCE_RE.test(s?.source ?? '') || SOURCE_RE.test(s?.sourceUrl ?? '')))
77
+ .map(([name]) => name)
78
+ .sort();
79
+ }
80
+ /** The oldest copy of a skill under root's skill folders, so one stale copy still counts. */
81
+ async function readCopies(env, root, name) {
82
+ let oldest;
83
+ for (const d of SKILL_DIRS) {
84
+ const dir = join(root, d, name);
85
+ const text = await env.readText(join(dir, 'SKILL.md'));
86
+ if (text === undefined)
87
+ continue;
88
+ const version = skillVersionOf(text);
89
+ if (!oldest || (version && (!oldest.version || compareVersions(version, oldest.version) < 0)))
90
+ oldest = { name, version, dir };
91
+ }
92
+ return oldest;
93
+ }
94
+ async function cliInstall(env, kind, where, lockPath, root) {
95
+ const names = namesInLock(await env.readText(lockPath));
96
+ if (names.length === 0)
97
+ return undefined;
98
+ const skills = await Promise.all(names.map(async (n) => (await readCopies(env, root, n)) ?? { name: n, dir: join(root, SKILL_DIRS[0], n) }));
99
+ return { kind, where, skills };
100
+ }
101
+ async function pluginInstall(env) {
102
+ const registry = parseJson(await env.readText(join(env.home, '.claude', 'plugins', 'installed_plugins.json')));
103
+ const installPath = registry?.plugins?.[PLUGIN_ID]?.[0]?.installPath;
104
+ if (!installPath)
105
+ return undefined;
106
+ const skills = [];
107
+ for (const s of SKILLS_PACK.skills) {
108
+ const dir = join(installPath, 'skills', s.name);
109
+ const text = await env.readText(join(dir, 'SKILL.md'));
110
+ if (text !== undefined)
111
+ skills.push({ name: s.name, version: skillVersionOf(text), dir });
112
+ }
113
+ return { kind: 'claude-plugin', where: `Claude Code plugin ${PLUGIN_ID}`, skills };
114
+ }
115
+ /** Skills copied by hand into an agent's skills folder: no lock file, no plugin. */
116
+ async function copiedSkills(env, root, where, claimed) {
117
+ const found = [];
118
+ for (const d of SKILL_DIRS) {
119
+ const skills = [];
120
+ for (const s of SKILLS_PACK.skills) {
121
+ const dir = join(root, d, s.name);
122
+ if (claimed.has(dir))
123
+ continue;
124
+ const text = await env.readText(join(dir, 'SKILL.md'));
125
+ // Only the Edgegap skill of that name, not someone's own skill that reuses it.
126
+ if (text === undefined || !text.includes(`name: ${s.name}`))
127
+ continue;
128
+ skills.push({ name: s.name, version: skillVersionOf(text), dir });
129
+ }
130
+ if (skills.length)
131
+ found.push({ kind: 'copy', where: `${where} ${join(root, d)}`, skills });
132
+ }
133
+ return found;
134
+ }
135
+ /** Every install of the Edgegap skills this server can see: user-wide, this project, and the Claude Code plugin. */
136
+ export async function findSkillsInstalls(env) {
137
+ const managed = (await Promise.all([
138
+ cliInstall(env, 'skills-cli-global', 'skills CLI, user-wide', join(env.home, '.agents', '.skill-lock.json'), env.home),
139
+ cliInstall(env, 'skills-cli-project', 'skills CLI, this project', join(env.cwd, 'skills-lock.json'), env.cwd),
140
+ pluginInstall(env),
141
+ ])).filter((i) => i !== undefined);
142
+ // A skills CLI install writes into the same folders as a hand copy; count it once.
143
+ const claimed = new Set();
144
+ for (const i of managed) {
145
+ for (const s of i.skills) {
146
+ for (const root of [env.home, env.cwd])
147
+ for (const d of SKILL_DIRS)
148
+ claimed.add(join(root, d, s.name));
149
+ }
150
+ }
151
+ const copies = [
152
+ ...(await copiedSkills(env, env.home, 'copied user-wide into', claimed)),
153
+ ...(resolve(env.cwd) !== resolve(env.home) ? await copiedSkills(env, env.cwd, 'copied into this project,', claimed) : []),
154
+ ];
155
+ return [...managed, ...copies];
156
+ }
157
+ /** The commands that update a managed install, as argv lists. Copies have none. */
158
+ export function updateCommands(install, outdated) {
159
+ const names = outdated.filter((n) => SKILL_NAME_RE.test(n));
160
+ switch (install.kind) {
161
+ case 'skills-cli-global':
162
+ return [['npx', '-y', 'skills', 'update', ...names, '-g', '-y']];
163
+ case 'skills-cli-project':
164
+ return [['npx', '-y', 'skills', 'update', ...names, '-p', '-y']];
165
+ case 'claude-plugin':
166
+ return [
167
+ ['claude', 'plugin', 'marketplace', 'update', 'edgegap'],
168
+ ['claude', 'plugin', 'update', PLUGIN_ID],
169
+ ];
170
+ case 'copy':
171
+ return [];
172
+ }
173
+ }
174
+ /**
175
+ * Rewrites a hand-copied skill from the files bundled in this release. Files
176
+ * the developer added are left alone. Refused for symlinks and git checkouts:
177
+ * those are someone's working copy, not an install.
178
+ */
179
+ export async function replaceFromBundle(env, skill) {
180
+ const bundled = SKILLS_PACK.skills.find((s) => s.name === skill.name);
181
+ if (!bundled)
182
+ throw new Error(`${skill.name} is not in the bundled pack`);
183
+ if (await env.isManaged(skill.dir)) {
184
+ throw new Error(`${skill.dir} is a symlink or a git checkout, so it was left alone; update it with git`);
185
+ }
186
+ const root = resolve(skill.dir);
187
+ for (const f of bundled.files) {
188
+ const target = resolve(root, ...f.path.split('/'));
189
+ if (!target.startsWith(root + sep))
190
+ throw new Error(`refused to write outside ${root}: ${f.path}`);
191
+ await env.writeText(target, f.content);
192
+ }
193
+ return `${skill.name} ${skill.version ?? '?'} → ${bundled.version} (${bundled.files.length} files from @edgegap/mcp's bundle)`;
194
+ }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Which Edgegap skills pack is the latest, so the skill tools can say when
3
+ * this server, or a copy of the skills on the developer's machine, is behind.
4
+ *
5
+ * Reads only version numbers from github.com/edgegap/llm-agent-skills, never
6
+ * skill text: updated skills reach agents through this server's own release
7
+ * (the bundle in src/skills.generated.ts) or the developer's package manager,
8
+ * not through anything fetched at run time. Uses only fetch, so the hosted
9
+ * Worker can run it too.
10
+ */
11
+ import { SKILLS_PACK } from './skills.js';
12
+ /** raw.githubusercontent.com root of the skills repo's main branch. */
13
+ export const DEFAULT_SKILLS_RAW = 'https://raw.githubusercontent.com/edgegap/llm-agent-skills/main';
14
+ /** Skill names as the pack writes them; anything else is not looked up. */
15
+ export const SKILL_NAME_RE = /^edgegap(?:-[a-z0-9]+)*$/;
16
+ /** Turns EDGEGAP_SKILLS_CHECK and EDGEGAP_SKILLS_RAW_URL into options. */
17
+ export function skillsCheckFromEnv(env) {
18
+ const off = /^(0|off|false|no)$/i.test(env.EDGEGAP_SKILLS_CHECK?.trim() ?? '');
19
+ const raw = env.EDGEGAP_SKILLS_RAW_URL?.trim();
20
+ // Only https, or plain http to this machine for tests.
21
+ const usable = raw && (/^https:\/\/[^/]+/.test(raw) || /^http:\/\/(127\.0\.0\.1|localhost)(:\d+)?(\/|$)/.test(raw));
22
+ return { enabled: !off, rawBase: (usable ? raw : DEFAULT_SKILLS_RAW).replace(/\/+$/, '') };
23
+ }
24
+ /** -1, 0 or 1 for two X.Y.Z versions; anything unparseable sorts first. */
25
+ export function compareVersions(a, b) {
26
+ const parse = (v) => (/^\d+\.\d+\.\d+$/.test(v) ? v.split('.').map(Number) : [-1, -1, -1]);
27
+ const pa = parse(a);
28
+ const pb = parse(b);
29
+ for (let i = 0; i < 3; i++) {
30
+ if (pa[i] !== pb[i])
31
+ return pa[i] < pb[i] ? -1 : 1;
32
+ }
33
+ return 0;
34
+ }
35
+ /** metadata.version from a SKILL.md's frontmatter, e.g. ` version: "0.1.14"`. */
36
+ export function skillVersionOf(skillMd) {
37
+ const fm = skillMd?.replace(/\r\n/g, '\n').match(/^---\n([\s\S]*?)\n---/)?.[1];
38
+ const m = fm?.match(/^metadata:\s*\n(?:[ \t]+.*\n)*?[ \t]+version:\s*["']?(\d+\.\d+\.\d+)["']?\s*$/m);
39
+ return m?.[1];
40
+ }
41
+ async function getText(url, timeoutMs) {
42
+ const res = await fetch(url, { signal: AbortSignal.timeout(timeoutMs) });
43
+ if (!res.ok)
44
+ throw new Error(`GET ${url} returned ${res.status}`);
45
+ return res.text();
46
+ }
47
+ const CACHE_MS = 60 * 60 * 1000;
48
+ let packCache;
49
+ /** The pack version on GitHub main (.claude-plugin/plugin.json), cached for an hour. */
50
+ export async function latestPack(opts) {
51
+ if (!opts.enabled)
52
+ return { error: 'the check is off (EDGEGAP_SKILLS_CHECK=off)' };
53
+ if (packCache && packCache.key === opts.rawBase && Date.now() - packCache.at < CACHE_MS)
54
+ return packCache.value;
55
+ let value;
56
+ try {
57
+ const plugin = JSON.parse(await getText(`${opts.rawBase}/.claude-plugin/plugin.json`, opts.timeoutMs ?? 3_000));
58
+ const v = typeof plugin.version === 'string' && /^\d+\.\d+\.\d+$/.test(plugin.version) ? plugin.version : undefined;
59
+ value = v ? { version: v } : { error: 'plugin.json on GitHub has no X.Y.Z version' };
60
+ }
61
+ catch (err) {
62
+ value = { error: `GitHub could not be reached (${err.message})` };
63
+ }
64
+ // Failures are cached too, so an offline machine pays the timeout once an hour, not per call.
65
+ packCache = { at: Date.now(), key: opts.rawBase, value };
66
+ return value;
67
+ }
68
+ /**
69
+ * Latest version of each named skill: GitHub main where it answers, otherwise
70
+ * the version bundled in this server. `source` says which.
71
+ */
72
+ export async function latestSkillVersions(names, opts) {
73
+ const out = {};
74
+ await Promise.all([...new Set(names)].filter((n) => SKILL_NAME_RE.test(n)).map(async (name) => {
75
+ const bundled = SKILLS_PACK.skills.find((s) => s.name === name)?.version;
76
+ let remote;
77
+ if (opts.enabled) {
78
+ try {
79
+ remote = skillVersionOf(await getText(`${opts.rawBase}/skills/${name}/SKILL.md`, opts.timeoutMs ?? 5_000));
80
+ }
81
+ catch {
82
+ remote = undefined;
83
+ }
84
+ }
85
+ if (remote && (!bundled || compareVersions(remote, bundled) >= 0))
86
+ out[name] = { version: remote, source: 'github' };
87
+ else if (bundled)
88
+ out[name] = { version: bundled, source: 'bundled' };
89
+ else
90
+ out[name] = { source: 'unknown' };
91
+ }));
92
+ return out;
93
+ }
94
+ /** What edgegap_list_skills and edgegap_get_skill say about the pack this server serves. */
95
+ export function servedPackStatus(latest, hosted) {
96
+ if (!latest.version)
97
+ return { latest_pack: `unknown: ${latest.error}` };
98
+ const behind = compareVersions(SKILLS_PACK.version, latest.version) < 0;
99
+ return {
100
+ latest_pack: latest.version,
101
+ served_is_latest: !behind,
102
+ ...(behind
103
+ ? {
104
+ update: hosted
105
+ ? `Pack ${latest.version} is on GitHub; this hosted server still serves ${SKILLS_PACK.version} until its next release. The skills served here are still correct to follow.`
106
+ : `Pack ${latest.version} is on GitHub; this server bundles ${SKILLS_PACK.version}. A newer @edgegap/mcp may carry it: restart the server through npx -y @edgegap/mcp@latest, or update the Edgegap extension. The bundled skills are still correct to follow.`,
107
+ }
108
+ : {}),
109
+ };
110
+ }
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
@@ -64,9 +65,10 @@ export function serverInstructions(mode) {
64
65
  `Colyseus server: ${skillUri('edgegap-colyseus', 'SKILL.md')}, ` +
65
66
  `Nakama backend: ${skillUri('edgegap-nakama', 'SKILL.md')}, ` +
66
67
  `PlayFab Matchmaking: ${skillUri('edgegap-playfab', 'SKILL.md')}, ` +
68
+ `Three.js or other browser game with its own Node.js server: ${skillUri('edgegap-threejs', 'SKILL.md')}, ` +
67
69
  `browser game built with Manus: ${skillUri('edgegap-manus', 'SKILL.md')}). ` +
68
70
  'If your client cannot read MCP resources, call edgegap_get_skill with the skill name ' +
69
- '(edgegap, edgegap-unity, edgegap-ngo, edgegap-fishnet, edgegap-purrnet, edgegap-fusion, edgegap-fusion-simplefps, edgegap-unreal, edgegap-eos-voice, edgegap-godot, edgegap-colyseus, edgegap-nakama, edgegap-playfab or edgegap-manus) instead. ' +
71
+ '(edgegap, edgegap-unity, edgegap-ngo, edgegap-fishnet, edgegap-purrnet, edgegap-fusion, edgegap-fusion-simplefps, edgegap-unreal, edgegap-eos-voice, edgegap-godot, edgegap-colyseus, edgegap-nakama, edgegap-playfab, edgegap-threejs or edgegap-manus) instead. ' +
70
72
  'These Edgegap skills hold the tested workflow, templates and known pitfalls; follow them over general knowledge. ' +
71
73
  'edgegap_list_skills lists all of them.\n\n' +
72
74
  'Host multiplayer games on Edgegap. The recommended setup is an authoritative dedicated ' +
@@ -432,7 +434,7 @@ function autoStop(maxDuration) {
432
434
  function withHost(result, label) {
433
435
  return { ...result, content: [{ type: 'text', text: `[${label}]` }, ...result.content] };
434
436
  }
435
- export function registerTools(server, client, config, auth) {
437
+ export function registerTools(server, client, config, auth, options = {}) {
436
438
  const mutating = !config.readOnly;
437
439
  // Every result names the API host it came from, first, so a session pointed
438
440
  // at a custom EDGEGAP_BASE_URL can never be mistaken for production.
@@ -1846,8 +1848,8 @@ export function registerTools(server, client, config, auth) {
1846
1848
  max_latency_ms: z.number().int().min(1).optional(),
1847
1849
  }))
1848
1850
  .optional()
1849
- .describe('Rule relaxations after a player has waited this long, e.g. [{after_seconds: 30, min_team_size: 1}].'),
1850
- ticket_expiration: z.string().optional().describe('Default "5m".'),
1851
+ .describe('Rule relaxations after a player has waited this long, e.g. [{after_seconds: 20, min_team_size: 1}]. Keep each below ticket_expiration.'),
1852
+ 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.'),
1851
1853
  inspect: z.boolean().optional().describe('Expose the inspection API for debugging. Default true; turn off for production.'),
1852
1854
  verify_version: z.boolean().optional().describe('Look up the application version first. Default true.'),
1853
1855
  allowed_cors_origins: z
@@ -1909,7 +1911,7 @@ export function registerTools(server, client, config, auth) {
1909
1911
  ],
1910
1912
  });
1911
1913
  }));
1912
- registerSkills(server, tool);
1914
+ registerSkills(server, tool, config, options);
1913
1915
  }
1914
1916
  // ==================================================================== skills ====
1915
1917
  /**
@@ -1920,7 +1922,10 @@ export function registerTools(server, client, config, auth) {
1920
1922
  * - resources, one per file: for clients that browse or @-mention resources.
1921
1923
  * All three read the same bundle (src/skills.generated.ts). No token, no network.
1922
1924
  */
1923
- function registerSkills(server, tool) {
1925
+ function registerSkills(server, tool, config, options) {
1926
+ const hosted = config.transport === 'hosted';
1927
+ const check = options.skillsCheck ?? skillsCheckFromEnv(typeof process === 'undefined' ? {} : process.env);
1928
+ const local = hosted ? undefined : options.localSkills;
1924
1929
  const names = SKILLS_PACK.skills.map((s) => s.name);
1925
1930
  const pack = `${SKILLS_PACK.version} (${SKILLS_PACK.commit.slice(0, 7)})`;
1926
1931
  const howToFetch = (skill) => `Fetch any of these with edgegap_get_skill {skill: "${skill}", file: "<path>"}, or read the ` +
@@ -1935,21 +1940,28 @@ function registerSkills(server, tool) {
1935
1940
  'edgegap-purrnet for Unity with PurrNet, edgegap-fusion for Unity with Photon Fusion 2, edgegap-unity for other Unity projects, edgegap-unreal for Unreal Engine ' +
1936
1941
  '(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, ' +
1937
1942
  'edgegap-colyseus for a Colyseus server, edgegap-nakama for a game with a Nakama backend, edgegap-playfab for a game that keeps PlayFab Matchmaking, ' +
1938
- 'edgegap-manus for a browser game built with Manus, edgegap for any other engine or platform questions; it routes to the rest. No ' +
1939
- 'API call.',
1943
+ 'edgegap-threejs for a Three.js or other browser game with its own Node.js server, ' +
1944
+ 'edgegap-manus for a browser game built with Manus, edgegap for any other engine or platform questions; it routes to the rest. ' +
1945
+ 'Also says whether a newer skills pack is on GitHub (reads one version number, no Edgegap API call).',
1940
1946
  inputSchema: {},
1941
- annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
1942
- }, async () => ok({
1943
- pack,
1944
- source: SKILLS_PACK.source,
1945
- skills: SKILLS_PACK.skills.map((s) => ({
1946
- name: s.name,
1947
- version: s.version,
1948
- description: s.description,
1949
- files: s.files.length,
1950
- })),
1951
- next_step: 'Load the skill that matches the project with edgegap_get_skill, then follow it.',
1952
- }));
1947
+ annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
1948
+ }, async () => {
1949
+ const status = servedPackStatus(await latestPack(check), hosted);
1950
+ return ok({
1951
+ pack,
1952
+ ...status,
1953
+ source: SKILLS_PACK.source,
1954
+ skills: SKILLS_PACK.skills.map((s) => ({
1955
+ name: s.name,
1956
+ version: s.version,
1957
+ description: s.description,
1958
+ files: s.files.length,
1959
+ })),
1960
+ next_step: 'Load the skill that matches the project with edgegap_get_skill, then follow it. ' +
1961
+ 'If the developer also has Edgegap skills installed in their agent (a skills folder or the Claude Code plugin), ' +
1962
+ 'edgegap_update_skills checks whether those copies are current.',
1963
+ });
1964
+ });
1953
1965
  tool('edgegap_get_skill', {
1954
1966
  title: 'Load an Edgegap agent skill',
1955
1967
  description: 'Load one Edgegap agent skill: its SKILL.md (the workflow to follow) by default, or one of ' +
@@ -1958,6 +1970,7 @@ function registerSkills(server, tool) {
1958
1970
  'edgegap-purrnet for Unity with PurrNet, edgegap-fusion for Unity with Photon Fusion 2, edgegap-unity for other Unity projects, edgegap-unreal for Unreal Engine ' +
1959
1971
  '(edgegap-eos-voice for voice chat), edgegap-fusion-simplefps for the Photon Simple FPS sample, edgegap-godot for Godot 4 with a Godot server, ' +
1960
1972
  'edgegap-colyseus for a Colyseus server, edgegap-nakama for a Nakama backend, edgegap-playfab for PlayFab Matchmaking, ' +
1973
+ 'edgegap-threejs for a Three.js/browser game with a Node.js server, ' +
1961
1974
  'edgegap-manus for a browser game built with Manus, edgegap otherwise — and fetch the references and templates it points to as you reach them. No API call.',
1962
1975
  inputSchema: {
1963
1976
  // A string, not an enum: clients cache tool schemas, and a cached enum from an older
@@ -1980,13 +1993,160 @@ function registerSkills(server, tool) {
1980
1993
  return fail(`"${file}" is not a file in the ${skill.name} skill. Its files are:\n` +
1981
1994
  skill.files.map((f) => `- ${f.path}`).join('\n'));
1982
1995
  }
1983
- const header = `${skill.name} ${skill.version} · ${found.path} · pack ${pack}`;
1996
+ const status = found.path === 'SKILL.md' ? servedPackStatus(await latestPack(check), hosted) : undefined;
1997
+ const header = `${skill.name} ${skill.version} · ${found.path} · pack ${pack}` +
1998
+ (status?.update ? `\nNote: ${status.update}` : '');
1984
1999
  const others = found.path === 'SKILL.md' ? fileIndex(skill) : [];
1985
2000
  const footer = others.length
1986
2001
  ? `\n\n---\nOther files in this skill:\n${others.map((p) => `- ${p}`).join('\n')}\n\n${howToFetch(skill.name)}`
1987
2002
  : '';
1988
2003
  return { content: [{ type: 'text', text: `${header}\n\n${found.content}${footer}` }] };
1989
2004
  });
2005
+ tool('edgegap_update_skills', {
2006
+ title: 'Check and update the installed Edgegap skills',
2007
+ description: 'Check whether the Edgegap agent skills installed in the developer\'s agent are the latest, and update them. ' +
2008
+ (hosted
2009
+ ? 'This hosted server cannot see the developer\'s disk: pass installed_versions (each loaded skill\'s ' +
2010
+ 'metadata.version from its SKILL.md frontmatter) and it compares them with the latest on GitHub and says how to update. '
2011
+ : 'Finds installs made with the skills CLI (user-wide or this project), the Claude Code plugin edgegap@edgegap, and skills ' +
2012
+ 'copied by hand into an agent\'s skills folder, and compares each skill with the latest on GitHub. Without apply it only ' +
2013
+ 'checks and changes nothing. With apply=true it runs each outdated install\'s own updater (npx skills update for the Edgegap ' +
2014
+ 'skills only, or claude plugin update) and rewrites hand-copied skills from the files bundled in this server; ask the ' +
2015
+ 'developer before applying. ') +
2016
+ 'Skill text is never downloaded by this tool. The skills served by edgegap_get_skill need no update here.',
2017
+ inputSchema: {
2018
+ ...(local
2019
+ ? {
2020
+ apply: z
2021
+ .boolean()
2022
+ .optional()
2023
+ .describe('Run the updates for outdated installs. Omit or false to only check.'),
2024
+ }
2025
+ : {}),
2026
+ installed_versions: z
2027
+ .record(z.string(), z.string())
2028
+ .optional()
2029
+ .describe('Skill name → version of skills you have loaded from somewhere this server cannot see, e.g. ' +
2030
+ '{"edgegap-unity": "0.1.8"}. The version is metadata.version in the SKILL.md frontmatter.'),
2031
+ },
2032
+ annotations: { readOnlyHint: !local, destructiveHint: false, idempotentHint: true, openWorldHint: true },
2033
+ }, async (args) => {
2034
+ const apply = args.apply === true;
2035
+ const given = Object.entries(args.installed_versions ?? {}).filter(([n]) => SKILL_NAME_RE.test(n));
2036
+ const installs = local ? await local.findSkillsInstalls(local.env) : [];
2037
+ const wanted = [...installs.flatMap((i) => i.skills.map((s) => s.name)), ...given.map(([n]) => n)];
2038
+ const [packLatest, latest] = await Promise.all([latestPack(check), latestSkillVersions(wanted, check)]);
2039
+ const row = (name, installed) => {
2040
+ const l = latest[name];
2041
+ const status = !l?.version || !installed ? 'unknown' : compareVersions(installed, l.version) < 0 ? 'update available' : 'up to date';
2042
+ return {
2043
+ name,
2044
+ installed: installed ?? 'no version in its SKILL.md',
2045
+ latest: l?.version ?? 'unknown (not in the pack)',
2046
+ latest_from: l?.source === 'github' ? 'GitHub main' : l?.source === 'bundled' ? 'this server\'s bundle (GitHub not reachable)' : 'unknown',
2047
+ status,
2048
+ };
2049
+ };
2050
+ const report = installs.map((i) => ({ install: i, rows: i.skills.map((s) => row(s.name, s.version)) }));
2051
+ const outdatedOf = (rows) => rows.filter((r) => r.status !== 'up to date').map((r) => r.name);
2052
+ const result = {
2053
+ latest_pack: packLatest.version ?? `unknown: ${packLatest.error}`,
2054
+ installs: report.map(({ install, rows }) => ({ where: install.where, kind: install.kind, skills: rows })),
2055
+ };
2056
+ if (given.length)
2057
+ result.loaded_skills = given.map(([n, v]) => row(n, v));
2058
+ const anyOutdated = report.some(({ rows }) => outdatedOf(rows).length) || given.some(([n, v]) => row(n, v).status === 'update available');
2059
+ const howToUpdate = 'Reinstall the way they were installed: npx skills add edgegap/llm-agent-skills --skill "*" (add -g for user-wide); ' +
2060
+ 'in Claude Code, /plugin marketplace update edgegap then /plugin update edgegap@edgegap; or copy the skills folders from ' +
2061
+ 'github.com/edgegap/llm-agent-skills again.';
2062
+ if (given.some(([n, v]) => row(n, v).status === 'update available'))
2063
+ result.how_to_update = howToUpdate;
2064
+ if (!local) {
2065
+ result.note = hosted
2066
+ ? 'This hosted server cannot see the developer\'s installed skills; only installed_versions was checked.'
2067
+ : 'This server does not look for installed skills; only installed_versions was checked.';
2068
+ if (anyOutdated)
2069
+ result.how_to_update = howToUpdate;
2070
+ return ok(result);
2071
+ }
2072
+ if (installs.length === 0) {
2073
+ result.found = 'No Edgegap skills installed in this machine\'s agent folders, project or Claude Code plugins.';
2074
+ if (anyOutdated)
2075
+ result.how_to_update = howToUpdate;
2076
+ return ok(result);
2077
+ }
2078
+ if (!anyOutdated) {
2079
+ result.status = 'Every installed Edgegap skill is current.';
2080
+ return ok(result);
2081
+ }
2082
+ const plan = report.flatMap(({ install, rows }) => {
2083
+ const names = outdatedOf(rows);
2084
+ if (!names.length)
2085
+ return [];
2086
+ if (install.kind === 'copy') {
2087
+ return names.map((n) => {
2088
+ const bundled = SKILLS_PACK.skills.find((s) => s.name === n)?.version;
2089
+ const r = rows.find((x) => x.name === n);
2090
+ const canCopy = bundled && (r.installed === 'no version in its SKILL.md' || compareVersions(r.installed, bundled) < 0);
2091
+ return {
2092
+ skill: install.skills.find((s) => s.name === n),
2093
+ action: canCopy
2094
+ ? `rewrite ${n} in ${install.skills.find((s) => s.name === n).dir} from this server's bundle (${bundled})`
2095
+ : `${n}: GitHub has ${r.latest} but this server bundles ${bundled ?? 'nothing newer'}; recopy it from github.com/edgegap/llm-agent-skills`,
2096
+ canCopy: Boolean(canCopy),
2097
+ };
2098
+ });
2099
+ }
2100
+ const commands = local.updateCommands(install, names);
2101
+ return [{ commands, action: commands.map((c) => c.join(' ')).join(' && ') }];
2102
+ });
2103
+ if (!apply) {
2104
+ result.would_run = plan.map((p) => p.action);
2105
+ result.next_step = config.readOnly
2106
+ ? 'Read-only mode (EDGEGAP_READ_ONLY): this server will not apply updates. Run the commands above yourself.'
2107
+ : 'Ask the developer, then call edgegap_update_skills again with apply=true to run these.';
2108
+ return ok(result);
2109
+ }
2110
+ if (config.readOnly) {
2111
+ 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.');
2112
+ }
2113
+ const applied = [];
2114
+ let failed = false;
2115
+ for (const p of plan) {
2116
+ if (p.commands) {
2117
+ for (const cmd of p.commands) {
2118
+ try {
2119
+ const out = await local.env.run(cmd[0], cmd.slice(1), local.env.cwd);
2120
+ applied.push(`ran: ${cmd.join(' ')}${out ? `\n${out.split('\n').slice(-10).join('\n')}` : ''}`);
2121
+ }
2122
+ catch (err) {
2123
+ failed = true;
2124
+ applied.push(`failed: ${err.message.split('\n').slice(0, 12).join('\n')}`);
2125
+ break;
2126
+ }
2127
+ }
2128
+ }
2129
+ else if (p.canCopy && p.skill) {
2130
+ try {
2131
+ applied.push(`updated: ${await local.replaceFromBundle(local.env, p.skill)}`);
2132
+ }
2133
+ catch (err) {
2134
+ failed = true;
2135
+ applied.push(`skipped: ${err.message}`);
2136
+ }
2137
+ }
2138
+ else {
2139
+ applied.push(`not updated: ${p.action}`);
2140
+ }
2141
+ }
2142
+ const after = await local.findSkillsInstalls(local.env);
2143
+ result.applied = applied;
2144
+ result.after = after.map((i) => ({ where: i.where, skills: i.skills.map((s) => row(s.name, s.version)) }));
2145
+ result.reload =
2146
+ 'The running agent session keeps the skills it already loaded. Start a new session ' +
2147
+ '(in Claude Code, /reload-plugins also works for the plugin) to use the update.';
2148
+ return failed ? { ...ok(result), isError: true } : ok(result);
2149
+ });
1990
2150
  for (const skill of SKILLS_PACK.skills) {
1991
2151
  // A prompt per skill: in Claude Code these show up as slash commands.
1992
2152
  server.registerPrompt(skill.name, {
package/dist/version.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * call, and by edgegap_context. Keep in step with package.json and server.json;
4
4
  * test/package.mjs fails the build when they disagree.
5
5
  */
6
- export const VERSION = '0.7.1';
6
+ export const VERSION = '0.9.0';
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@edgegap/mcp",
3
3
  "mcpName": "dev.edgegap/mcp",
4
- "version": "0.7.1",
4
+ "version": "0.9.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",