@player-devtools/mcp 0.15.2 → 0.16.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 +43 -17
- package/dist/cjs/index.cjs +165 -71
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +165 -71
- package/dist/index.mjs +165 -71
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.legacy-esm.js
CHANGED
|
@@ -27,14 +27,6 @@ function resolveBasicPlugin(client, playerId) {
|
|
|
27
27
|
if (!basicPlugin) return { error: "no plugin registered for this player" };
|
|
28
28
|
return { id, player, basicPlugin };
|
|
29
29
|
}
|
|
30
|
-
function ok(value) {
|
|
31
|
-
return { content: [{ type: "text", text: JSON.stringify(value) }] };
|
|
32
|
-
}
|
|
33
|
-
function err(message) {
|
|
34
|
-
return {
|
|
35
|
-
content: [{ type: "text", text: JSON.stringify({ error: message }) }]
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
30
|
function handleGetFlow(client, input) {
|
|
39
31
|
const { playerId } = PlayerInput.parse(input);
|
|
40
32
|
const resolved = resolveBasicPlugin(client, playerId);
|
|
@@ -103,41 +95,16 @@ var playerIdShape2 = {
|
|
|
103
95
|
var GetPlayerStatusInput = z2.object(playerIdShape2);
|
|
104
96
|
function handleListPlayers(client) {
|
|
105
97
|
const { players, current } = client.getState();
|
|
106
|
-
return {
|
|
107
|
-
content: [
|
|
108
|
-
{
|
|
109
|
-
type: "text",
|
|
110
|
-
text: JSON.stringify({
|
|
111
|
-
players: Object.keys(players),
|
|
112
|
-
current: current.player
|
|
113
|
-
})
|
|
114
|
-
}
|
|
115
|
-
]
|
|
116
|
-
};
|
|
98
|
+
return ok({ players: Object.keys(players), current: current.player });
|
|
117
99
|
}
|
|
118
100
|
function handleGetPlayerStatus(client, input) {
|
|
119
101
|
const { playerId } = GetPlayerStatusInput.parse(input);
|
|
120
102
|
const { players, current } = client.getState();
|
|
121
103
|
const id = playerId ?? current.player;
|
|
122
|
-
if (!id) return
|
|
104
|
+
if (!id) return err("no player selected");
|
|
123
105
|
const player = players[id];
|
|
124
|
-
if (!player) return
|
|
125
|
-
return {
|
|
126
|
-
content: [
|
|
127
|
-
{
|
|
128
|
-
type: "text",
|
|
129
|
-
text: JSON.stringify({
|
|
130
|
-
active: player.active,
|
|
131
|
-
plugins: Object.keys(player.plugins)
|
|
132
|
-
})
|
|
133
|
-
}
|
|
134
|
-
]
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
function errorResult(message) {
|
|
138
|
-
return {
|
|
139
|
-
content: [{ type: "text", text: JSON.stringify({ error: message }) }]
|
|
140
|
-
};
|
|
106
|
+
if (!player) return err(`player not found: ${id}`);
|
|
107
|
+
return ok({ active: player.active, plugins: Object.keys(player.plugins) });
|
|
141
108
|
}
|
|
142
109
|
var listPlayersDef = {
|
|
143
110
|
name: "list_players",
|
|
@@ -159,26 +126,18 @@ var describePluginShape = {
|
|
|
159
126
|
pluginId: z3.string().describe("Plugin ID.")
|
|
160
127
|
};
|
|
161
128
|
var DescribePluginInput = z3.object(describePluginShape);
|
|
162
|
-
function err2(message) {
|
|
163
|
-
return {
|
|
164
|
-
content: [{ type: "text", text: JSON.stringify({ error: message }) }]
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
function ok2(value) {
|
|
168
|
-
return { content: [{ type: "text", text: JSON.stringify(value) }] };
|
|
169
|
-
}
|
|
170
129
|
function handleDescribePlugin(client, input) {
|
|
171
130
|
const { playerId, pluginId } = DescribePluginInput.parse(input);
|
|
172
131
|
const { players, current } = client.getState();
|
|
173
132
|
const id = playerId ?? current.player;
|
|
174
|
-
if (!id) return
|
|
133
|
+
if (!id) return err("no player selected");
|
|
175
134
|
const player = players[id];
|
|
176
|
-
if (!player) return
|
|
135
|
+
if (!player) return err(`player not found: ${id}`);
|
|
177
136
|
const plugin = player.plugins[pluginId];
|
|
178
|
-
if (!plugin) return
|
|
137
|
+
if (!plugin) return err(`plugin not found: ${pluginId}`);
|
|
179
138
|
if (!plugin.capabilities)
|
|
180
|
-
return
|
|
181
|
-
return
|
|
139
|
+
return err(`plugin "${pluginId}" has no capabilities declared`);
|
|
140
|
+
return ok(plugin.capabilities);
|
|
182
141
|
}
|
|
183
142
|
var describePluginDef = {
|
|
184
143
|
name: "describe_plugin",
|
|
@@ -200,35 +159,27 @@ var invokeActionShape = {
|
|
|
200
159
|
};
|
|
201
160
|
var SelectPlayerInput = z4.object(selectPlayerShape);
|
|
202
161
|
var InvokeActionInput = z4.object(invokeActionShape);
|
|
203
|
-
function err3(message) {
|
|
204
|
-
return {
|
|
205
|
-
content: [{ type: "text", text: JSON.stringify({ error: message }) }]
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
function ok3(value) {
|
|
209
|
-
return { content: [{ type: "text", text: JSON.stringify(value) }] };
|
|
210
|
-
}
|
|
211
162
|
function handleSelectPlayer(client, input) {
|
|
212
163
|
const { playerId } = SelectPlayerInput.parse(input);
|
|
213
164
|
const { players } = client.getState();
|
|
214
|
-
if (!players[playerId]) return
|
|
165
|
+
if (!players[playerId]) return err(`player not found: ${playerId}`);
|
|
215
166
|
client.selectPlayer(playerId);
|
|
216
|
-
return
|
|
167
|
+
return ok({ selected: playerId });
|
|
217
168
|
}
|
|
218
169
|
function handleInvokeAction(client, input) {
|
|
219
170
|
const { playerId, pluginId, action, payload } = InvokeActionInput.parse(input);
|
|
220
171
|
const { players, current } = client.getState();
|
|
221
172
|
const id = playerId ?? current.player;
|
|
222
|
-
if (!id) return
|
|
173
|
+
if (!id) return err("no player selected");
|
|
223
174
|
const player = players[id];
|
|
224
|
-
if (!player) return
|
|
175
|
+
if (!player) return err(`player not found: ${id}`);
|
|
225
176
|
const plugin = player.plugins[pluginId];
|
|
226
|
-
if (!plugin) return
|
|
177
|
+
if (!plugin) return err(`plugin not found: ${pluginId}`);
|
|
227
178
|
if (plugin.capabilities?.actions && !(action in plugin.capabilities.actions)) {
|
|
228
|
-
return
|
|
179
|
+
return err(`action "${action}" not declared in plugin capabilities`);
|
|
229
180
|
}
|
|
230
181
|
client.handleInteraction({ type: action, payload, target: id });
|
|
231
|
-
return
|
|
182
|
+
return ok({ invoked: action });
|
|
232
183
|
}
|
|
233
184
|
var selectPlayerDef = {
|
|
234
185
|
name: "select_player",
|
|
@@ -243,7 +194,139 @@ var invokeActionDef = {
|
|
|
243
194
|
handle: handleInvokeAction
|
|
244
195
|
};
|
|
245
196
|
|
|
197
|
+
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/tools/flipper.ts
|
|
198
|
+
import { FlipperServerTransport } from "@player-devtools/client-flipper";
|
|
199
|
+
import { z as z5 } from "zod";
|
|
200
|
+
var clientIdShape = {
|
|
201
|
+
clientId: z5.string().optional().describe(
|
|
202
|
+
"Flipper client ID \u2014 a transport-level device/app connection, NOT a Player devtools playerId (see list_players/select_player). A client can be connected, and even activated, before any Player instance on it is visible to those tools. Unlike playerId, there is no 'currently selected' client: omitting this targets every connected client \u2014 for enable/disable, only clients not already in the desired state are messaged."
|
|
203
|
+
)
|
|
204
|
+
};
|
|
205
|
+
var ClientIdInput = z5.object(clientIdShape);
|
|
206
|
+
function asFlipperTransport(transport) {
|
|
207
|
+
return transport instanceof FlipperServerTransport ? transport : null;
|
|
208
|
+
}
|
|
209
|
+
function handleGetFlipperStatus(_client, _args, transport) {
|
|
210
|
+
const flipper = asFlipperTransport(transport);
|
|
211
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
212
|
+
const { connected, host, port } = flipper.getDiagnostics();
|
|
213
|
+
return ok({ connected, host, port });
|
|
214
|
+
}
|
|
215
|
+
function handleGetFlipperConsumers(_client, _args, transport) {
|
|
216
|
+
const flipper = asFlipperTransport(transport);
|
|
217
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
218
|
+
const { owns, refs, activeClientIds, connectedClientIds } = flipper.getDiagnostics();
|
|
219
|
+
return ok({ owns, refs, activeClientIds, connectedClientIds });
|
|
220
|
+
}
|
|
221
|
+
async function handleRestartFlipperServer(_client, _args, transport) {
|
|
222
|
+
const flipper = asFlipperTransport(transport);
|
|
223
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
224
|
+
const result = await flipper.restart();
|
|
225
|
+
if (!result.ok) return err(result.reason);
|
|
226
|
+
return ok({ restarted: true, host: result.host, port: result.port });
|
|
227
|
+
}
|
|
228
|
+
async function handleGetFlipperPluginInstallStatus(_client, _args, transport) {
|
|
229
|
+
const flipper = asFlipperTransport(transport);
|
|
230
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
231
|
+
if (!flipper.getDiagnostics().connected) {
|
|
232
|
+
return err("flipper transport not connected");
|
|
233
|
+
}
|
|
234
|
+
const status = await flipper.getPluginInstallStatus();
|
|
235
|
+
if (!status.installed && status.reason) return err(status.reason);
|
|
236
|
+
return ok(status);
|
|
237
|
+
}
|
|
238
|
+
var getFlipperStatusDef = {
|
|
239
|
+
name: "get_flipper_connection_status",
|
|
240
|
+
description: "Get the MCP server's basic connection health to the shared flipper-server daemon: whether it's connected, and the host/port it's connected to. For ownership/refcount/client info, use get_flipper_consumers instead.",
|
|
241
|
+
inputSchema: {},
|
|
242
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
243
|
+
handle: handleGetFlipperStatus
|
|
244
|
+
};
|
|
245
|
+
var getFlipperConsumersDef = {
|
|
246
|
+
name: "get_flipper_consumers",
|
|
247
|
+
description: "Get who else is attached to the shared flipper-server daemon: whether this process owns it, the daemon-wide refcount (reflects all consumers, not just this process), and the connected/active devtools clients on this connection.",
|
|
248
|
+
inputSchema: {},
|
|
249
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
250
|
+
handle: handleGetFlipperConsumers
|
|
251
|
+
};
|
|
252
|
+
var restartFlipperServerDef = {
|
|
253
|
+
name: "restart_flipper_server",
|
|
254
|
+
description: "Restart the shared flipper-server daemon. Only succeeds when this MCP server owns the daemon and is its sole consumer; otherwise returns a soft error rather than disrupting other consumers.",
|
|
255
|
+
inputSchema: {},
|
|
256
|
+
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
257
|
+
handle: handleRestartFlipperServer
|
|
258
|
+
};
|
|
259
|
+
var getFlipperPluginInstallStatusDef = {
|
|
260
|
+
name: "get_flipper_plugin_install_status",
|
|
261
|
+
description: "Check whether the Player UI Devtools Flipper plugin is installed on the connected daemon.",
|
|
262
|
+
inputSchema: {},
|
|
263
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
264
|
+
handle: handleGetFlipperPluginInstallStatus
|
|
265
|
+
};
|
|
266
|
+
function handleGetFlipperPluginActivationStatus(_client, _args, transport) {
|
|
267
|
+
const flipper = asFlipperTransport(transport);
|
|
268
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
269
|
+
const { connected, connectedClientIds, activeClientIds } = flipper.getDiagnostics();
|
|
270
|
+
if (!connected) return err("flipper transport not connected");
|
|
271
|
+
const active = new Set(activeClientIds);
|
|
272
|
+
return ok({
|
|
273
|
+
activeClientIds,
|
|
274
|
+
inactiveClientIds: connectedClientIds.filter((id) => !active.has(id))
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
async function handleEnableFlipperPlugin(_client, args, transport) {
|
|
278
|
+
const flipper = asFlipperTransport(transport);
|
|
279
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
280
|
+
const { clientId } = ClientIdInput.parse(args);
|
|
281
|
+
try {
|
|
282
|
+
await flipper.enablePlugin(clientId);
|
|
283
|
+
} catch (error) {
|
|
284
|
+
return err(error instanceof Error ? error.message : String(error));
|
|
285
|
+
}
|
|
286
|
+
return ok({ enabled: true, clientId: clientId ?? "all" });
|
|
287
|
+
}
|
|
288
|
+
async function handleDisableFlipperPlugin(_client, args, transport) {
|
|
289
|
+
const flipper = asFlipperTransport(transport);
|
|
290
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
291
|
+
const { clientId } = ClientIdInput.parse(args);
|
|
292
|
+
try {
|
|
293
|
+
await flipper.disablePlugin(clientId);
|
|
294
|
+
} catch (error) {
|
|
295
|
+
return err(error instanceof Error ? error.message : String(error));
|
|
296
|
+
}
|
|
297
|
+
return ok({ disabled: true, clientId: clientId ?? "all" });
|
|
298
|
+
}
|
|
299
|
+
var getFlipperPluginActivationStatusDef = {
|
|
300
|
+
name: "get_flipper_plugin_activation_status",
|
|
301
|
+
description: "Get per-client activation status of the Player UI Devtools Flipper plugin: which connected clients have completed the init handshake (active) versus which are connected but not yet activated (inactive). Distinct from get_flipper_plugin_install_status, which only reports whether the plugin is installed on the daemon, not activated for any specific client.",
|
|
302
|
+
inputSchema: {},
|
|
303
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
304
|
+
handle: handleGetFlipperPluginActivationStatus
|
|
305
|
+
};
|
|
306
|
+
var enableFlipperPluginDef = {
|
|
307
|
+
name: "enable_flipper_plugin",
|
|
308
|
+
description: "Activate the Player UI Devtools Flipper plugin for a client by sending the init handshake (installing the plugin on the daemon first, if needed). Pass clientId to target one client, or omit it to activate every connected client not already active. There is no direct mapping from clientId to the playerId(s) it hosts \u2014 after activating, poll list_players until the expected Player appears.",
|
|
309
|
+
inputSchema: clientIdShape,
|
|
310
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
311
|
+
handle: handleEnableFlipperPlugin
|
|
312
|
+
};
|
|
313
|
+
var disableFlipperPluginDef = {
|
|
314
|
+
name: "disable_flipper_plugin",
|
|
315
|
+
description: "Deactivate the Player UI Devtools Flipper plugin for a client by sending the deinit handshake, without disconnecting it from flipper-server. Pass clientId to target one client, or omit it to deactivate every currently active client.",
|
|
316
|
+
inputSchema: clientIdShape,
|
|
317
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
318
|
+
handle: handleDisableFlipperPlugin
|
|
319
|
+
};
|
|
320
|
+
|
|
246
321
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/tools/index.ts
|
|
322
|
+
function ok(value) {
|
|
323
|
+
return { content: [{ type: "text", text: JSON.stringify(value) }] };
|
|
324
|
+
}
|
|
325
|
+
function err(message) {
|
|
326
|
+
return {
|
|
327
|
+
content: [{ type: "text", text: JSON.stringify({ error: message }) }]
|
|
328
|
+
};
|
|
329
|
+
}
|
|
247
330
|
var TOOL_DEFS = [
|
|
248
331
|
listPlayersDef,
|
|
249
332
|
getPlayerStatusDef,
|
|
@@ -253,7 +336,14 @@ var TOOL_DEFS = [
|
|
|
253
336
|
getPluginDataDef,
|
|
254
337
|
describePluginDef,
|
|
255
338
|
selectPlayerDef,
|
|
256
|
-
invokeActionDef
|
|
339
|
+
invokeActionDef,
|
|
340
|
+
getFlipperStatusDef,
|
|
341
|
+
getFlipperConsumersDef,
|
|
342
|
+
restartFlipperServerDef,
|
|
343
|
+
getFlipperPluginInstallStatusDef,
|
|
344
|
+
getFlipperPluginActivationStatusDef,
|
|
345
|
+
enableFlipperPluginDef,
|
|
346
|
+
disableFlipperPluginDef
|
|
257
347
|
];
|
|
258
348
|
|
|
259
349
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/telemetry/index.ts
|
|
@@ -362,7 +452,7 @@ function allowlistEventProperties(event) {
|
|
|
362
452
|
}
|
|
363
453
|
|
|
364
454
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/telemetry/index.ts
|
|
365
|
-
var MCP_VERSION = true ? "0.
|
|
455
|
+
var MCP_VERSION = true ? "0.16.0" : "unstamped";
|
|
366
456
|
function createAnalytics(server, deps) {
|
|
367
457
|
try {
|
|
368
458
|
const config = resolveTelemetryConfig();
|
|
@@ -422,8 +512,12 @@ var MCPServer = class {
|
|
|
422
512
|
const register = this.server.registerTool.bind(this.server);
|
|
423
513
|
register(
|
|
424
514
|
def.name,
|
|
425
|
-
{
|
|
426
|
-
|
|
515
|
+
{
|
|
516
|
+
description: def.description,
|
|
517
|
+
inputSchema: def.inputSchema,
|
|
518
|
+
annotations: def.annotations
|
|
519
|
+
},
|
|
520
|
+
(args) => def.handle(this.client, args, this.transport)
|
|
427
521
|
);
|
|
428
522
|
}
|
|
429
523
|
}
|
|
@@ -433,10 +527,10 @@ var MCPServer = class {
|
|
|
433
527
|
try {
|
|
434
528
|
await this.transport.connect();
|
|
435
529
|
this.transportConnected = true;
|
|
436
|
-
} catch (
|
|
530
|
+
} catch (err2) {
|
|
437
531
|
console.warn(
|
|
438
532
|
"[MCPServer] Transport connect failed (will operate in disconnected mode):",
|
|
439
|
-
|
|
533
|
+
err2 instanceof Error ? err2.message : err2
|
|
440
534
|
);
|
|
441
535
|
}
|
|
442
536
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -27,14 +27,6 @@ function resolveBasicPlugin(client, playerId) {
|
|
|
27
27
|
if (!basicPlugin) return { error: "no plugin registered for this player" };
|
|
28
28
|
return { id, player, basicPlugin };
|
|
29
29
|
}
|
|
30
|
-
function ok(value) {
|
|
31
|
-
return { content: [{ type: "text", text: JSON.stringify(value) }] };
|
|
32
|
-
}
|
|
33
|
-
function err(message) {
|
|
34
|
-
return {
|
|
35
|
-
content: [{ type: "text", text: JSON.stringify({ error: message }) }]
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
30
|
function handleGetFlow(client, input) {
|
|
39
31
|
const { playerId } = PlayerInput.parse(input);
|
|
40
32
|
const resolved = resolveBasicPlugin(client, playerId);
|
|
@@ -103,41 +95,16 @@ var playerIdShape2 = {
|
|
|
103
95
|
var GetPlayerStatusInput = z2.object(playerIdShape2);
|
|
104
96
|
function handleListPlayers(client) {
|
|
105
97
|
const { players, current } = client.getState();
|
|
106
|
-
return {
|
|
107
|
-
content: [
|
|
108
|
-
{
|
|
109
|
-
type: "text",
|
|
110
|
-
text: JSON.stringify({
|
|
111
|
-
players: Object.keys(players),
|
|
112
|
-
current: current.player
|
|
113
|
-
})
|
|
114
|
-
}
|
|
115
|
-
]
|
|
116
|
-
};
|
|
98
|
+
return ok({ players: Object.keys(players), current: current.player });
|
|
117
99
|
}
|
|
118
100
|
function handleGetPlayerStatus(client, input) {
|
|
119
101
|
const { playerId } = GetPlayerStatusInput.parse(input);
|
|
120
102
|
const { players, current } = client.getState();
|
|
121
103
|
const id = playerId ?? current.player;
|
|
122
|
-
if (!id) return
|
|
104
|
+
if (!id) return err("no player selected");
|
|
123
105
|
const player = players[id];
|
|
124
|
-
if (!player) return
|
|
125
|
-
return {
|
|
126
|
-
content: [
|
|
127
|
-
{
|
|
128
|
-
type: "text",
|
|
129
|
-
text: JSON.stringify({
|
|
130
|
-
active: player.active,
|
|
131
|
-
plugins: Object.keys(player.plugins)
|
|
132
|
-
})
|
|
133
|
-
}
|
|
134
|
-
]
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
function errorResult(message) {
|
|
138
|
-
return {
|
|
139
|
-
content: [{ type: "text", text: JSON.stringify({ error: message }) }]
|
|
140
|
-
};
|
|
106
|
+
if (!player) return err(`player not found: ${id}`);
|
|
107
|
+
return ok({ active: player.active, plugins: Object.keys(player.plugins) });
|
|
141
108
|
}
|
|
142
109
|
var listPlayersDef = {
|
|
143
110
|
name: "list_players",
|
|
@@ -159,26 +126,18 @@ var describePluginShape = {
|
|
|
159
126
|
pluginId: z3.string().describe("Plugin ID.")
|
|
160
127
|
};
|
|
161
128
|
var DescribePluginInput = z3.object(describePluginShape);
|
|
162
|
-
function err2(message) {
|
|
163
|
-
return {
|
|
164
|
-
content: [{ type: "text", text: JSON.stringify({ error: message }) }]
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
function ok2(value) {
|
|
168
|
-
return { content: [{ type: "text", text: JSON.stringify(value) }] };
|
|
169
|
-
}
|
|
170
129
|
function handleDescribePlugin(client, input) {
|
|
171
130
|
const { playerId, pluginId } = DescribePluginInput.parse(input);
|
|
172
131
|
const { players, current } = client.getState();
|
|
173
132
|
const id = playerId ?? current.player;
|
|
174
|
-
if (!id) return
|
|
133
|
+
if (!id) return err("no player selected");
|
|
175
134
|
const player = players[id];
|
|
176
|
-
if (!player) return
|
|
135
|
+
if (!player) return err(`player not found: ${id}`);
|
|
177
136
|
const plugin = player.plugins[pluginId];
|
|
178
|
-
if (!plugin) return
|
|
137
|
+
if (!plugin) return err(`plugin not found: ${pluginId}`);
|
|
179
138
|
if (!plugin.capabilities)
|
|
180
|
-
return
|
|
181
|
-
return
|
|
139
|
+
return err(`plugin "${pluginId}" has no capabilities declared`);
|
|
140
|
+
return ok(plugin.capabilities);
|
|
182
141
|
}
|
|
183
142
|
var describePluginDef = {
|
|
184
143
|
name: "describe_plugin",
|
|
@@ -200,35 +159,27 @@ var invokeActionShape = {
|
|
|
200
159
|
};
|
|
201
160
|
var SelectPlayerInput = z4.object(selectPlayerShape);
|
|
202
161
|
var InvokeActionInput = z4.object(invokeActionShape);
|
|
203
|
-
function err3(message) {
|
|
204
|
-
return {
|
|
205
|
-
content: [{ type: "text", text: JSON.stringify({ error: message }) }]
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
function ok3(value) {
|
|
209
|
-
return { content: [{ type: "text", text: JSON.stringify(value) }] };
|
|
210
|
-
}
|
|
211
162
|
function handleSelectPlayer(client, input) {
|
|
212
163
|
const { playerId } = SelectPlayerInput.parse(input);
|
|
213
164
|
const { players } = client.getState();
|
|
214
|
-
if (!players[playerId]) return
|
|
165
|
+
if (!players[playerId]) return err(`player not found: ${playerId}`);
|
|
215
166
|
client.selectPlayer(playerId);
|
|
216
|
-
return
|
|
167
|
+
return ok({ selected: playerId });
|
|
217
168
|
}
|
|
218
169
|
function handleInvokeAction(client, input) {
|
|
219
170
|
const { playerId, pluginId, action, payload } = InvokeActionInput.parse(input);
|
|
220
171
|
const { players, current } = client.getState();
|
|
221
172
|
const id = playerId ?? current.player;
|
|
222
|
-
if (!id) return
|
|
173
|
+
if (!id) return err("no player selected");
|
|
223
174
|
const player = players[id];
|
|
224
|
-
if (!player) return
|
|
175
|
+
if (!player) return err(`player not found: ${id}`);
|
|
225
176
|
const plugin = player.plugins[pluginId];
|
|
226
|
-
if (!plugin) return
|
|
177
|
+
if (!plugin) return err(`plugin not found: ${pluginId}`);
|
|
227
178
|
if (plugin.capabilities?.actions && !(action in plugin.capabilities.actions)) {
|
|
228
|
-
return
|
|
179
|
+
return err(`action "${action}" not declared in plugin capabilities`);
|
|
229
180
|
}
|
|
230
181
|
client.handleInteraction({ type: action, payload, target: id });
|
|
231
|
-
return
|
|
182
|
+
return ok({ invoked: action });
|
|
232
183
|
}
|
|
233
184
|
var selectPlayerDef = {
|
|
234
185
|
name: "select_player",
|
|
@@ -243,7 +194,139 @@ var invokeActionDef = {
|
|
|
243
194
|
handle: handleInvokeAction
|
|
244
195
|
};
|
|
245
196
|
|
|
197
|
+
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/tools/flipper.ts
|
|
198
|
+
import { FlipperServerTransport } from "@player-devtools/client-flipper";
|
|
199
|
+
import { z as z5 } from "zod";
|
|
200
|
+
var clientIdShape = {
|
|
201
|
+
clientId: z5.string().optional().describe(
|
|
202
|
+
"Flipper client ID \u2014 a transport-level device/app connection, NOT a Player devtools playerId (see list_players/select_player). A client can be connected, and even activated, before any Player instance on it is visible to those tools. Unlike playerId, there is no 'currently selected' client: omitting this targets every connected client \u2014 for enable/disable, only clients not already in the desired state are messaged."
|
|
203
|
+
)
|
|
204
|
+
};
|
|
205
|
+
var ClientIdInput = z5.object(clientIdShape);
|
|
206
|
+
function asFlipperTransport(transport) {
|
|
207
|
+
return transport instanceof FlipperServerTransport ? transport : null;
|
|
208
|
+
}
|
|
209
|
+
function handleGetFlipperStatus(_client, _args, transport) {
|
|
210
|
+
const flipper = asFlipperTransport(transport);
|
|
211
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
212
|
+
const { connected, host, port } = flipper.getDiagnostics();
|
|
213
|
+
return ok({ connected, host, port });
|
|
214
|
+
}
|
|
215
|
+
function handleGetFlipperConsumers(_client, _args, transport) {
|
|
216
|
+
const flipper = asFlipperTransport(transport);
|
|
217
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
218
|
+
const { owns, refs, activeClientIds, connectedClientIds } = flipper.getDiagnostics();
|
|
219
|
+
return ok({ owns, refs, activeClientIds, connectedClientIds });
|
|
220
|
+
}
|
|
221
|
+
async function handleRestartFlipperServer(_client, _args, transport) {
|
|
222
|
+
const flipper = asFlipperTransport(transport);
|
|
223
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
224
|
+
const result = await flipper.restart();
|
|
225
|
+
if (!result.ok) return err(result.reason);
|
|
226
|
+
return ok({ restarted: true, host: result.host, port: result.port });
|
|
227
|
+
}
|
|
228
|
+
async function handleGetFlipperPluginInstallStatus(_client, _args, transport) {
|
|
229
|
+
const flipper = asFlipperTransport(transport);
|
|
230
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
231
|
+
if (!flipper.getDiagnostics().connected) {
|
|
232
|
+
return err("flipper transport not connected");
|
|
233
|
+
}
|
|
234
|
+
const status = await flipper.getPluginInstallStatus();
|
|
235
|
+
if (!status.installed && status.reason) return err(status.reason);
|
|
236
|
+
return ok(status);
|
|
237
|
+
}
|
|
238
|
+
var getFlipperStatusDef = {
|
|
239
|
+
name: "get_flipper_connection_status",
|
|
240
|
+
description: "Get the MCP server's basic connection health to the shared flipper-server daemon: whether it's connected, and the host/port it's connected to. For ownership/refcount/client info, use get_flipper_consumers instead.",
|
|
241
|
+
inputSchema: {},
|
|
242
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
243
|
+
handle: handleGetFlipperStatus
|
|
244
|
+
};
|
|
245
|
+
var getFlipperConsumersDef = {
|
|
246
|
+
name: "get_flipper_consumers",
|
|
247
|
+
description: "Get who else is attached to the shared flipper-server daemon: whether this process owns it, the daemon-wide refcount (reflects all consumers, not just this process), and the connected/active devtools clients on this connection.",
|
|
248
|
+
inputSchema: {},
|
|
249
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
250
|
+
handle: handleGetFlipperConsumers
|
|
251
|
+
};
|
|
252
|
+
var restartFlipperServerDef = {
|
|
253
|
+
name: "restart_flipper_server",
|
|
254
|
+
description: "Restart the shared flipper-server daemon. Only succeeds when this MCP server owns the daemon and is its sole consumer; otherwise returns a soft error rather than disrupting other consumers.",
|
|
255
|
+
inputSchema: {},
|
|
256
|
+
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
257
|
+
handle: handleRestartFlipperServer
|
|
258
|
+
};
|
|
259
|
+
var getFlipperPluginInstallStatusDef = {
|
|
260
|
+
name: "get_flipper_plugin_install_status",
|
|
261
|
+
description: "Check whether the Player UI Devtools Flipper plugin is installed on the connected daemon.",
|
|
262
|
+
inputSchema: {},
|
|
263
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
264
|
+
handle: handleGetFlipperPluginInstallStatus
|
|
265
|
+
};
|
|
266
|
+
function handleGetFlipperPluginActivationStatus(_client, _args, transport) {
|
|
267
|
+
const flipper = asFlipperTransport(transport);
|
|
268
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
269
|
+
const { connected, connectedClientIds, activeClientIds } = flipper.getDiagnostics();
|
|
270
|
+
if (!connected) return err("flipper transport not connected");
|
|
271
|
+
const active = new Set(activeClientIds);
|
|
272
|
+
return ok({
|
|
273
|
+
activeClientIds,
|
|
274
|
+
inactiveClientIds: connectedClientIds.filter((id) => !active.has(id))
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
async function handleEnableFlipperPlugin(_client, args, transport) {
|
|
278
|
+
const flipper = asFlipperTransport(transport);
|
|
279
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
280
|
+
const { clientId } = ClientIdInput.parse(args);
|
|
281
|
+
try {
|
|
282
|
+
await flipper.enablePlugin(clientId);
|
|
283
|
+
} catch (error) {
|
|
284
|
+
return err(error instanceof Error ? error.message : String(error));
|
|
285
|
+
}
|
|
286
|
+
return ok({ enabled: true, clientId: clientId ?? "all" });
|
|
287
|
+
}
|
|
288
|
+
async function handleDisableFlipperPlugin(_client, args, transport) {
|
|
289
|
+
const flipper = asFlipperTransport(transport);
|
|
290
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
291
|
+
const { clientId } = ClientIdInput.parse(args);
|
|
292
|
+
try {
|
|
293
|
+
await flipper.disablePlugin(clientId);
|
|
294
|
+
} catch (error) {
|
|
295
|
+
return err(error instanceof Error ? error.message : String(error));
|
|
296
|
+
}
|
|
297
|
+
return ok({ disabled: true, clientId: clientId ?? "all" });
|
|
298
|
+
}
|
|
299
|
+
var getFlipperPluginActivationStatusDef = {
|
|
300
|
+
name: "get_flipper_plugin_activation_status",
|
|
301
|
+
description: "Get per-client activation status of the Player UI Devtools Flipper plugin: which connected clients have completed the init handshake (active) versus which are connected but not yet activated (inactive). Distinct from get_flipper_plugin_install_status, which only reports whether the plugin is installed on the daemon, not activated for any specific client.",
|
|
302
|
+
inputSchema: {},
|
|
303
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
304
|
+
handle: handleGetFlipperPluginActivationStatus
|
|
305
|
+
};
|
|
306
|
+
var enableFlipperPluginDef = {
|
|
307
|
+
name: "enable_flipper_plugin",
|
|
308
|
+
description: "Activate the Player UI Devtools Flipper plugin for a client by sending the init handshake (installing the plugin on the daemon first, if needed). Pass clientId to target one client, or omit it to activate every connected client not already active. There is no direct mapping from clientId to the playerId(s) it hosts \u2014 after activating, poll list_players until the expected Player appears.",
|
|
309
|
+
inputSchema: clientIdShape,
|
|
310
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
311
|
+
handle: handleEnableFlipperPlugin
|
|
312
|
+
};
|
|
313
|
+
var disableFlipperPluginDef = {
|
|
314
|
+
name: "disable_flipper_plugin",
|
|
315
|
+
description: "Deactivate the Player UI Devtools Flipper plugin for a client by sending the deinit handshake, without disconnecting it from flipper-server. Pass clientId to target one client, or omit it to deactivate every currently active client.",
|
|
316
|
+
inputSchema: clientIdShape,
|
|
317
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
318
|
+
handle: handleDisableFlipperPlugin
|
|
319
|
+
};
|
|
320
|
+
|
|
246
321
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/tools/index.ts
|
|
322
|
+
function ok(value) {
|
|
323
|
+
return { content: [{ type: "text", text: JSON.stringify(value) }] };
|
|
324
|
+
}
|
|
325
|
+
function err(message) {
|
|
326
|
+
return {
|
|
327
|
+
content: [{ type: "text", text: JSON.stringify({ error: message }) }]
|
|
328
|
+
};
|
|
329
|
+
}
|
|
247
330
|
var TOOL_DEFS = [
|
|
248
331
|
listPlayersDef,
|
|
249
332
|
getPlayerStatusDef,
|
|
@@ -253,7 +336,14 @@ var TOOL_DEFS = [
|
|
|
253
336
|
getPluginDataDef,
|
|
254
337
|
describePluginDef,
|
|
255
338
|
selectPlayerDef,
|
|
256
|
-
invokeActionDef
|
|
339
|
+
invokeActionDef,
|
|
340
|
+
getFlipperStatusDef,
|
|
341
|
+
getFlipperConsumersDef,
|
|
342
|
+
restartFlipperServerDef,
|
|
343
|
+
getFlipperPluginInstallStatusDef,
|
|
344
|
+
getFlipperPluginActivationStatusDef,
|
|
345
|
+
enableFlipperPluginDef,
|
|
346
|
+
disableFlipperPluginDef
|
|
257
347
|
];
|
|
258
348
|
|
|
259
349
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/telemetry/index.ts
|
|
@@ -362,7 +452,7 @@ function allowlistEventProperties(event) {
|
|
|
362
452
|
}
|
|
363
453
|
|
|
364
454
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/telemetry/index.ts
|
|
365
|
-
var MCP_VERSION = true ? "0.
|
|
455
|
+
var MCP_VERSION = true ? "0.16.0" : "unstamped";
|
|
366
456
|
function createAnalytics(server, deps) {
|
|
367
457
|
try {
|
|
368
458
|
const config = resolveTelemetryConfig();
|
|
@@ -422,8 +512,12 @@ var MCPServer = class {
|
|
|
422
512
|
const register = this.server.registerTool.bind(this.server);
|
|
423
513
|
register(
|
|
424
514
|
def.name,
|
|
425
|
-
{
|
|
426
|
-
|
|
515
|
+
{
|
|
516
|
+
description: def.description,
|
|
517
|
+
inputSchema: def.inputSchema,
|
|
518
|
+
annotations: def.annotations
|
|
519
|
+
},
|
|
520
|
+
(args) => def.handle(this.client, args, this.transport)
|
|
427
521
|
);
|
|
428
522
|
}
|
|
429
523
|
}
|
|
@@ -433,10 +527,10 @@ var MCPServer = class {
|
|
|
433
527
|
try {
|
|
434
528
|
await this.transport.connect();
|
|
435
529
|
this.transportConnected = true;
|
|
436
|
-
} catch (
|
|
530
|
+
} catch (err2) {
|
|
437
531
|
console.warn(
|
|
438
532
|
"[MCPServer] Transport connect failed (will operate in disconnected mode):",
|
|
439
|
-
|
|
533
|
+
err2 instanceof Error ? err2.message : err2
|
|
440
534
|
);
|
|
441
535
|
}
|
|
442
536
|
}
|