gameye-mcp 0.4.0 → 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 +47 -24
- package/dist/dockerfile-check.d.ts +84 -0
- package/dist/dockerfile-check.js +278 -0
- package/dist/env.d.ts +8 -2
- package/dist/env.js +21 -9
- package/dist/generated/skills.d.ts +39 -0
- package/dist/generated/skills.js +220 -0
- package/dist/index.js +8 -3
- package/dist/server.d.ts +16 -2
- package/dist/server.js +34 -3
- package/dist/tokenless.d.ts +36 -0
- package/dist/tokenless.js +97 -0
- package/dist/tools/bundled-skills.d.ts +7 -0
- package/dist/tools/bundled-skills.js +76 -0
- package/dist/tools/common.d.ts +11 -1
- package/dist/tools/common.js +9 -2
- package/dist/tools/context.js +9 -1
- package/dist/tools/dockerfile-check.d.ts +3 -0
- package/dist/tools/dockerfile-check.js +27 -0
- package/dist/tools/register.js +6 -0
- package/dist/tools/skills.js +8 -2
- package/dist/tools/templates.d.ts +3 -0
- package/dist/tools/templates.js +40 -0
- package/dist/types.d.ts +1 -0
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
3
|
import { GameyeClient } from "./client.js";
|
|
4
|
-
import { loadConfigOrExit } from "./env.js";
|
|
4
|
+
import { loadConfigOrExit, NO_TOKEN_NOTICE } from "./env.js";
|
|
5
5
|
import { registerAllTools } from "./tools/register.js";
|
|
6
6
|
import { createServer } from "./server.js";
|
|
7
7
|
import { BETA_NOTICE } from "./beta.js";
|
|
8
8
|
import { VERSION as version } from "./version.js";
|
|
9
9
|
const config = loadConfigOrExit(process.env);
|
|
10
|
-
|
|
10
|
+
// With no token the client gets an empty one so registrars keep their shape;
|
|
11
|
+
// the per-tool token gate stops any request from being built without a token.
|
|
12
|
+
const client = new GameyeClient({ token: config.token ?? "", baseUrl: config.baseUrl, timeoutMs: config.timeoutMs });
|
|
11
13
|
const ctx = {
|
|
12
14
|
environment: config.environment,
|
|
13
15
|
host: config.host,
|
|
14
16
|
baseUrl: config.baseUrl,
|
|
15
17
|
version,
|
|
18
|
+
hasToken: config.hasToken,
|
|
16
19
|
limits: config.limits,
|
|
17
20
|
mask: (text) => client.maskToken(text),
|
|
18
21
|
};
|
|
19
|
-
const server = createServer(version);
|
|
22
|
+
const server = createServer(version, { hasToken: config.hasToken });
|
|
20
23
|
registerAllTools(server, client, ctx);
|
|
21
24
|
// Attribute API traffic to the MCP client (name only) once it has introduced itself.
|
|
22
25
|
server.server.oninitialized = () => client.setClientName(server.server.getClientVersion()?.name);
|
|
@@ -24,3 +27,5 @@ const transport = new StdioServerTransport();
|
|
|
24
27
|
await server.connect(transport);
|
|
25
28
|
console.error(`Gameye MCP server ${version} running on stdio [${ctx.environment} · ${ctx.host}]`);
|
|
26
29
|
console.error(BETA_NOTICE);
|
|
30
|
+
if (!config.hasToken)
|
|
31
|
+
console.error(NO_TOKEN_NOTICE);
|
package/dist/server.d.ts
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
/**
|
|
3
|
-
export
|
|
2
|
+
/** What the server knows about its configuration when it builds the instructions. */
|
|
3
|
+
export interface ServerMode {
|
|
4
|
+
hasToken: boolean;
|
|
5
|
+
}
|
|
6
|
+
/** The engine skills an agent reads after the `gameye` skill, one per supported engine. */
|
|
7
|
+
export declare const ENGINE_SKILLS: readonly string[];
|
|
8
|
+
/** The line, in both modes, naming the tools that read the bundled skills. */
|
|
9
|
+
export declare const BUNDLED_SKILLS_LINE = "This server bundles the Gameye agent skills: list them with gameye_list_skills and read one with gameye_get_skill, starting with the `gameye` skill.";
|
|
10
|
+
/**
|
|
11
|
+
* The instructions sent at initialize. With no token they lead with what works
|
|
12
|
+
* now: the first sentence says no token is configured and names the token-free
|
|
13
|
+
* tools and the first skill to read (R8).
|
|
14
|
+
*/
|
|
15
|
+
export declare function serverInstructions(mode: ServerMode): string;
|
|
16
|
+
/** The MCP server, with instructions for its token mode and the beta notice. */
|
|
17
|
+
export declare function createServer(version: string, mode: ServerMode): McpServer;
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { BETA_NOTICE } from "./beta.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { NO_PASTE_RULE, RESTART_RULE, TOKEN_FREE_TOOLS, TOKEN_SIGNUP_STEPS } from "./tokenless.js";
|
|
4
|
+
/** The engine skills an agent reads after the `gameye` skill, one per supported engine. */
|
|
5
|
+
export const ENGINE_SKILLS = [
|
|
6
|
+
"gameye-unity-server",
|
|
7
|
+
"gameye-unreal-server",
|
|
8
|
+
"gameye-godot-server",
|
|
9
|
+
"gameye-web-server",
|
|
10
|
+
];
|
|
11
|
+
function orList(items, word) {
|
|
12
|
+
return items.length < 2 ? items.join("") : `${items.slice(0, -1).join(", ")} ${word} ${items[items.length - 1]}`;
|
|
13
|
+
}
|
|
14
|
+
/** The line, in both modes, naming the tools that read the bundled skills. */
|
|
15
|
+
export const BUNDLED_SKILLS_LINE = "This server bundles the Gameye agent skills: list them with gameye_list_skills and read one with gameye_get_skill, starting with the `gameye` skill.";
|
|
16
|
+
/**
|
|
17
|
+
* The instructions sent at initialize. With no token they lead with what works
|
|
18
|
+
* now: the first sentence says no token is configured and names the token-free
|
|
19
|
+
* tools and the first skill to read (R8).
|
|
20
|
+
*/
|
|
21
|
+
export function serverInstructions(mode) {
|
|
22
|
+
if (mode.hasToken)
|
|
23
|
+
return `${BETA_NOTICE}\n${BUNDLED_SKILLS_LINE}`;
|
|
24
|
+
return [
|
|
25
|
+
`No Gameye API token is configured, so only the token-free tools work: ${orList(TOKEN_FREE_TOOLS, "and")}; ` +
|
|
26
|
+
`read the \`gameye\` skill first with gameye_get_skill, then the skill for the game's engine (${orList(ENGINE_SKILLS, "or")}).`,
|
|
27
|
+
"Every other tool needs a token: without one it returns setup steps and sends nothing to the Gameye API, dry runs included.",
|
|
28
|
+
TOKEN_SIGNUP_STEPS,
|
|
29
|
+
RESTART_RULE,
|
|
30
|
+
NO_PASTE_RULE,
|
|
31
|
+
BETA_NOTICE,
|
|
32
|
+
].join("\n");
|
|
33
|
+
}
|
|
34
|
+
/** The MCP server, with instructions for its token mode and the beta notice. */
|
|
35
|
+
export function createServer(version, mode) {
|
|
36
|
+
return new McpServer({ name: "gameye", version }, { instructions: serverInstructions(mode) });
|
|
6
37
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** The first line of every no-token refusal. Stable: agents and tests match on it. */
|
|
2
|
+
export declare const TOKEN_REQUIRED_MARKER = "Token required: no GAMEYE_API_TOKEN is configured for this server.";
|
|
3
|
+
/**
|
|
4
|
+
* Tools that work without a token. Every other tool needs one: `defineTool`
|
|
5
|
+
* gates any tool that does not set `requiresToken: false`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const TOKEN_FREE_TOOLS: readonly string[];
|
|
8
|
+
/** Every token-free tool description opens with this sentence. */
|
|
9
|
+
export declare const TOKEN_FREE_LEAD = "Works without a Gameye account or token.";
|
|
10
|
+
/** Every account tool description ends with this sentence. */
|
|
11
|
+
export declare const ACCOUNT_TOOL_TAIL = "Needs GAMEYE_API_TOKEN; without one, returns setup steps and sends nothing.";
|
|
12
|
+
/** A tool description with the sentence that says whether it needs a token. */
|
|
13
|
+
export declare function describeTokenNeed(description: string, requiresToken: boolean): string;
|
|
14
|
+
export type ScopeRecipeName = "Observer" | "Operator" | "Deployer" | "Token admin";
|
|
15
|
+
export interface ScopeRecipe {
|
|
16
|
+
name: ScopeRecipeName;
|
|
17
|
+
/** Every scope the recipe grants, including the recipes it builds on. */
|
|
18
|
+
scopes: readonly string[];
|
|
19
|
+
/** What a token with this recipe lets the agent do. */
|
|
20
|
+
summary: string;
|
|
21
|
+
}
|
|
22
|
+
/** The README "Token scopes" recipes, narrowest first. */
|
|
23
|
+
export declare const SCOPE_RECIPES: readonly ScopeRecipe[];
|
|
24
|
+
/** The narrowest recipe for each account tool, from the scope each API operation requires. */
|
|
25
|
+
export declare const TOOL_SCOPE_RECIPE: Readonly<Record<string, ScopeRecipeName>>;
|
|
26
|
+
/** Where a self-serve developer gets a token (sandbox host, this server's default). */
|
|
27
|
+
export declare const TOKEN_SIGNUP_STEPS: string;
|
|
28
|
+
export declare const RESTART_RULE = "The server reads GAMEYE_API_TOKEN once when it starts: after setting or changing it, restart or reconnect the MCP server.";
|
|
29
|
+
export declare const NO_PASTE_RULE = "Do not paste the token into this chat. The user sets it in the server configuration themselves.";
|
|
30
|
+
export declare const TOKEN_FREE_LINE: string;
|
|
31
|
+
/**
|
|
32
|
+
* The refusal an account tool returns when no token is configured. Order per
|
|
33
|
+
* R6: marker; nothing sent; where to get a token; scopes; how to set it per
|
|
34
|
+
* install path; restart; do not paste; what works now.
|
|
35
|
+
*/
|
|
36
|
+
export declare function tokenRequiredMessage(tool: string): string;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// No-token mode: which tools work without GAMEYE_API_TOKEN, the scope recipe
|
|
2
|
+
// each account tool needs, and the refusal an account tool returns when no
|
|
3
|
+
// token is configured. The refusal never asks for the token: credentials stay
|
|
4
|
+
// in the server's environment, read once at start.
|
|
5
|
+
/** The first line of every no-token refusal. Stable: agents and tests match on it. */
|
|
6
|
+
export const TOKEN_REQUIRED_MARKER = "Token required: no GAMEYE_API_TOKEN is configured for this server.";
|
|
7
|
+
/**
|
|
8
|
+
* Tools that work without a token. Every other tool needs one: `defineTool`
|
|
9
|
+
* gates any tool that does not set `requiresToken: false`.
|
|
10
|
+
*/
|
|
11
|
+
export const TOKEN_FREE_TOOLS = [
|
|
12
|
+
"gameye_context",
|
|
13
|
+
"gameye_update_skills",
|
|
14
|
+
"gameye_list_skills",
|
|
15
|
+
"gameye_get_skill",
|
|
16
|
+
"gameye_get_template",
|
|
17
|
+
"gameye_check_dockerfile",
|
|
18
|
+
];
|
|
19
|
+
/** Every token-free tool description opens with this sentence. */
|
|
20
|
+
export const TOKEN_FREE_LEAD = "Works without a Gameye account or token.";
|
|
21
|
+
/** Every account tool description ends with this sentence. */
|
|
22
|
+
export const ACCOUNT_TOOL_TAIL = "Needs GAMEYE_API_TOKEN; without one, returns setup steps and sends nothing.";
|
|
23
|
+
/** A tool description with the sentence that says whether it needs a token. */
|
|
24
|
+
export function describeTokenNeed(description, requiresToken) {
|
|
25
|
+
return requiresToken ? `${description} ${ACCOUNT_TOOL_TAIL}` : `${TOKEN_FREE_LEAD} ${description}`;
|
|
26
|
+
}
|
|
27
|
+
const OBSERVER = ["session:read", "logs:read", "artifact:read", "regions:read", "region:read", "application:read"];
|
|
28
|
+
const OPERATOR = [...OBSERVER, "session:start", "session:stop", "session:write"];
|
|
29
|
+
const DEPLOYER = [...OPERATOR, "application:write"];
|
|
30
|
+
const TOKEN_ADMIN = [...DEPLOYER, "token:write"];
|
|
31
|
+
/** The README "Token scopes" recipes, narrowest first. */
|
|
32
|
+
export const SCOPE_RECIPES = [
|
|
33
|
+
{ name: "Observer", scopes: OBSERVER, summary: "Inspect sessions, logs, artifacts, regions and applications. No changes." },
|
|
34
|
+
{ name: "Operator", scopes: OPERATOR, summary: "Also launch and stop sessions and update session state." },
|
|
35
|
+
{ name: "Deployer", scopes: DEPLOYER, summary: "Also create and edit applications, so the agent can set up a deployment end to end." },
|
|
36
|
+
{ name: "Token admin", scopes: TOKEN_ADMIN, summary: "Also create API tokens." },
|
|
37
|
+
];
|
|
38
|
+
/** The narrowest recipe for each account tool, from the scope each API operation requires. */
|
|
39
|
+
export const TOOL_SCOPE_RECIPE = {
|
|
40
|
+
gameye_list_sessions: "Observer",
|
|
41
|
+
gameye_describe_session: "Observer",
|
|
42
|
+
gameye_get_logs: "Observer",
|
|
43
|
+
gameye_get_artifacts: "Observer",
|
|
44
|
+
gameye_list_regions: "Observer",
|
|
45
|
+
gameye_get_locations: "Observer",
|
|
46
|
+
gameye_check_tag: "Observer",
|
|
47
|
+
gameye_list_applications: "Observer",
|
|
48
|
+
gameye_list_registry_tags: "Observer",
|
|
49
|
+
gameye_launch_session: "Operator",
|
|
50
|
+
gameye_stop_session: "Operator",
|
|
51
|
+
gameye_player_join: "Operator",
|
|
52
|
+
gameye_player_leave: "Operator",
|
|
53
|
+
gameye_enable_tag: "Deployer",
|
|
54
|
+
gameye_create_application: "Deployer",
|
|
55
|
+
gameye_edit_application: "Deployer",
|
|
56
|
+
gameye_create_token: "Token admin",
|
|
57
|
+
};
|
|
58
|
+
/** Where a self-serve developer gets a token (sandbox host, this server's default). */
|
|
59
|
+
export const TOKEN_SIGNUP_STEPS = "Get a token: sign up at https://trial.gameye.com, then in the Gameye Admin Panel open Users → API tokens and create one. " +
|
|
60
|
+
"Self-serve accounts use the sandbox host, which is this server's default (GAMEYE_ENV=sandbox).";
|
|
61
|
+
export const RESTART_RULE = "The server reads GAMEYE_API_TOKEN once when it starts: after setting or changing it, restart or reconnect the MCP server.";
|
|
62
|
+
export const NO_PASTE_RULE = "Do not paste the token into this chat. The user sets it in the server configuration themselves.";
|
|
63
|
+
export const TOKEN_FREE_LINE = `Works now without a token: ${TOKEN_FREE_TOOLS.join(", ")}.`;
|
|
64
|
+
function scopeLine(tool) {
|
|
65
|
+
const name = TOOL_SCOPE_RECIPE[tool];
|
|
66
|
+
const recipe = SCOPE_RECIPES.find((r) => r.name === name);
|
|
67
|
+
if (!recipe) {
|
|
68
|
+
return `Narrowest token scopes for ${tool}: see the Token scopes section of the gameye-mcp README.`;
|
|
69
|
+
}
|
|
70
|
+
return `Narrowest token scopes for ${tool}: ${recipe.name} (${recipe.scopes.join(" ")}). ${recipe.summary}`;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The refusal an account tool returns when no token is configured. Order per
|
|
74
|
+
* R6: marker; nothing sent; where to get a token; scopes; how to set it per
|
|
75
|
+
* install path; restart; do not paste; what works now.
|
|
76
|
+
*/
|
|
77
|
+
export function tokenRequiredMessage(tool) {
|
|
78
|
+
return [
|
|
79
|
+
TOKEN_REQUIRED_MARKER,
|
|
80
|
+
"Nothing was sent to the Gameye API, and retrying this call will not help until a token is configured.",
|
|
81
|
+
"",
|
|
82
|
+
TOKEN_SIGNUP_STEPS,
|
|
83
|
+
"",
|
|
84
|
+
scopeLine(tool),
|
|
85
|
+
"",
|
|
86
|
+
"Set the token where this server is configured:",
|
|
87
|
+
"• Claude Code plugin: enter it in the gameye plugin's API token setting.",
|
|
88
|
+
"• Claude Code CLI: re-add the server in your own terminal, passing the token with the -e GAMEYE_API_TOKEN option of `claude mcp add`.",
|
|
89
|
+
"• Other MCP clients: add GAMEYE_API_TOKEN to the env block of the server's mcpServers entry.",
|
|
90
|
+
"• Docker: keep `-e GAMEYE_API_TOKEN` (no value) in the docker run arguments and set the value in the client's env block, so it never appears on the command line.",
|
|
91
|
+
"",
|
|
92
|
+
RESTART_RULE,
|
|
93
|
+
NO_PASTE_RULE,
|
|
94
|
+
"",
|
|
95
|
+
TOKEN_FREE_LINE,
|
|
96
|
+
].join("\n");
|
|
97
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { type ServerContext } from "./common.js";
|
|
3
|
+
/** The first line of every bundled-skill result. */
|
|
4
|
+
export declare const BUNDLED_PACK_LINE: string;
|
|
5
|
+
export declare const INSTALLED_WINS_LINE = "If an installed copy of the Gameye skills is newer, it wins.";
|
|
6
|
+
export declare const BUNDLED_HEADER: string;
|
|
7
|
+
export declare function registerBundledSkillsTools(server: McpServer, ctx: ServerContext): void;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineTool } from "./common.js";
|
|
3
|
+
import { BUNDLED_SKILLS, BUNDLED_SKILLS_COMMIT, BUNDLED_SKILLS_PACK_VERSION, BUNDLED_SKILLS_TAG, } from "../generated/skills.js";
|
|
4
|
+
/** The first line of every bundled-skill result. */
|
|
5
|
+
export const BUNDLED_PACK_LINE = `Bundled Gameye skills pack: ${BUNDLED_SKILLS_PACK_VERSION} (gameye-skills ${BUNDLED_SKILLS_TAG}, commit ${BUNDLED_SKILLS_COMMIT.slice(0, 7)}).`;
|
|
6
|
+
export const INSTALLED_WINS_LINE = "If an installed copy of the Gameye skills is newer, it wins.";
|
|
7
|
+
export const BUNDLED_HEADER = `${BUNDLED_PACK_LINE}\n${INSTALLED_WINS_LINE}`;
|
|
8
|
+
const SKILL_FILE = "SKILL.md";
|
|
9
|
+
/** Looks like a path escape, an absolute path or a URL rather than a file inside one skill. */
|
|
10
|
+
function unsafeReason(value) {
|
|
11
|
+
if (/^[a-z]:/i.test(value) || (value.startsWith("/") && !value.startsWith("//")) || value.startsWith("\\"))
|
|
12
|
+
return "an absolute path";
|
|
13
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(value) || value.startsWith("//"))
|
|
14
|
+
return "a URL";
|
|
15
|
+
if (value.split(/[\\/]/).includes(".."))
|
|
16
|
+
return "a parent-directory path";
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
function skillNames() {
|
|
20
|
+
return BUNDLED_SKILLS.map((s) => s.name).join(", ");
|
|
21
|
+
}
|
|
22
|
+
function refuse(text) {
|
|
23
|
+
return { text: `${BUNDLED_HEADER}\n\n${text}`, isError: true };
|
|
24
|
+
}
|
|
25
|
+
function filesOf(skill) {
|
|
26
|
+
return Object.keys(skill.files);
|
|
27
|
+
}
|
|
28
|
+
export function registerBundledSkillsTools(server, ctx) {
|
|
29
|
+
defineTool(server, ctx, "gameye_list_skills", {
|
|
30
|
+
title: "List the bundled Gameye skills",
|
|
31
|
+
description: "List the Gameye agent skills bundled with this server: each skill's name, description, version and files, and the bundled pack version. " +
|
|
32
|
+
"Works offline. Read one with gameye_get_skill. If an installed copy of the Gameye skills is newer, it wins.",
|
|
33
|
+
inputSchema: {},
|
|
34
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
35
|
+
requiresToken: false,
|
|
36
|
+
}, async () => {
|
|
37
|
+
const lines = [BUNDLED_HEADER, ""];
|
|
38
|
+
for (const skill of BUNDLED_SKILLS) {
|
|
39
|
+
lines.push(`• ${skill.name} (skill ${skill.version}): ${skill.description}`);
|
|
40
|
+
lines.push(` files: ${filesOf(skill).join(", ")}`);
|
|
41
|
+
}
|
|
42
|
+
return lines.join("\n");
|
|
43
|
+
});
|
|
44
|
+
defineTool(server, ctx, "gameye_get_skill", {
|
|
45
|
+
title: "Read a bundled Gameye skill",
|
|
46
|
+
description: "Read a Gameye agent skill bundled with this server: its SKILL.md, or one of its reference files. " +
|
|
47
|
+
"Works offline and serves only the bundled copy (list names and files with gameye_list_skills). " +
|
|
48
|
+
"If an installed copy of the Gameye skills is newer, it wins.",
|
|
49
|
+
inputSchema: {
|
|
50
|
+
name: z.string().describe("Skill name, e.g. gameye or gameye-containerize"),
|
|
51
|
+
file: z
|
|
52
|
+
.string()
|
|
53
|
+
.optional()
|
|
54
|
+
.describe("File inside the skill, e.g. references/routing.md. Defaults to SKILL.md"),
|
|
55
|
+
},
|
|
56
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
57
|
+
requiresToken: false,
|
|
58
|
+
}, async ({ name, file }) => {
|
|
59
|
+
const nameProblem = unsafeReason(name) ?? (/[\\/]/.test(name) ? "a path" : undefined);
|
|
60
|
+
if (nameProblem)
|
|
61
|
+
return refuse(`Refused: the skill name is ${nameProblem}. Use one of: ${skillNames()}.`);
|
|
62
|
+
const skill = BUNDLED_SKILLS.find((s) => s.name === name);
|
|
63
|
+
// Never echo the supplied name or file: it is user text and may be a pasted token.
|
|
64
|
+
if (!skill)
|
|
65
|
+
return refuse(`No bundled skill has that name. Bundled skills: ${skillNames()}.`);
|
|
66
|
+
const rel = file ?? SKILL_FILE;
|
|
67
|
+
const fileProblem = unsafeReason(rel);
|
|
68
|
+
if (fileProblem) {
|
|
69
|
+
return refuse(`Refused: the file is ${fileProblem}. Files in ${skill.name}: ${filesOf(skill).join(", ")}.`);
|
|
70
|
+
}
|
|
71
|
+
if (!Object.hasOwn(skill.files, rel)) {
|
|
72
|
+
return refuse(`The bundled ${skill.name} skill has no such file. Files: ${filesOf(skill).join(", ")}.`);
|
|
73
|
+
}
|
|
74
|
+
return [BUNDLED_HEADER, `Skill: ${skill.name} ${skill.version} · ${rel}`, "", skill.files[rel]].join("\n");
|
|
75
|
+
});
|
|
76
|
+
}
|
package/dist/tools/common.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export interface ServerContext {
|
|
|
11
11
|
host: string;
|
|
12
12
|
baseUrl: string;
|
|
13
13
|
version: string;
|
|
14
|
+
/** Whether an API token is configured. The context never holds the token itself. */
|
|
15
|
+
hasToken: boolean;
|
|
14
16
|
/** Local launch and stop limits, fixed when the server starts. */
|
|
15
17
|
limits: SessionLimits;
|
|
16
18
|
/** Replace the API token with `***`. Applied to every tool result, success or error. */
|
|
@@ -28,13 +30,21 @@ export interface ToolDefinition<Shape extends z.ZodRawShape> {
|
|
|
28
30
|
annotations: ToolAnnotations;
|
|
29
31
|
/** Extra hint appended to the error text for a GameyeError, e.g. for a 404. */
|
|
30
32
|
errorHint?: (err: GameyeError) => string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the tool needs GAMEYE_API_TOKEN. Defaults to true, so a new tool
|
|
35
|
+
* fails closed: with no token it refuses before its handler runs.
|
|
36
|
+
*/
|
|
37
|
+
requiresToken?: boolean;
|
|
31
38
|
}
|
|
32
39
|
/**
|
|
33
40
|
* Register a tool so that every result starts with the environment and host,
|
|
34
41
|
* has the API token masked (log output, labels and error messages can echo
|
|
35
42
|
* it), and every failure comes back as `isError: true` with the server's details
|
|
36
43
|
* and trace ID instead of being thrown. A GuardError (a refusal before any
|
|
37
|
-
* request) comes back as `isError: true` with its message.
|
|
44
|
+
* request) comes back as `isError: true` with its message. With no token
|
|
45
|
+
* configured, a tool that requires one is refused before its handler runs, so
|
|
46
|
+
* no request (and no dry run or limit check) happens. The description gains
|
|
47
|
+
* the sentence that says whether the tool works without a token.
|
|
38
48
|
*/
|
|
39
49
|
export declare function defineTool<Shape extends z.ZodRawShape>(server: McpServer, ctx: ServerContext, name: string, def: ToolDefinition<Shape>, handler: (args: z.infer<z.ZodObject<Shape>>) => Promise<ToolOutput>): void;
|
|
40
50
|
/** Format labels for display, never showing the value of the `env` label. */
|
package/dist/tools/common.js
CHANGED
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { GameyeError, GameyeTimeoutError, redactLabels } from "../client.js";
|
|
3
3
|
import { resultPrefix } from "../env.js";
|
|
4
4
|
import { GuardError } from "../guards.js";
|
|
5
|
+
import { describeTokenNeed, tokenRequiredMessage } from "../tokenless.js";
|
|
5
6
|
/** Shared `dryRun` input for every tool that sends a write. */
|
|
6
7
|
export const dryRunInput = z
|
|
7
8
|
.boolean()
|
|
@@ -12,9 +13,13 @@ export const dryRunInput = z
|
|
|
12
13
|
* has the API token masked (log output, labels and error messages can echo
|
|
13
14
|
* it), and every failure comes back as `isError: true` with the server's details
|
|
14
15
|
* and trace ID instead of being thrown. A GuardError (a refusal before any
|
|
15
|
-
* request) comes back as `isError: true` with its message.
|
|
16
|
+
* request) comes back as `isError: true` with its message. With no token
|
|
17
|
+
* configured, a tool that requires one is refused before its handler runs, so
|
|
18
|
+
* no request (and no dry run or limit check) happens. The description gains
|
|
19
|
+
* the sentence that says whether the tool works without a token.
|
|
16
20
|
*/
|
|
17
21
|
export function defineTool(server, ctx, name, def, handler) {
|
|
22
|
+
const requiresToken = def.requiresToken !== false;
|
|
18
23
|
const prefix = resultPrefix(ctx);
|
|
19
24
|
const wrap = (text, isError) => ({
|
|
20
25
|
content: [{ type: "text", text: ctx.mask(`${prefix}\n${text}`) }],
|
|
@@ -22,6 +27,8 @@ export function defineTool(server, ctx, name, def, handler) {
|
|
|
22
27
|
});
|
|
23
28
|
const callback = async (args) => {
|
|
24
29
|
try {
|
|
30
|
+
if (requiresToken && !ctx.hasToken)
|
|
31
|
+
throw new GuardError(tokenRequiredMessage(name));
|
|
25
32
|
const out = await handler(args);
|
|
26
33
|
return typeof out === "string" ? wrap(out) : wrap(out.text, out.isError);
|
|
27
34
|
}
|
|
@@ -38,7 +45,7 @@ export function defineTool(server, ctx, name, def, handler) {
|
|
|
38
45
|
};
|
|
39
46
|
server.registerTool(name, {
|
|
40
47
|
title: def.title,
|
|
41
|
-
description: def.description,
|
|
48
|
+
description: describeTokenNeed(def.description, requiresToken),
|
|
42
49
|
inputSchema: def.inputSchema,
|
|
43
50
|
annotations: def.annotations,
|
|
44
51
|
}, callback);
|
package/dist/tools/context.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { AGENT_LABEL_KEY, AGENT_LABEL_VALUE, DEFAULT_SESSION_TTL, DEFAULT_TOKEN_EXPIRY } from "../guards.js";
|
|
2
2
|
import { defineTool } from "./common.js";
|
|
3
3
|
import { BETA_NOTICE } from "../beta.js";
|
|
4
|
+
import { RESTART_RULE, TOKEN_FREE_LINE, TOKEN_SIGNUP_STEPS } from "../tokenless.js";
|
|
4
5
|
export function registerContextTool(server, ctx) {
|
|
5
6
|
defineTool(server, ctx, "gameye_context", {
|
|
6
7
|
title: "Server context",
|
|
7
8
|
description: "Show which Gameye environment and host this server targets, the server version and the guardrail defaults. The environment is fixed when the server starts (GAMEYE_ENV / GAMEYE_API_URL) and cannot be changed by a tool call.",
|
|
8
9
|
inputSchema: {},
|
|
9
10
|
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
11
|
+
requiresToken: false,
|
|
10
12
|
}, async () => [
|
|
11
13
|
BETA_NOTICE,
|
|
12
14
|
`Environment: ${ctx.environment}`,
|
|
13
15
|
`Host: ${ctx.host}`,
|
|
14
16
|
`Base URL: ${ctx.baseUrl}`,
|
|
15
17
|
`Server version: gameye-mcp ${ctx.version}`,
|
|
18
|
+
`Token: ${ctx.hasToken ? "configured" : "not configured"}`,
|
|
16
19
|
"",
|
|
17
20
|
"Guardrail defaults:",
|
|
18
21
|
` Session TTL: ${DEFAULT_SESSION_TTL} when a launch gives no ttl`,
|
|
@@ -25,7 +28,12 @@ export function registerContextTool(server, ctx) {
|
|
|
25
28
|
` Launches: ${ctx.limits.maxLaunches} per server run (GAMEYE_MAX_LAUNCHES)`,
|
|
26
29
|
` Stop: ${ctx.limits.stopOwnOnly ? "only sessions this server launched (GAMEYE_STOP_OWN_ONLY=1)" : "any session the token can see, by exact ID"}`,
|
|
27
30
|
"",
|
|
28
|
-
|
|
31
|
+
...(ctx.hasToken
|
|
32
|
+
? [
|
|
33
|
+
"Token scopes: not introspectable. The Gameye API has no endpoint that reports a token's scopes; a call that needs a missing scope fails with 403 and names the required scope.",
|
|
34
|
+
]
|
|
35
|
+
: ["No API token: account tools refuse and send nothing until a token is set.", TOKEN_FREE_LINE, TOKEN_SIGNUP_STEPS]),
|
|
36
|
+
RESTART_RULE,
|
|
29
37
|
ctx.environment === "custom"
|
|
30
38
|
? "This server uses a non-standard GAMEYE_API_URL."
|
|
31
39
|
: "To target the other environment, configure a second server entry with a different GAMEYE_ENV.",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { checkDockerfile, formatDockerfileReport } from "../dockerfile-check.js";
|
|
3
|
+
import { defineTool } from "./common.js";
|
|
4
|
+
const MAX_DOCKERFILE_CHARS = 200_000;
|
|
5
|
+
export function registerDockerfileCheckTool(server, ctx) {
|
|
6
|
+
defineTool(server, ctx, "gameye_check_dockerfile", {
|
|
7
|
+
title: "Check Dockerfile",
|
|
8
|
+
description: "Check game server Dockerfile text against the gameye-containerize container contract, offline: linux/amd64 base, exposed ports and protocols, exec-form launch without npm/yarn start, no loopback bind, non-root user, and no API token or credential in ENV/ARG. Returns findings with severity, rule code, line, message and fix, plus what the check cannot know. Pass the Dockerfile text itself; this tool reads no files and sends nothing.",
|
|
9
|
+
inputSchema: {
|
|
10
|
+
dockerfile: z
|
|
11
|
+
.string()
|
|
12
|
+
.min(1)
|
|
13
|
+
.max(MAX_DOCKERFILE_CHARS)
|
|
14
|
+
.describe("The full Dockerfile text (not a path)"),
|
|
15
|
+
ports: z
|
|
16
|
+
.array(z.object({
|
|
17
|
+
port: z.number().int().min(1).max(65535).describe("Container port the server binds"),
|
|
18
|
+
protocol: z.enum(["tcp", "udp"]).describe("Protocol the server binds on that port"),
|
|
19
|
+
}))
|
|
20
|
+
.max(64)
|
|
21
|
+
.optional()
|
|
22
|
+
.describe("Optional: the ports and protocols the server binds, to check against EXPOSE"),
|
|
23
|
+
},
|
|
24
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
25
|
+
requiresToken: false,
|
|
26
|
+
}, async ({ dockerfile, ports }) => formatDockerfileReport(checkDockerfile(dockerfile, { ports })));
|
|
27
|
+
}
|
package/dist/tools/register.js
CHANGED
|
@@ -9,6 +9,9 @@ import { registerTokenTools } from "./tokens.js";
|
|
|
9
9
|
import { registerLogTools } from "./logs.js";
|
|
10
10
|
import { registerArtifactTools } from "./artifacts.js";
|
|
11
11
|
import { registerSkillsTools } from "./skills.js";
|
|
12
|
+
import { registerBundledSkillsTools } from "./bundled-skills.js";
|
|
13
|
+
import { registerDockerfileCheckTool } from "./dockerfile-check.js";
|
|
14
|
+
import { registerTemplateTools } from "./templates.js";
|
|
12
15
|
/** Register every tool. */
|
|
13
16
|
export function registerAllTools(server, client, ctx) {
|
|
14
17
|
registerContextTool(server, ctx);
|
|
@@ -22,4 +25,7 @@ export function registerAllTools(server, client, ctx) {
|
|
|
22
25
|
registerArtifactTools(server, client, ctx);
|
|
23
26
|
registerTokenTools(server, client, ctx);
|
|
24
27
|
registerSkillsTools(server, ctx);
|
|
28
|
+
registerBundledSkillsTools(server, ctx);
|
|
29
|
+
registerTemplateTools(server, ctx);
|
|
30
|
+
registerDockerfileCheckTool(server, ctx);
|
|
25
31
|
}
|
package/dist/tools/skills.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineTool } from "./common.js";
|
|
3
3
|
import { compareVersions, defaultSkillsEnv, describeInstall, ENABLE_UPDATE_ENV, fetchLatestPackVersion, findSkillsInstalls, isOutdated, updateCommands, } from "../skills.js";
|
|
4
|
+
import { BUNDLED_SKILLS_PACK_VERSION } from "../generated/skills.js";
|
|
4
5
|
const RELOAD_NOTE = "The running session keeps the skills it already loaded. Start a new session (in Claude Code, /reload-plugins also works for the plugin) to use the update.";
|
|
5
6
|
export function registerSkillsTools(server, ctx, env = defaultSkillsEnv()) {
|
|
6
7
|
defineTool(server, ctx, "gameye_update_skills", {
|
|
@@ -10,7 +11,9 @@ export function registerSkillsTools(server, ctx, env = defaultSkillsEnv()) {
|
|
|
10
11
|
"Without apply it only checks and changes nothing. With apply=true it runs each outdated install's own updater " +
|
|
11
12
|
"(npx skills update for the Gameye skills only, or claude plugin update) when the operator set " +
|
|
12
13
|
`${ENABLE_UPDATE_ENV}=1; otherwise it lists the commands for the user to run. Ask the user before applying. ` +
|
|
13
|
-
|
|
14
|
+
`Also reports the skills pack bundled with this server (${BUNDLED_SKILLS_PACK_VERSION}). ` +
|
|
15
|
+
"Updates come only through those package managers. This server ships a pinned copy of the skills reviewed at build time; " +
|
|
16
|
+
"the skill and template tools never fetch skill text at runtime, and only gameye_update_skills reaches GitHub, when called.",
|
|
14
17
|
inputSchema: {
|
|
15
18
|
apply: z
|
|
16
19
|
.boolean()
|
|
@@ -23,8 +26,10 @@ export function registerSkillsTools(server, ctx, env = defaultSkillsEnv()) {
|
|
|
23
26
|
.describe("The `Pack version:` from the gameye skill you have loaded, used when no install is found on disk"),
|
|
24
27
|
},
|
|
25
28
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
29
|
+
requiresToken: false,
|
|
26
30
|
}, async ({ apply, installedVersion }) => {
|
|
27
31
|
const installs = await findSkillsInstalls(env);
|
|
32
|
+
const bundled = `Bundled with this server: pack ${BUNDLED_SKILLS_PACK_VERSION} (read it with gameye_list_skills and gameye_get_skill)`;
|
|
28
33
|
let latest;
|
|
29
34
|
try {
|
|
30
35
|
latest = await fetchLatestPackVersion(env);
|
|
@@ -33,12 +38,13 @@ export function registerSkillsTools(server, ctx, env = defaultSkillsEnv()) {
|
|
|
33
38
|
const lines = [
|
|
34
39
|
`Could not read the latest Gameye skills pack version from GitHub: ${err instanceof Error ? err.message : String(err)}`,
|
|
35
40
|
"Nothing was updated.",
|
|
41
|
+
bundled,
|
|
36
42
|
];
|
|
37
43
|
for (const install of installs)
|
|
38
44
|
lines.push(`• ${describeInstall(install)}`);
|
|
39
45
|
return { text: lines.join("\n"), isError: true };
|
|
40
46
|
}
|
|
41
|
-
const lines = [`Latest Gameye skills pack: ${latest}
|
|
47
|
+
const lines = [`Latest Gameye skills pack: ${latest}`, bundled];
|
|
42
48
|
if (installs.length === 0) {
|
|
43
49
|
lines.push("No skills CLI or Claude Code plugin install of the Gameye skills was found.");
|
|
44
50
|
if (installedVersion) {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineTool } from "./common.js";
|
|
3
|
+
import { BUNDLED_HEADER } from "./bundled-skills.js";
|
|
4
|
+
import { BUNDLED_TEMPLATES, TEMPLATE_ENGINES, TEMPLATE_KINDS } from "../generated/skills.js";
|
|
5
|
+
/** A fence of backticks longer than any backtick run in the code, so the block cannot close early. */
|
|
6
|
+
function fenceFor(code) {
|
|
7
|
+
const longest = Math.max(0, ...[...code.matchAll(/`+/g)].map((m) => m[0].length));
|
|
8
|
+
return "`".repeat(Math.max(3, longest + 1));
|
|
9
|
+
}
|
|
10
|
+
function formatTemplate(t) {
|
|
11
|
+
const fence = fenceFor(t.code);
|
|
12
|
+
return [
|
|
13
|
+
BUNDLED_HEADER,
|
|
14
|
+
`Template: ${t.engine}/${t.kind}, from the ${t.skill} skill, section "${t.section}".`,
|
|
15
|
+
...(t.note ? ["", `Note: ${t.note}`] : []),
|
|
16
|
+
"",
|
|
17
|
+
`${fence}${t.language}\n${t.code}${fence}`,
|
|
18
|
+
"",
|
|
19
|
+
`Read the rest of the skill with gameye_get_skill (name: "${t.skill}") before adapting this template.`,
|
|
20
|
+
].join("\n");
|
|
21
|
+
}
|
|
22
|
+
export function registerTemplateTools(server, ctx) {
|
|
23
|
+
defineTool(server, ctx, "gameye_get_template", {
|
|
24
|
+
title: "Get an engine's Dockerfile or shutdown-hook template",
|
|
25
|
+
description: "Get the Dockerfile or the shutdown-hook template for an Unreal, Unity, Godot or web game server, word for word as published in the bundled Gameye engine skill, with the skill and section it came from. " +
|
|
26
|
+
"Works offline. Read the rest of the skill with gameye_get_skill. If an installed copy of the Gameye skills is newer, it wins.",
|
|
27
|
+
inputSchema: {
|
|
28
|
+
engine: z.enum(TEMPLATE_ENGINES).describe("Game server engine: unreal, unity, godot or web"),
|
|
29
|
+
kind: z.enum(TEMPLATE_KINDS).describe("Template: dockerfile or shutdown-hook"),
|
|
30
|
+
},
|
|
31
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
32
|
+
requiresToken: false,
|
|
33
|
+
}, async ({ engine, kind }) => {
|
|
34
|
+
const template = BUNDLED_TEMPLATES.find((t) => t.engine === engine && t.kind === kind);
|
|
35
|
+
// The bundler fails the build unless every engine and kind is present.
|
|
36
|
+
if (!template)
|
|
37
|
+
throw new Error(`No bundled ${engine}/${kind} template`);
|
|
38
|
+
return formatTemplate(template);
|
|
39
|
+
});
|
|
40
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -156,6 +156,7 @@ export interface CreateTokenRequest {
|
|
|
156
156
|
expires_after?: string;
|
|
157
157
|
}
|
|
158
158
|
export interface GameyeClientConfig {
|
|
159
|
+
/** API token; empty in no-token mode, where the tool gate keeps every request from being sent. */
|
|
159
160
|
token: string;
|
|
160
161
|
baseUrl: string;
|
|
161
162
|
/** Default per-request timeout in milliseconds. Logs and artifacts get at least 60s and 120s. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gameye-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"mcpName": "io.github.Gameye/gameye-mcp",
|
|
5
5
|
"description": "MCP server for the Gameye game server orchestration API: launch and inspect sessions, check image tags, fetch logs and artifacts from any MCP client",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
"test:smoke": "vitest run --config vitest.smoke.config.ts",
|
|
25
25
|
"sync-spec": "node scripts/sync-spec.mjs",
|
|
26
26
|
"check-spec": "node scripts/sync-spec.mjs --check",
|
|
27
|
+
"sync-skills": "node scripts/sync-skills.mjs",
|
|
28
|
+
"check-skills": "node scripts/sync-skills.mjs --check",
|
|
27
29
|
"prepublishOnly": "npm run build"
|
|
28
30
|
},
|
|
29
31
|
"keywords": [
|