@air-jam/mcp-server 0.9.2 → 1.0.0-beta.1

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/src/tools.ts CHANGED
@@ -1,46 +1,68 @@
1
- import {
2
- inspectGameAgentContract,
3
- } from "@air-jam/devtools-core/agent";
4
- import { inspectProject } from "@air-jam/devtools-core/context";
1
+ import { inspectProject } from "@air-jam/devtools/context";
5
2
  import {
6
3
  getDevStatus,
7
4
  getTopology,
8
5
  resetLocalDev,
9
6
  startDev,
10
7
  stopDev,
11
- } from "@air-jam/devtools-core/dev";
8
+ } from "@air-jam/devtools/dev";
9
+ import {
10
+ gameRunAddressSchema,
11
+ gameRunDiscoverySchema,
12
+ gameRunSteerSchema,
13
+ gameRunWaitSchema,
14
+ startGameRunSchema,
15
+ startPlayGameRunSchema,
16
+ startTestGameRunSchema,
17
+ } from "@air-jam/devtools/game-runs";
12
18
  import {
19
+ captureGameSessionVisuals,
13
20
  closeGameSession,
21
+ controlGameSessionParticipant,
22
+ gameSessionOperationSchemas,
14
23
  invokeGameSessionAction,
24
+ listGameRuns,
25
+ listGameTestProfiles,
26
+ observeGameSession,
15
27
  openGameSession,
28
+ readGameRun,
16
29
  readGameSession,
30
+ readGameSettings,
31
+ replayGameRun,
17
32
  sendGameSessionInput,
18
- } from "@air-jam/devtools-core/game-session";
33
+ startGameRun,
34
+ steerGameRun,
35
+ stopGameRun,
36
+ updateGameSettings,
37
+ waitGameRun,
38
+ } from "@air-jam/devtools/game-session";
39
+ import { inspectGame, listGames } from "@air-jam/devtools/games";
40
+ import { readDevLogs } from "@air-jam/devtools/logs";
41
+ import { getPlatformMachineAuthStatus } from "@air-jam/devtools/platform-auth";
19
42
  import {
20
- inspectGame,
21
- listGames,
22
- listVisualCaptureSummaries,
23
- readVisualCaptureSummary,
24
- } from "@air-jam/devtools-core/games";
25
- import { readDevLogs } from "@air-jam/devtools-core/logs";
26
- import { getPlatformMachineAuthStatus } from "@air-jam/devtools-core/platform-auth";
27
- import { runQualityGate } from "@air-jam/devtools-core/quality";
43
+ runCompleteEvaluation,
44
+ runQualityGate,
45
+ } from "@air-jam/devtools/quality";
28
46
  import {
47
+ archivePlatformRelease,
29
48
  bundleLocalRelease,
49
+ exportPlatformReleaseGeneration,
50
+ finalizePlatformReleaseGeneration,
30
51
  inspectLocalRelease,
31
52
  inspectPlatformRelease,
32
53
  listPlatformReleaseTargets,
33
54
  listPlatformReleases,
34
55
  publishPlatformRelease,
35
56
  submitPlatformRelease,
57
+ uploadPlatformReleaseGeneration,
36
58
  validateLocalRelease,
37
- } from "@air-jam/devtools-core/release";
38
- import {
39
- captureVisuals,
40
- listVisualScenarios,
41
- } from "@air-jam/devtools-core/visual";
42
- import type { ToolExecution } from "@modelcontextprotocol/sdk/types.js";
59
+ } from "@air-jam/devtools/release";
60
+ import type {
61
+ CallToolResult,
62
+ ToolExecution,
63
+ } from "@modelcontextprotocol/sdk/types.js";
43
64
  import { z } from "zod";
65
+ import toolContract from "../tool-contract.json" with { type: "json" };
44
66
 
45
67
  type AirJamProjectMode = "monorepo" | "standalone-game" | "unknown";
46
68
  type AirJamQualityGate =
@@ -55,12 +77,7 @@ type AirJamQualityGate =
55
77
  export type AirJamMcpToolDefinition = {
56
78
  description: string;
57
79
  inputSchema: z.ZodTypeAny;
58
- run: (args: never) => Promise<{
59
- content: Array<{
60
- type: "text";
61
- text: string;
62
- }>;
63
- }>;
80
+ run: (args: never) => Promise<Pick<CallToolResult, "content">>;
64
81
  execution?: ToolExecution;
65
82
  };
66
83
 
@@ -119,19 +136,7 @@ const buildTopologySchema = (projectMode: AirJamProjectMode) =>
119
136
  secure: z.boolean().optional(),
120
137
  });
121
138
 
122
- const buildCaptureVisualsSchema = (projectMode: AirJamProjectMode) =>
123
- z.object({
124
- cwd: z.string().optional(),
125
- gameId: z.string().optional(),
126
- scenarioId: z.string().optional(),
127
- mode:
128
- projectMode === "monorepo"
129
- ? z.enum(["standalone-dev", "arcade-test"]).optional()
130
- : z.literal("standalone-dev").optional(),
131
- secure: z.boolean().optional(),
132
- });
133
-
134
- const buildHarnessModeSchema = (projectMode: AirJamProjectMode) =>
139
+ const buildGameSessionModeSchema = (projectMode: AirJamProjectMode) =>
135
140
  projectMode === "monorepo"
136
141
  ? z.enum(["standalone-dev", "arcade-dev", "arcade-test"]).optional()
137
142
  : z.literal("standalone-dev").optional();
@@ -170,10 +175,30 @@ const RELEASE_SUBMIT_INPUT_SCHEMA = RELEASE_PLATFORM_INPUT_SCHEMA.extend({
170
175
  distDir: z.string().optional(),
171
176
  bundle: z.string().optional(),
172
177
  skipBuild: z.boolean().optional(),
178
+ waitForProcessing: z.boolean().optional(),
179
+ processingTimeoutSeconds: z.number().int().min(1).max(3_600).optional(),
173
180
  publish: z.boolean().optional(),
174
181
  });
175
182
 
176
- const RELEASE_PUBLISH_INPUT_SCHEMA = RELEASE_PLATFORM_INPUT_SCHEMA.extend({
183
+ const RELEASE_UPLOAD_INPUT_SCHEMA = RELEASE_PLATFORM_INPUT_SCHEMA.extend({
184
+ releaseId: z.string().min(1),
185
+ cwd: z.string().optional(),
186
+ bundle: z.string().min(1),
187
+ });
188
+
189
+ const RELEASE_FINALIZE_INPUT_SCHEMA = RELEASE_PLATFORM_INPUT_SCHEMA.extend({
190
+ releaseId: z.string().min(1),
191
+ generationId: z.string().min(1),
192
+ });
193
+
194
+ const RELEASE_EXPORT_INPUT_SCHEMA = RELEASE_PLATFORM_INPUT_SCHEMA.extend({
195
+ releaseId: z.string().min(1),
196
+ generationId: z.string().min(1),
197
+ cwd: z.string().optional(),
198
+ out: z.string().optional(),
199
+ });
200
+
201
+ const RELEASE_MUTATION_INPUT_SCHEMA = RELEASE_PLATFORM_INPUT_SCHEMA.extend({
177
202
  releaseId: z.string().min(1),
178
203
  });
179
204
 
@@ -205,23 +230,6 @@ export const STOP_DEV_INPUT_SCHEMA = z.object({
205
230
  mode: z.enum(["standalone-dev", "arcade-dev", "arcade-test"]).optional(),
206
231
  });
207
232
 
208
- const buildConnectControllerSchema = (projectMode: AirJamProjectMode) =>
209
- z.object({
210
- cwd: z.string().optional(),
211
- gameId: z.string().optional(),
212
- mode: buildHarnessModeSchema(projectMode),
213
- secure: z.boolean().optional(),
214
- roomId: z.string().min(1).optional(),
215
- harnessSessionId: z.string().min(1).optional(),
216
- controllerJoinUrl: z.string().url().optional(),
217
- controllerId: z.string().min(3).optional(),
218
- deviceId: z.string().min(8).optional(),
219
- nickname: z.string().min(1).optional(),
220
- avatarId: z.string().min(1).optional(),
221
- capabilityToken: z.string().min(1).optional(),
222
- timeoutMs: z.number().int().positive().optional(),
223
- });
224
-
225
233
  export const buildToolDefinitions = ({
226
234
  projectMode,
227
235
  }: {
@@ -230,27 +238,15 @@ export const buildToolDefinitions = ({
230
238
  const runQualityGateInputSchema = buildQualityGateSchema(projectMode);
231
239
  const startDevInputSchema = buildStartDevSchema(projectMode);
232
240
  const topologyInputSchema = buildTopologySchema(projectMode);
233
- const captureVisualsInputSchema = buildCaptureVisualsSchema(projectMode);
234
- const inspectGameAgentContractInputSchema = z.object({
235
- cwd: z.string().optional(),
236
- gameId: z.string().optional(),
237
- });
238
- const openGameSessionInputSchema = buildConnectControllerSchema(projectMode);
239
- const gameSessionInputSchema = z.object({
240
- gameSessionId: z.string().min(1),
241
- });
242
- const sendGameSessionInputSchema = gameSessionInputSchema.extend({
243
- input: z.record(z.string(), z.unknown()),
244
- });
245
- const readGameSessionInputSchema = gameSessionInputSchema.extend({
246
- requestSync: z.boolean().optional(),
247
- timeoutMs: z.number().int().positive().optional(),
248
- });
249
- const invokeGameSessionActionInputSchema = gameSessionInputSchema.extend({
250
- actionId: z.string().min(1),
251
- payload: z.unknown().optional(),
252
- timeoutMs: z.number().int().positive().optional(),
241
+ const openGameSessionInputSchema = gameSessionOperationSchemas.open.extend({
242
+ mode: buildGameSessionModeSchema(projectMode),
253
243
  });
244
+ const captureGameSessionInputSchema = gameSessionOperationSchemas.capture;
245
+ const gameSessionInputSchema = gameSessionOperationSchemas.close;
246
+ const sendGameSessionInputSchema = gameSessionOperationSchemas.input;
247
+ const readGameSessionInputSchema = gameSessionOperationSchemas.read;
248
+ const observeGameSessionInputSchema = gameSessionOperationSchemas.observe;
249
+ const invokeGameSessionActionInputSchema = gameSessionOperationSchemas.invoke;
254
250
 
255
251
  return {
256
252
  "airjam.inspect_project": {
@@ -278,13 +274,6 @@ export const buildToolDefinitions = ({
278
274
  run: async ({ cwd, gameId }: { cwd?: string; gameId?: string }) =>
279
275
  withJsonText(await inspectGame({ cwd, gameId })),
280
276
  },
281
- "airjam.inspect_game_agent_contract": {
282
- description:
283
- "Inspect one game's agent contract, including game-specific snapshot description and semantic controller action metadata.",
284
- inputSchema: inspectGameAgentContractInputSchema,
285
- run: async ({ cwd, gameId }: { cwd?: string; gameId?: string }) =>
286
- withJsonText(await inspectGameAgentContract({ cwd, gameId })),
287
- },
288
277
  "airjam.read_logs": {
289
278
  description:
290
279
  "Read the canonical Air Jam unified dev log stream. Start with view=signal and a bounded tail before adding more filters.",
@@ -299,6 +288,13 @@ export const buildToolDefinitions = ({
299
288
  run: async (input: z.infer<typeof runQualityGateInputSchema>) =>
300
289
  withJsonText(await runQualityGate(input)),
301
290
  },
291
+ "airjam.evaluate": {
292
+ description:
293
+ "Run the complete Air Jam game evaluation: typecheck, lint, tests, and a production build. Returns every gate result in one stable document.",
294
+ inputSchema: z.object({ cwd: z.string().optional() }),
295
+ run: async ({ cwd }: { cwd?: string }) =>
296
+ withJsonText(await runCompleteEvaluation({ cwd })),
297
+ },
302
298
  "airjam.auth_status": {
303
299
  description:
304
300
  "Inspect the locally stored Air Jam platform machine session used for hosted release operations.",
@@ -389,9 +385,72 @@ export const buildToolDefinitions = ({
389
385
  }),
390
386
  ),
391
387
  },
388
+ "airjam.release_upload": {
389
+ description:
390
+ "Upload an existing hosted release zip as a new immutable generation and return the exact generation needed for resumable finalization.",
391
+ inputSchema: RELEASE_UPLOAD_INPUT_SCHEMA,
392
+ execution: {
393
+ taskSupport: "required",
394
+ },
395
+ run: async ({
396
+ platformUrl,
397
+ releaseId,
398
+ cwd,
399
+ bundle,
400
+ }: z.infer<typeof RELEASE_UPLOAD_INPUT_SCHEMA>) =>
401
+ withJsonText(
402
+ await uploadPlatformReleaseGeneration({
403
+ platformUrl,
404
+ releaseId,
405
+ cwd,
406
+ bundlePath: bundle,
407
+ }),
408
+ ),
409
+ },
410
+ "airjam.release_finalize": {
411
+ description:
412
+ "Durably enqueue processing for one exact immutable hosted release generation and return its job; use release inspection to follow or recover it.",
413
+ inputSchema: RELEASE_FINALIZE_INPUT_SCHEMA,
414
+ run: async ({
415
+ platformUrl,
416
+ releaseId,
417
+ generationId,
418
+ }: z.infer<typeof RELEASE_FINALIZE_INPUT_SCHEMA>) =>
419
+ withJsonText(
420
+ await finalizePlatformReleaseGeneration({
421
+ platformUrl,
422
+ releaseId,
423
+ generationId,
424
+ }),
425
+ ),
426
+ },
427
+ "airjam.release_export": {
428
+ description:
429
+ "Download one exact immutable hosted release generation without overwriting an existing local archive.",
430
+ inputSchema: RELEASE_EXPORT_INPUT_SCHEMA,
431
+ execution: {
432
+ taskSupport: "required",
433
+ },
434
+ run: async ({
435
+ platformUrl,
436
+ releaseId,
437
+ generationId,
438
+ cwd,
439
+ out,
440
+ }: z.infer<typeof RELEASE_EXPORT_INPUT_SCHEMA>) =>
441
+ withJsonText(
442
+ await exportPlatformReleaseGeneration({
443
+ platformUrl,
444
+ releaseId,
445
+ generationId,
446
+ cwd,
447
+ out,
448
+ }),
449
+ ),
450
+ },
392
451
  "airjam.release_submit": {
393
452
  description:
394
- "Bundle a standalone Air Jam game if needed, upload it as a hosted release draft, finalize it, and optionally publish it.",
453
+ "Bundle a standalone Air Jam game if needed, upload it as a hosted release draft, enqueue durable processing, optionally wait, and optionally publish after readiness.",
395
454
  inputSchema: RELEASE_SUBMIT_INPUT_SCHEMA,
396
455
  execution: {
397
456
  taskSupport: "required",
@@ -404,6 +463,8 @@ export const buildToolDefinitions = ({
404
463
  distDir,
405
464
  bundle,
406
465
  skipBuild,
466
+ waitForProcessing,
467
+ processingTimeoutSeconds,
407
468
  publish,
408
469
  }: z.infer<typeof RELEASE_SUBMIT_INPUT_SCHEMA>) =>
409
470
  withJsonText(
@@ -415,17 +476,21 @@ export const buildToolDefinitions = ({
415
476
  distDir,
416
477
  bundlePath: bundle,
417
478
  skipBuild,
479
+ waitForProcessing,
480
+ ...(processingTimeoutSeconds === undefined
481
+ ? {}
482
+ : { processingTimeoutMs: processingTimeoutSeconds * 1_000 }),
418
483
  publish,
419
484
  }),
420
485
  ),
421
486
  },
422
487
  "airjam.release_publish": {
423
488
  description: "Publish one ready hosted release on the Air Jam platform.",
424
- inputSchema: RELEASE_PUBLISH_INPUT_SCHEMA,
489
+ inputSchema: RELEASE_MUTATION_INPUT_SCHEMA,
425
490
  run: async ({
426
491
  platformUrl,
427
492
  releaseId,
428
- }: z.infer<typeof RELEASE_PUBLISH_INPUT_SCHEMA>) =>
493
+ }: z.infer<typeof RELEASE_MUTATION_INPUT_SCHEMA>) =>
429
494
  withJsonText(
430
495
  await publishPlatformRelease({
431
496
  platformUrl,
@@ -433,6 +498,16 @@ export const buildToolDefinitions = ({
433
498
  }),
434
499
  ),
435
500
  },
501
+ "airjam.release_archive": {
502
+ description:
503
+ "Retire one exact owned hosted release so it can no longer be played.",
504
+ inputSchema: RELEASE_MUTATION_INPUT_SCHEMA,
505
+ run: async ({
506
+ platformUrl,
507
+ releaseId,
508
+ }: z.infer<typeof RELEASE_MUTATION_INPUT_SCHEMA>) =>
509
+ withJsonText(await archivePlatformRelease({ platformUrl, releaseId })),
510
+ },
436
511
  "airjam.start_dev": {
437
512
  description:
438
513
  "Start the Air Jam local dev stack for the current project and return the managed process id plus resolved topology.",
@@ -442,7 +517,7 @@ export const buildToolDefinitions = ({
442
517
  },
443
518
  "airjam.stop_dev": {
444
519
  description:
445
- "Stop one or more Air Jam dev processes previously started by devtools-core.",
520
+ "Stop one or more Air Jam dev processes previously started by devtools.",
446
521
  inputSchema: STOP_DEV_INPUT_SCHEMA,
447
522
  run: async (input: z.infer<typeof STOP_DEV_INPUT_SCHEMA>) =>
448
523
  withJsonText(await stopDev(input)),
@@ -472,44 +547,125 @@ export const buildToolDefinitions = ({
472
547
  run: async (input: z.infer<typeof topologyInputSchema>) =>
473
548
  withJsonText(await getTopology(input)),
474
549
  },
475
- "airjam.list_visual_scenarios": {
550
+ "airjam.list_game_test_profiles": {
476
551
  description:
477
- "Internal experimental visual harness tool: load one game's visual scenario pack and list scenario ids plus harness action metadata.",
478
- inputSchema: INSPECT_GAME_INPUT_SCHEMA,
479
- run: async ({ cwd, gameId }: { cwd?: string; gameId?: string }) =>
480
- withJsonText(await listVisualScenarios({ cwd, gameId })),
552
+ "Discover authored game scenarios and their code, random or model policies. Runs own bounded participant lifetimes, with actual host observations and retained receipts.",
553
+ inputSchema: gameRunDiscoverySchema,
554
+ run: async (input) => withJsonText(await listGameTestProfiles(input)),
481
555
  },
482
- "airjam.capture_visuals": {
556
+ "airjam.start_game_run": {
483
557
  description:
484
- "Internal experimental visual harness tool: run Air Jam visual capture for one game and return artifact metadata and screenshot paths. Prefer embedded browser screenshots for normal visual proof.",
485
- inputSchema: captureVisualsInputSchema,
486
- execution: {
487
- taskSupport: "required",
488
- },
489
- run: async (input: z.infer<typeof captureVisualsInputSchema>) =>
490
- withJsonText(await captureVisuals(input)),
558
+ "Start an authored test (kind=test, profile, policy and budget) or a profile-free model player (kind=play, current room only, optional intent, ten-minute safety deadline and no verdict). Supply a stable UUID runId; retries return the same admission. Play requires the creator's granted current room. Tests may also target owned or headless rooms. Target headless plays with no page on game time, far faster than real time; owned plays the built page. Read or stop by runId.",
559
+ inputSchema: z.object({
560
+ ...z.object(startTestGameRunSchema.shape).partial().shape,
561
+ ...z.object(startPlayGameRunSchema.shape).partial().shape,
562
+ kind: z.enum(["test", "play"]).default("test"),
563
+ runId: startTestGameRunSchema.shape.runId,
564
+ target: startTestGameRunSchema.shape.target,
565
+ }),
566
+ run: async (input) =>
567
+ withJsonText(await startGameRun(startGameRunSchema.parse(input))),
568
+ },
569
+ "airjam.read_game_run": {
570
+ description:
571
+ "Read a run's actual state, controller ownership, counters, terminal reason and cleanup/evidence receipts.",
572
+ inputSchema: gameRunAddressSchema,
573
+ run: async (input) => withJsonText(await readGameRun(input)),
574
+ },
575
+ "airjam.wait_game_run": {
576
+ description:
577
+ "Wait for a terminal run or a bounded timeout. Returns the actual record; a timeout or disconnected client never stops the run.",
578
+ inputSchema: gameRunWaitSchema,
579
+ run: async (input) => withJsonText(await waitGameRun(input)),
580
+ },
581
+ "airjam.replay_game_run": {
582
+ description:
583
+ "Replay an ended headless run from its recorded input log on a fresh copy of the game, with no server or page, and report whether it ends where the run ended: the same agent view, simulation and step.",
584
+ inputSchema: gameRunAddressSchema,
585
+ run: async (input) => withJsonText(await replayGameRun(input)),
586
+ },
587
+ "airjam.stop_game_run": {
588
+ description:
589
+ "Stop a policy run, release its inputs, retain a final actual observation, and disconnect its owned controllers/host. Idempotent.",
590
+ inputSchema: gameRunAddressSchema,
591
+ run: async (input) => withJsonText(await stopGameRun(input)),
592
+ },
593
+ "airjam.steer_game_run": {
594
+ description:
595
+ "Change what one seat of an active run is trying to do, in words its decision-model policy reads, or clear it with null. Never sends a control; the policy still decides. Each change is recorded on the run with its time and source.",
596
+ inputSchema: gameRunSteerSchema,
597
+ run: async (input) => withJsonText(await steerGameRun(input)),
598
+ },
599
+ "airjam.list_game_runs": {
600
+ description:
601
+ "List activities admitted by this project's current session owner.",
602
+ inputSchema: gameRunDiscoverySchema.pick({ cwd: true }),
603
+ run: async (input) => withJsonText(await listGameRuns(input)),
491
604
  },
492
605
  "airjam.open_game_session": {
493
606
  description:
494
- "Open one high-level Air Jam game session by connecting a virtual controller and discovering published semantic game actions for the same room.",
607
+ "Open a separate owned test host with a virtual controller and live semantic actions. Omit roomId/controllerJoinUrl for semantic testing. Explicit room attachments are participant-only: inputs and raw controller tools, no semantic source interpretation or host actions.",
495
608
  inputSchema: openGameSessionInputSchema,
496
609
  run: async (input: z.infer<typeof openGameSessionInputSchema>) =>
497
610
  withJsonText(await openGameSession(input)),
498
611
  },
612
+ "airjam.control_game_session_participant": {
613
+ description:
614
+ "Send a bounded agent participant input, semantic action or release through the actual room. Requires a fresh observed runtime identity and explicit controller-lifetime lease/sequence. Never grants host actions. Retry an unconfirmed command with the identical lease, sequence and envelope; never invent a new sequence to repeat an uncertain action.",
615
+ inputSchema: gameSessionOperationSchemas.control,
616
+ run: async (input: z.infer<typeof gameSessionOperationSchemas.control>) =>
617
+ withJsonText(await controlGameSessionParticipant(input)),
618
+ },
499
619
  "airjam.send_game_session_input": {
500
620
  description:
501
- "Send one real player-style input payload through a previously opened Air Jam game session.",
621
+ "Send a player's declared controls through a previously opened Air Jam game session: a button true or false (false then true is one press), an axis a number from -1 to 1, a stick an { x, y }.",
502
622
  inputSchema: sendGameSessionInputSchema,
503
623
  run: async (input: z.infer<typeof sendGameSessionInputSchema>) =>
504
624
  withJsonText(await sendGameSessionInput(input)),
505
625
  },
506
626
  "airjam.read_game_session": {
507
627
  description:
508
- "Read one high-level Air Jam game session, including runtime controller state plus any available semantic game snapshot.",
628
+ "Read authoritative live state and current semantic actions from an owned game host. Requires semanticAccess=owned-host; never interprets local source for someone else's room.",
509
629
  inputSchema: readGameSessionInputSchema,
510
630
  run: async (input: z.infer<typeof readGameSessionInputSchema>) =>
511
631
  withJsonText(await readGameSession(input)),
512
632
  },
633
+ "airjam.observe_game_session": {
634
+ description:
635
+ "Observe fresh live semantic and host-local state from an owned game, with a bounded real render image when supported. Returns runtime identity, sample interval and surface coverage. Does not join a player or invoke actions; unsupported images are explicit.",
636
+ inputSchema: observeGameSessionInputSchema,
637
+ run: async (input: z.infer<typeof observeGameSessionInputSchema>) => {
638
+ const observation = await observeGameSession(input);
639
+ const { visual, ...metadata } = observation;
640
+ if (visual.status !== "captured") return withJsonText(observation);
641
+ const { data, ...image } = visual.image;
642
+ return {
643
+ content: [
644
+ ...withJsonText({
645
+ ...metadata,
646
+ visual: { status: "captured", image },
647
+ }).content,
648
+ { type: "image" as const, mimeType: image.mimeType, data },
649
+ ],
650
+ };
651
+ },
652
+ },
653
+ "airjam.read_game_settings": {
654
+ description:
655
+ "Read the current settings and revision from an owned live game host.",
656
+ inputSchema: gameSessionOperationSchemas["settings-read"],
657
+ run: async (
658
+ input: z.infer<(typeof gameSessionOperationSchemas)["settings-read"]>,
659
+ ) => withJsonText(await readGameSettings(input)),
660
+ },
661
+ "airjam.update_game_settings": {
662
+ description:
663
+ "Atomically change live settings on an owned game host using its current revision. Non-live settings require a new room.",
664
+ inputSchema: gameSessionOperationSchemas["settings-update"],
665
+ run: async (
666
+ input: z.infer<(typeof gameSessionOperationSchemas)["settings-update"]>,
667
+ ) => withJsonText(await updateGameSettings(input)),
668
+ },
513
669
  "airjam.invoke_game_session_action": {
514
670
  description:
515
671
  "Invoke one discovered game-session action by its unified session action id, without manually choosing between player-semantic and host-staging internals.",
@@ -517,28 +673,19 @@ export const buildToolDefinitions = ({
517
673
  run: async (input: z.infer<typeof invokeGameSessionActionInputSchema>) =>
518
674
  withJsonText(await invokeGameSessionAction(input)),
519
675
  },
676
+ "airjam.capture_game_session_visuals": {
677
+ description:
678
+ "Capture canonical host and controller screenshots from the browser runtime owned by an open game session.",
679
+ inputSchema: captureGameSessionInputSchema,
680
+ run: async (input: z.infer<typeof captureGameSessionInputSchema>) =>
681
+ withJsonText(await captureGameSessionVisuals(input)),
682
+ },
520
683
  "airjam.close_game_session": {
521
684
  description:
522
685
  "Close one previously opened Air Jam game session and disconnect its virtual controller.",
523
686
  inputSchema: gameSessionInputSchema,
524
- run: async ({ gameSessionId }: { gameSessionId: string }) =>
525
- withJsonText(await closeGameSession({ gameSessionId })),
526
- },
527
- "airjam.list_visual_capture_summaries": {
528
- description:
529
- "Internal experimental visual harness tool: list existing visual capture summaries already written under .airjam/artifacts/visual.",
530
- inputSchema: z.object({
531
- cwd: z.string().optional(),
532
- }),
533
- run: async ({ cwd }: { cwd?: string }) =>
534
- withJsonText(await listVisualCaptureSummaries({ cwd })),
535
- },
536
- "airjam.read_visual_capture_summary": {
537
- description:
538
- "Internal experimental visual harness tool: read one visual capture summary for a game from .airjam/artifacts/visual/<game>/capture-summary.json.",
539
- inputSchema: INSPECT_GAME_INPUT_SCHEMA,
540
- run: async ({ cwd, gameId }: { cwd?: string; gameId?: string }) =>
541
- withJsonText(await readVisualCaptureSummary({ cwd, gameId })),
687
+ run: async (input: z.infer<typeof gameSessionInputSchema>) =>
688
+ withJsonText(await closeGameSession(input)),
542
689
  },
543
690
  } as const;
544
691
  };
@@ -548,59 +695,9 @@ export type AirJamMcpToolDefinitions = ReturnType<typeof buildToolDefinitions>;
548
695
  export const getRegisteredToolNamesForProjectMode = (
549
696
  projectMode: AirJamProjectMode,
550
697
  ): ReadonlyArray<keyof AirJamMcpToolDefinitions> => {
551
- if (projectMode === "monorepo") {
552
- return [
553
- "airjam.inspect_project",
554
- "airjam.auth_status",
555
- "airjam.list_games",
556
- "airjam.inspect_game",
557
- "airjam.inspect_game_agent_contract",
558
- "airjam.read_logs",
559
- "airjam.run_quality_gate",
560
- "airjam.release_list",
561
- "airjam.release_inspect",
562
- "airjam.release_publish",
563
- "airjam.start_dev",
564
- "airjam.stop_dev",
565
- "airjam.status",
566
- "airjam.reset_local",
567
- "airjam.topology",
568
- "airjam.open_game_session",
569
- "airjam.send_game_session_input",
570
- "airjam.read_game_session",
571
- "airjam.invoke_game_session_action",
572
- "airjam.close_game_session",
573
- ] as const;
574
- }
575
-
576
- if (projectMode === "standalone-game") {
577
- return [
578
- "airjam.inspect_project",
579
- "airjam.auth_status",
580
- "airjam.list_games",
581
- "airjam.inspect_game",
582
- "airjam.inspect_game_agent_contract",
583
- "airjam.read_logs",
584
- "airjam.run_quality_gate",
585
- "airjam.release_doctor",
586
- "airjam.release_validate",
587
- "airjam.release_bundle",
588
- "airjam.release_list",
589
- "airjam.release_inspect",
590
- "airjam.release_submit",
591
- "airjam.release_publish",
592
- "airjam.start_dev",
593
- "airjam.stop_dev",
594
- "airjam.status",
595
- "airjam.reset_local",
596
- "airjam.topology",
597
- "airjam.open_game_session",
598
- "airjam.send_game_session_input",
599
- "airjam.read_game_session",
600
- "airjam.invoke_game_session_action",
601
- "airjam.close_game_session",
602
- ] as const;
603
- }
604
-
605
- return ["airjam.inspect_project"] as const;
698
+ const mode =
699
+ projectMode === "monorepo" || projectMode === "standalone-game"
700
+ ? projectMode
701
+ : "unknown";
702
+ return toolContract[mode] as ReadonlyArray<keyof AirJamMcpToolDefinitions>;
606
703
  };
package/src/version.ts ADDED
@@ -0,0 +1,15 @@
1
+ import fs from "node:fs";
2
+
3
+ type PackageManifest = {
4
+ version?: unknown;
5
+ };
6
+
7
+ const manifest = JSON.parse(
8
+ fs.readFileSync(new URL("../package.json", import.meta.url), "utf8"),
9
+ ) as PackageManifest;
10
+
11
+ if (typeof manifest.version !== "string" || manifest.version.length === 0) {
12
+ throw new Error("@air-jam/mcp-server package version is missing.");
13
+ }
14
+
15
+ export const AIR_JAM_MCP_SERVER_VERSION = manifest.version;