@player-devtools/mcp 0.15.2-next.0 → 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/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Player instance: list running Players, read their flow / data / logs / config,
|
|
|
6
6
|
inspect plugin state, select a Player, and invoke plugin actions.
|
|
7
7
|
|
|
8
8
|
It is the agent-facing sibling of the [browser extension] and the
|
|
9
|
-
[Flipper plugin](../flipper-plugin): all three are Devtools
|
|
9
|
+
[Flipper plugin](../flipper-plugin): all three are Devtools _clients_ that speak
|
|
10
10
|
to the same Player Devtools plugins over the [messenger](../messenger) protocol.
|
|
11
11
|
The MCP server connects to those plugins through a running
|
|
12
12
|
[`flipper-server`](https://github.com/facebook/flipper) and re-exposes them as
|
|
@@ -61,23 +61,49 @@ The server registers the following tools (defined as `ToolDef`s in
|
|
|
61
61
|
player-scoped tool takes an optional `playerId` and falls back to the currently
|
|
62
62
|
selected Player when it's omitted.
|
|
63
63
|
|
|
64
|
-
| Tool
|
|
65
|
-
|
|
|
66
|
-
| `list_players`
|
|
67
|
-
| `get_player_status` | `playerId?`
|
|
68
|
-
| `get_flow`
|
|
69
|
-
| `get_data`
|
|
70
|
-
| `get_logs`
|
|
71
|
-
| `get_plugin_data`
|
|
72
|
-
| `describe_plugin`
|
|
73
|
-
| `select_player`
|
|
74
|
-
| `invoke_action`
|
|
64
|
+
| Tool | Args | Returns |
|
|
65
|
+
| ------------------- | --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
66
|
+
| `list_players` | — | All known Player instances and which one is selected. |
|
|
67
|
+
| `get_player_status` | `playerId?` | Active status + registered plugin IDs. |
|
|
68
|
+
| `get_flow` | `playerId?` | The current flow (from the basic plugin). |
|
|
69
|
+
| `get_data` | `playerId?` | The current flow data model. |
|
|
70
|
+
| `get_logs` | `playerId?` | Accumulated runtime logs. |
|
|
71
|
+
| `get_plugin_data` | `playerId?`, `pluginId`, `dataKey` | A specific data key from any plugin. |
|
|
72
|
+
| `describe_plugin` | `playerId?`, `pluginId` | The plugin's capability descriptor — the data keys and actions it exposes. **Call this first** to discover what a plugin supports. |
|
|
73
|
+
| `select_player` | `playerId` | Selects a Player as the default target for later calls. |
|
|
74
|
+
| `invoke_action` | `playerId?`, `pluginId`, `action`, `payload?` | Invokes a named action (validated against the plugin's declared capabilities). |
|
|
75
75
|
|
|
76
76
|
A typical agent flow: `list_players` → `select_player` → `describe_plugin` →
|
|
77
77
|
`get_*` / `invoke_action`.
|
|
78
78
|
|
|
79
|
+
### Diagnostics
|
|
80
|
+
|
|
81
|
+
These tools inspect and manage the MCP server's connection to the shared
|
|
82
|
+
[`flipper-server` daemon](#shared-flipper-server-daemon) itself, rather than
|
|
83
|
+
any Player instance behind it — useful when an agent needs to tell "no Players
|
|
84
|
+
are connected" apart from "the Flipper transport itself is unhealthy." They
|
|
85
|
+
soft-error when the server isn't running on a `FlipperServerTransport`.
|
|
86
|
+
|
|
87
|
+
All `clientId` args refer to a Flipper **client** — a transport-level
|
|
88
|
+
device/app connection — not a Player devtools `playerId` (used by
|
|
89
|
+
`list_players` / `select_player` / etc). A client can be connected, and even
|
|
90
|
+
have the plugin activated, before any Player instance on it is visible to the
|
|
91
|
+
player-scoped tools; one client can also host multiple Players. Unlike
|
|
92
|
+
`playerId`, there is no "currently selected" client — omitting `clientId`
|
|
93
|
+
targets every connected client instead of falling back to a selection.
|
|
94
|
+
|
|
95
|
+
| Tool | Args | Returns |
|
|
96
|
+
| --------------------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
97
|
+
| `get_flipper_connection_status` | — | Basic connection health: `connected`, `host`, `port`. |
|
|
98
|
+
| `get_flipper_consumers` | — | `owns`, `refs` (daemon-wide, not just this process), `activeClientIds`, and `connectedClientIds`. |
|
|
99
|
+
| `restart_flipper_server` | — | Restarts the daemon — only when this process owns it and is its sole consumer, otherwise a soft error. |
|
|
100
|
+
| `get_flipper_plugin_install_status` | — | Whether the Player UI Devtools Flipper plugin is installed on the daemon (npm-level install, not per-client activation). |
|
|
101
|
+
| `get_flipper_plugin_activation_status` | — | Per-client activation split: `activeClientIds` (completed the `init` handshake) vs. `inactiveClientIds` (connected but not yet activated). |
|
|
102
|
+
| `enable_flipper_plugin` | `clientId?` | Activates the plugin for `clientId`, or every connected-but-inactive client if omitted (see [Plugin activation](#plugin-activation)). |
|
|
103
|
+
| `disable_flipper_plugin` | `clientId?` | Deactivates the plugin for `clientId`, or every currently active client if omitted, without disconnecting. |
|
|
104
|
+
|
|
79
105
|
> **NOTE**
|
|
80
|
-
> Tool handlers return
|
|
106
|
+
> Tool handlers return _soft errors_ (e.g. `{ "error": "player not found" }`) as
|
|
81
107
|
> normal results rather than throwing, so a failed call still returns a
|
|
82
108
|
> structured payload the agent can read.
|
|
83
109
|
|
|
@@ -193,10 +219,10 @@ Register it with an MCP client (e.g. Claude) by pointing the client at the
|
|
|
193
219
|
The server reports anonymous usage analytics so we can tell how widely it's used
|
|
194
220
|
and whether it's working in the field. It is **on by default** and sends:
|
|
195
221
|
|
|
196
|
-
|
|
|
197
|
-
|
|
|
198
|
-
| Identity
|
|
199
|
-
| Events
|
|
222
|
+
| | |
|
|
223
|
+
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
224
|
+
| Identity | A random UUID generated on first run and stored at `~/.player-ui-devtools/install.json`. It is not derived from anything about you or your machine — delete the file and a new one is generated. |
|
|
225
|
+
| Events | Session start (`$mcp_initialize`), tool calls (`$mcp_tool_call`), tool listing (`$mcp_tools_list`), and errors (`$exception`). |
|
|
200
226
|
| Properties | Tool **name**, call duration, whether the call errored, the MCP client name/version (e.g. which editor), the devtools version, OS platform, Node major version, and whether the Flipper transport connected. |
|
|
201
227
|
|
|
202
228
|
**Tool arguments and tool responses are never transmitted.** Those can contain
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -61,14 +61,6 @@ function resolveBasicPlugin(client, playerId) {
|
|
|
61
61
|
if (!basicPlugin) return { error: "no plugin registered for this player" };
|
|
62
62
|
return { id, player, basicPlugin };
|
|
63
63
|
}
|
|
64
|
-
function ok(value) {
|
|
65
|
-
return { content: [{ type: "text", text: JSON.stringify(value) }] };
|
|
66
|
-
}
|
|
67
|
-
function err(message) {
|
|
68
|
-
return {
|
|
69
|
-
content: [{ type: "text", text: JSON.stringify({ error: message }) }]
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
64
|
function handleGetFlow(client, input) {
|
|
73
65
|
const { playerId } = PlayerInput.parse(input);
|
|
74
66
|
const resolved = resolveBasicPlugin(client, playerId);
|
|
@@ -137,41 +129,16 @@ var playerIdShape2 = {
|
|
|
137
129
|
var GetPlayerStatusInput = import_zod2.z.object(playerIdShape2);
|
|
138
130
|
function handleListPlayers(client) {
|
|
139
131
|
const { players, current } = client.getState();
|
|
140
|
-
return {
|
|
141
|
-
content: [
|
|
142
|
-
{
|
|
143
|
-
type: "text",
|
|
144
|
-
text: JSON.stringify({
|
|
145
|
-
players: Object.keys(players),
|
|
146
|
-
current: current.player
|
|
147
|
-
})
|
|
148
|
-
}
|
|
149
|
-
]
|
|
150
|
-
};
|
|
132
|
+
return ok({ players: Object.keys(players), current: current.player });
|
|
151
133
|
}
|
|
152
134
|
function handleGetPlayerStatus(client, input) {
|
|
153
135
|
const { playerId } = GetPlayerStatusInput.parse(input);
|
|
154
136
|
const { players, current } = client.getState();
|
|
155
137
|
const id = playerId ?? current.player;
|
|
156
|
-
if (!id) return
|
|
138
|
+
if (!id) return err("no player selected");
|
|
157
139
|
const player = players[id];
|
|
158
|
-
if (!player) return
|
|
159
|
-
return {
|
|
160
|
-
content: [
|
|
161
|
-
{
|
|
162
|
-
type: "text",
|
|
163
|
-
text: JSON.stringify({
|
|
164
|
-
active: player.active,
|
|
165
|
-
plugins: Object.keys(player.plugins)
|
|
166
|
-
})
|
|
167
|
-
}
|
|
168
|
-
]
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
function errorResult(message) {
|
|
172
|
-
return {
|
|
173
|
-
content: [{ type: "text", text: JSON.stringify({ error: message }) }]
|
|
174
|
-
};
|
|
140
|
+
if (!player) return err(`player not found: ${id}`);
|
|
141
|
+
return ok({ active: player.active, plugins: Object.keys(player.plugins) });
|
|
175
142
|
}
|
|
176
143
|
var listPlayersDef = {
|
|
177
144
|
name: "list_players",
|
|
@@ -193,26 +160,18 @@ var describePluginShape = {
|
|
|
193
160
|
pluginId: import_zod3.z.string().describe("Plugin ID.")
|
|
194
161
|
};
|
|
195
162
|
var DescribePluginInput = import_zod3.z.object(describePluginShape);
|
|
196
|
-
function err2(message) {
|
|
197
|
-
return {
|
|
198
|
-
content: [{ type: "text", text: JSON.stringify({ error: message }) }]
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
function ok2(value) {
|
|
202
|
-
return { content: [{ type: "text", text: JSON.stringify(value) }] };
|
|
203
|
-
}
|
|
204
163
|
function handleDescribePlugin(client, input) {
|
|
205
164
|
const { playerId, pluginId } = DescribePluginInput.parse(input);
|
|
206
165
|
const { players, current } = client.getState();
|
|
207
166
|
const id = playerId ?? current.player;
|
|
208
|
-
if (!id) return
|
|
167
|
+
if (!id) return err("no player selected");
|
|
209
168
|
const player = players[id];
|
|
210
|
-
if (!player) return
|
|
169
|
+
if (!player) return err(`player not found: ${id}`);
|
|
211
170
|
const plugin = player.plugins[pluginId];
|
|
212
|
-
if (!plugin) return
|
|
171
|
+
if (!plugin) return err(`plugin not found: ${pluginId}`);
|
|
213
172
|
if (!plugin.capabilities)
|
|
214
|
-
return
|
|
215
|
-
return
|
|
173
|
+
return err(`plugin "${pluginId}" has no capabilities declared`);
|
|
174
|
+
return ok(plugin.capabilities);
|
|
216
175
|
}
|
|
217
176
|
var describePluginDef = {
|
|
218
177
|
name: "describe_plugin",
|
|
@@ -234,35 +193,27 @@ var invokeActionShape = {
|
|
|
234
193
|
};
|
|
235
194
|
var SelectPlayerInput = import_zod4.z.object(selectPlayerShape);
|
|
236
195
|
var InvokeActionInput = import_zod4.z.object(invokeActionShape);
|
|
237
|
-
function err3(message) {
|
|
238
|
-
return {
|
|
239
|
-
content: [{ type: "text", text: JSON.stringify({ error: message }) }]
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
function ok3(value) {
|
|
243
|
-
return { content: [{ type: "text", text: JSON.stringify(value) }] };
|
|
244
|
-
}
|
|
245
196
|
function handleSelectPlayer(client, input) {
|
|
246
197
|
const { playerId } = SelectPlayerInput.parse(input);
|
|
247
198
|
const { players } = client.getState();
|
|
248
|
-
if (!players[playerId]) return
|
|
199
|
+
if (!players[playerId]) return err(`player not found: ${playerId}`);
|
|
249
200
|
client.selectPlayer(playerId);
|
|
250
|
-
return
|
|
201
|
+
return ok({ selected: playerId });
|
|
251
202
|
}
|
|
252
203
|
function handleInvokeAction(client, input) {
|
|
253
204
|
const { playerId, pluginId, action, payload } = InvokeActionInput.parse(input);
|
|
254
205
|
const { players, current } = client.getState();
|
|
255
206
|
const id = playerId ?? current.player;
|
|
256
|
-
if (!id) return
|
|
207
|
+
if (!id) return err("no player selected");
|
|
257
208
|
const player = players[id];
|
|
258
|
-
if (!player) return
|
|
209
|
+
if (!player) return err(`player not found: ${id}`);
|
|
259
210
|
const plugin = player.plugins[pluginId];
|
|
260
|
-
if (!plugin) return
|
|
211
|
+
if (!plugin) return err(`plugin not found: ${pluginId}`);
|
|
261
212
|
if (plugin.capabilities?.actions && !(action in plugin.capabilities.actions)) {
|
|
262
|
-
return
|
|
213
|
+
return err(`action "${action}" not declared in plugin capabilities`);
|
|
263
214
|
}
|
|
264
215
|
client.handleInteraction({ type: action, payload, target: id });
|
|
265
|
-
return
|
|
216
|
+
return ok({ invoked: action });
|
|
266
217
|
}
|
|
267
218
|
var selectPlayerDef = {
|
|
268
219
|
name: "select_player",
|
|
@@ -277,7 +228,139 @@ var invokeActionDef = {
|
|
|
277
228
|
handle: handleInvokeAction
|
|
278
229
|
};
|
|
279
230
|
|
|
231
|
+
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/tools/flipper.ts
|
|
232
|
+
var import_client_flipper = require("@player-devtools/client-flipper");
|
|
233
|
+
var import_zod5 = require("zod");
|
|
234
|
+
var clientIdShape = {
|
|
235
|
+
clientId: import_zod5.z.string().optional().describe(
|
|
236
|
+
"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."
|
|
237
|
+
)
|
|
238
|
+
};
|
|
239
|
+
var ClientIdInput = import_zod5.z.object(clientIdShape);
|
|
240
|
+
function asFlipperTransport(transport) {
|
|
241
|
+
return transport instanceof import_client_flipper.FlipperServerTransport ? transport : null;
|
|
242
|
+
}
|
|
243
|
+
function handleGetFlipperStatus(_client, _args, transport) {
|
|
244
|
+
const flipper = asFlipperTransport(transport);
|
|
245
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
246
|
+
const { connected, host, port } = flipper.getDiagnostics();
|
|
247
|
+
return ok({ connected, host, port });
|
|
248
|
+
}
|
|
249
|
+
function handleGetFlipperConsumers(_client, _args, transport) {
|
|
250
|
+
const flipper = asFlipperTransport(transport);
|
|
251
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
252
|
+
const { owns, refs, activeClientIds, connectedClientIds } = flipper.getDiagnostics();
|
|
253
|
+
return ok({ owns, refs, activeClientIds, connectedClientIds });
|
|
254
|
+
}
|
|
255
|
+
async function handleRestartFlipperServer(_client, _args, transport) {
|
|
256
|
+
const flipper = asFlipperTransport(transport);
|
|
257
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
258
|
+
const result = await flipper.restart();
|
|
259
|
+
if (!result.ok) return err(result.reason);
|
|
260
|
+
return ok({ restarted: true, host: result.host, port: result.port });
|
|
261
|
+
}
|
|
262
|
+
async function handleGetFlipperPluginInstallStatus(_client, _args, transport) {
|
|
263
|
+
const flipper = asFlipperTransport(transport);
|
|
264
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
265
|
+
if (!flipper.getDiagnostics().connected) {
|
|
266
|
+
return err("flipper transport not connected");
|
|
267
|
+
}
|
|
268
|
+
const status = await flipper.getPluginInstallStatus();
|
|
269
|
+
if (!status.installed && status.reason) return err(status.reason);
|
|
270
|
+
return ok(status);
|
|
271
|
+
}
|
|
272
|
+
var getFlipperStatusDef = {
|
|
273
|
+
name: "get_flipper_connection_status",
|
|
274
|
+
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.",
|
|
275
|
+
inputSchema: {},
|
|
276
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
277
|
+
handle: handleGetFlipperStatus
|
|
278
|
+
};
|
|
279
|
+
var getFlipperConsumersDef = {
|
|
280
|
+
name: "get_flipper_consumers",
|
|
281
|
+
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.",
|
|
282
|
+
inputSchema: {},
|
|
283
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
284
|
+
handle: handleGetFlipperConsumers
|
|
285
|
+
};
|
|
286
|
+
var restartFlipperServerDef = {
|
|
287
|
+
name: "restart_flipper_server",
|
|
288
|
+
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.",
|
|
289
|
+
inputSchema: {},
|
|
290
|
+
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
291
|
+
handle: handleRestartFlipperServer
|
|
292
|
+
};
|
|
293
|
+
var getFlipperPluginInstallStatusDef = {
|
|
294
|
+
name: "get_flipper_plugin_install_status",
|
|
295
|
+
description: "Check whether the Player UI Devtools Flipper plugin is installed on the connected daemon.",
|
|
296
|
+
inputSchema: {},
|
|
297
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
298
|
+
handle: handleGetFlipperPluginInstallStatus
|
|
299
|
+
};
|
|
300
|
+
function handleGetFlipperPluginActivationStatus(_client, _args, transport) {
|
|
301
|
+
const flipper = asFlipperTransport(transport);
|
|
302
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
303
|
+
const { connected, connectedClientIds, activeClientIds } = flipper.getDiagnostics();
|
|
304
|
+
if (!connected) return err("flipper transport not connected");
|
|
305
|
+
const active = new Set(activeClientIds);
|
|
306
|
+
return ok({
|
|
307
|
+
activeClientIds,
|
|
308
|
+
inactiveClientIds: connectedClientIds.filter((id) => !active.has(id))
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
async function handleEnableFlipperPlugin(_client, args, transport) {
|
|
312
|
+
const flipper = asFlipperTransport(transport);
|
|
313
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
314
|
+
const { clientId } = ClientIdInput.parse(args);
|
|
315
|
+
try {
|
|
316
|
+
await flipper.enablePlugin(clientId);
|
|
317
|
+
} catch (error) {
|
|
318
|
+
return err(error instanceof Error ? error.message : String(error));
|
|
319
|
+
}
|
|
320
|
+
return ok({ enabled: true, clientId: clientId ?? "all" });
|
|
321
|
+
}
|
|
322
|
+
async function handleDisableFlipperPlugin(_client, args, transport) {
|
|
323
|
+
const flipper = asFlipperTransport(transport);
|
|
324
|
+
if (!flipper) return err("not using a Flipper transport");
|
|
325
|
+
const { clientId } = ClientIdInput.parse(args);
|
|
326
|
+
try {
|
|
327
|
+
await flipper.disablePlugin(clientId);
|
|
328
|
+
} catch (error) {
|
|
329
|
+
return err(error instanceof Error ? error.message : String(error));
|
|
330
|
+
}
|
|
331
|
+
return ok({ disabled: true, clientId: clientId ?? "all" });
|
|
332
|
+
}
|
|
333
|
+
var getFlipperPluginActivationStatusDef = {
|
|
334
|
+
name: "get_flipper_plugin_activation_status",
|
|
335
|
+
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.",
|
|
336
|
+
inputSchema: {},
|
|
337
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
338
|
+
handle: handleGetFlipperPluginActivationStatus
|
|
339
|
+
};
|
|
340
|
+
var enableFlipperPluginDef = {
|
|
341
|
+
name: "enable_flipper_plugin",
|
|
342
|
+
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.",
|
|
343
|
+
inputSchema: clientIdShape,
|
|
344
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
345
|
+
handle: handleEnableFlipperPlugin
|
|
346
|
+
};
|
|
347
|
+
var disableFlipperPluginDef = {
|
|
348
|
+
name: "disable_flipper_plugin",
|
|
349
|
+
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.",
|
|
350
|
+
inputSchema: clientIdShape,
|
|
351
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
352
|
+
handle: handleDisableFlipperPlugin
|
|
353
|
+
};
|
|
354
|
+
|
|
280
355
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/tools/index.ts
|
|
356
|
+
function ok(value) {
|
|
357
|
+
return { content: [{ type: "text", text: JSON.stringify(value) }] };
|
|
358
|
+
}
|
|
359
|
+
function err(message) {
|
|
360
|
+
return {
|
|
361
|
+
content: [{ type: "text", text: JSON.stringify({ error: message }) }]
|
|
362
|
+
};
|
|
363
|
+
}
|
|
281
364
|
var TOOL_DEFS = [
|
|
282
365
|
listPlayersDef,
|
|
283
366
|
getPlayerStatusDef,
|
|
@@ -287,7 +370,14 @@ var TOOL_DEFS = [
|
|
|
287
370
|
getPluginDataDef,
|
|
288
371
|
describePluginDef,
|
|
289
372
|
selectPlayerDef,
|
|
290
|
-
invokeActionDef
|
|
373
|
+
invokeActionDef,
|
|
374
|
+
getFlipperStatusDef,
|
|
375
|
+
getFlipperConsumersDef,
|
|
376
|
+
restartFlipperServerDef,
|
|
377
|
+
getFlipperPluginInstallStatusDef,
|
|
378
|
+
getFlipperPluginActivationStatusDef,
|
|
379
|
+
enableFlipperPluginDef,
|
|
380
|
+
disableFlipperPluginDef
|
|
291
381
|
];
|
|
292
382
|
|
|
293
383
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/telemetry/index.ts
|
|
@@ -396,7 +486,7 @@ function allowlistEventProperties(event) {
|
|
|
396
486
|
}
|
|
397
487
|
|
|
398
488
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/telemetry/index.ts
|
|
399
|
-
var MCP_VERSION = true ? "0.
|
|
489
|
+
var MCP_VERSION = true ? "0.16.0" : "unstamped";
|
|
400
490
|
function createAnalytics(server, deps) {
|
|
401
491
|
try {
|
|
402
492
|
const config = resolveTelemetryConfig();
|
|
@@ -456,8 +546,12 @@ var MCPServer = class {
|
|
|
456
546
|
const register = this.server.registerTool.bind(this.server);
|
|
457
547
|
register(
|
|
458
548
|
def.name,
|
|
459
|
-
{
|
|
460
|
-
|
|
549
|
+
{
|
|
550
|
+
description: def.description,
|
|
551
|
+
inputSchema: def.inputSchema,
|
|
552
|
+
annotations: def.annotations
|
|
553
|
+
},
|
|
554
|
+
(args) => def.handle(this.client, args, this.transport)
|
|
461
555
|
);
|
|
462
556
|
}
|
|
463
557
|
}
|
|
@@ -467,10 +561,10 @@ var MCPServer = class {
|
|
|
467
561
|
try {
|
|
468
562
|
await this.transport.connect();
|
|
469
563
|
this.transportConnected = true;
|
|
470
|
-
} catch (
|
|
564
|
+
} catch (err2) {
|
|
471
565
|
console.warn(
|
|
472
566
|
"[MCPServer] Transport connect failed (will operate in disconnected mode):",
|
|
473
|
-
|
|
567
|
+
err2 instanceof Error ? err2.message : err2
|
|
474
568
|
);
|
|
475
569
|
}
|
|
476
570
|
}
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/server.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/tools/flow.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/tools/players.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/tools/plugins.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/tools/select.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/tools/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/telemetry/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/telemetry/config.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/telemetry/installId.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/telemetry/redaction.ts"],"sourcesContent":["export { MCPServer } from \"./server\";\n","import {\n createExtensionClient,\n type ExtensionClient,\n} from \"@player-devtools/client\";\nimport type { Transport } from \"@player-devtools/types\";\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport type { PostHog } from \"posthog-node\";\n\nimport { TOOL_DEFS, type ToolDef } from \"./tools\";\nimport { createAnalytics, MCP_VERSION } from \"./telemetry\";\n\nexport class MCPServer {\n private client: ExtensionClient;\n private server: McpServer;\n private analytics: PostHog | null;\n private transportConnected = false;\n\n constructor(private transport: Transport) {\n this.client = createExtensionClient(transport);\n this.server = new McpServer({\n name: \"player-devtools\",\n version: MCP_VERSION,\n });\n // Instrument before registering tools so every handler is wrapped.\n this.analytics = createAnalytics(this.server, {\n isTransportConnected: () => this.transportConnected,\n });\n this.registerTools();\n }\n\n private registerTools(): void {\n for (const def of TOOL_DEFS) {\n // `registerTool` is heavily generic over the Zod input shape; inferring\n // that across a heterogeneous array trips TS2589 (excessively deep). The\n // shapes are validated at runtime by the SDK, so register through a\n // loosely-typed view to keep inference shallow.\n const register = this.server.registerTool.bind(this.server) as (\n name: string,\n config: { description: string; inputSchema: ToolDef[\"inputSchema\"] },\n cb: (args: unknown) => CallToolResult,\n ) => unknown;\n\n register(\n def.name,\n { description: def.description, inputSchema: def.inputSchema },\n (args) => def.handle(this.client, args),\n );\n }\n }\n\n async start(): Promise<void> {\n const stdioTransport = new StdioServerTransport();\n await this.server.connect(stdioTransport);\n try {\n await this.transport.connect();\n this.transportConnected = true;\n } catch (err) {\n console.warn(\n \"[MCPServer] Transport connect failed (will operate in disconnected mode):\",\n err instanceof Error ? err.message : err,\n );\n }\n }\n\n async stop(): Promise<void> {\n // Flush buffered events first: bin/run calls process.exit(0) as soon as\n // this resolves, which would otherwise drop them. Never fail shutdown on a\n // telemetry error.\n try {\n await this.analytics?.shutdown();\n } catch {\n /* best-effort */\n }\n this.client.destroy();\n await this.transport.close();\n await this.server.close();\n }\n}\n","import type { ExtensionClient } from \"@player-devtools/client\";\nimport type { PluginData } from \"@player-devtools/types\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { z } from \"zod\";\n\nimport type { ToolDef } from \"./index\";\n\ntype Failure = { error: string };\ntype PlayerOk = {\n id: string;\n player: {\n plugins: Record<string, PluginData>;\n active: boolean;\n config: Record<string, unknown>;\n };\n};\ntype BasicPluginOk = PlayerOk & { basicPlugin: PluginData };\n\n/** Optional player id, shared by the player-scoped read tools. */\nconst playerIdShape = {\n playerId: z\n .string()\n .optional()\n .describe(\"Player ID. Defaults to the currently selected player.\"),\n};\n\nconst PlayerInput = z.object(playerIdShape);\n\nfunction resolvePlayer(\n client: ExtensionClient,\n playerId?: string,\n): Failure | PlayerOk {\n const { players, current } = client.getState();\n const id = playerId ?? current.player;\n if (!id) return { error: \"no player selected\" };\n const player = players[id];\n if (!player) return { error: `player not found: ${id}` };\n return { id, player };\n}\n\nfunction resolveBasicPlugin(\n client: ExtensionClient,\n playerId?: string,\n): Failure | BasicPluginOk {\n const resolved = resolvePlayer(client, playerId);\n if (\"error\" in resolved) return resolved;\n const { id, player } = resolved;\n // Find the first plugin — by convention the basic plugin is registered first\n const [basicPlugin] = Object.values(player.plugins);\n if (!basicPlugin) return { error: \"no plugin registered for this player\" };\n return { id, player, basicPlugin };\n}\n\nfunction ok(value: unknown): CallToolResult {\n return { content: [{ type: \"text\", text: JSON.stringify(value) }] };\n}\n\nfunction err(message: string): CallToolResult {\n return {\n content: [{ type: \"text\", text: JSON.stringify({ error: message }) }],\n };\n}\n\nexport function handleGetFlow(\n client: ExtensionClient,\n input: unknown,\n): CallToolResult {\n const { playerId } = PlayerInput.parse(input);\n const resolved = resolveBasicPlugin(client, playerId);\n if (\"error\" in resolved) return err(resolved.error);\n return ok(resolved.basicPlugin.flow);\n}\n\nexport function handleGetData(\n client: ExtensionClient,\n input: unknown,\n): CallToolResult {\n const { playerId } = PlayerInput.parse(input);\n const resolved = resolveBasicPlugin(client, playerId);\n if (\"error\" in resolved) return err(resolved.error);\n return ok(resolved.basicPlugin.flow?.data ?? null);\n}\n\nexport function handleGetLogs(\n client: ExtensionClient,\n input: unknown,\n): CallToolResult {\n const { playerId } = PlayerInput.parse(input);\n const resolved = resolveBasicPlugin(client, playerId);\n if (\"error\" in resolved) return err(resolved.error);\n // Logs live in the plugin's flow data under a \"logs\" key by convention\n return ok(\n (resolved.basicPlugin.flow?.data as Record<string, unknown>)?.logs ?? [],\n );\n}\n\nconst getPluginDataShape = {\n ...playerIdShape,\n pluginId: z.string().describe(\"Plugin ID.\"),\n dataKey: z.string().describe(\"Key to retrieve from the plugin's data.\"),\n};\n\nconst GetPluginDataInput = z.object(getPluginDataShape);\n\nexport function handleGetPluginData(\n client: ExtensionClient,\n input: unknown,\n): CallToolResult {\n const { playerId, pluginId, dataKey } = GetPluginDataInput.parse(input);\n const resolved = resolvePlayer(client, playerId);\n if (\"error\" in resolved) return err(resolved.error);\n const plugin = resolved.player.plugins[pluginId];\n if (!plugin) return err(`plugin not found: ${pluginId}`);\n const value = (plugin.flow?.data as Record<string, unknown> | undefined)?.[\n dataKey\n ];\n return ok(value ?? null);\n}\n\nexport const getFlowDef: ToolDef = {\n name: \"get_flow\",\n description:\n \"Get the current flow from the basic devtools plugin for a Player instance.\",\n inputSchema: playerIdShape,\n handle: handleGetFlow,\n};\n\nexport const getDataDef: ToolDef = {\n name: \"get_data\",\n description:\n \"Get the current flow data model from the basic devtools plugin for a Player instance.\",\n inputSchema: playerIdShape,\n handle: handleGetData,\n};\n\nexport const getLogsDef: ToolDef = {\n name: \"get_logs\",\n description:\n \"Get the logs from the basic devtools plugin for a Player instance.\",\n inputSchema: playerIdShape,\n handle: handleGetLogs,\n};\n\nexport const getPluginDataDef: ToolDef = {\n name: \"get_plugin_data\",\n description: \"Get a specific data key from any plugin for a Player instance.\",\n inputSchema: getPluginDataShape,\n handle: handleGetPluginData,\n};\n","import type { ExtensionClient } from \"@player-devtools/client\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { z } from \"zod\";\n\nimport type { ToolDef } from \"./index\";\n\nconst playerIdShape = {\n playerId: z\n .string()\n .optional()\n .describe(\"Player ID. Defaults to the currently selected player.\"),\n};\n\nconst GetPlayerStatusInput = z.object(playerIdShape);\n\nexport function handleListPlayers(client: ExtensionClient): CallToolResult {\n const { players, current } = client.getState();\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify({\n players: Object.keys(players),\n current: current.player,\n }),\n },\n ],\n };\n}\n\nexport function handleGetPlayerStatus(\n client: ExtensionClient,\n input: unknown,\n): CallToolResult {\n const { playerId } = GetPlayerStatusInput.parse(input);\n const { players, current } = client.getState();\n const id = playerId ?? current.player;\n if (!id) return errorResult(\"no player selected\");\n const player = players[id];\n if (!player) return errorResult(`player not found: ${id}`);\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify({\n active: player.active,\n plugins: Object.keys(player.plugins),\n }),\n },\n ],\n };\n}\n\nfunction errorResult(message: string): CallToolResult {\n return {\n content: [{ type: \"text\", text: JSON.stringify({ error: message }) }],\n };\n}\n\nexport const listPlayersDef: ToolDef = {\n name: \"list_players\",\n description:\n \"List all Player instances known to the devtools, and which one is currently selected.\",\n inputSchema: {},\n handle: (client) => handleListPlayers(client),\n};\n\nexport const getPlayerStatusDef: ToolDef = {\n name: \"get_player_status\",\n description:\n \"Get the active status and registered plugin IDs for a Player instance.\",\n inputSchema: playerIdShape,\n handle: handleGetPlayerStatus,\n};\n","import type { ExtensionClient } from \"@player-devtools/client\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { z } from \"zod\";\n\nimport type { ToolDef } from \"./index\";\n\nconst describePluginShape = {\n playerId: z\n .string()\n .optional()\n .describe(\"Player ID. Defaults to the currently selected player.\"),\n pluginId: z.string().describe(\"Plugin ID.\"),\n};\n\nconst DescribePluginInput = z.object(describePluginShape);\n\nfunction err(message: string): CallToolResult {\n return {\n content: [{ type: \"text\", text: JSON.stringify({ error: message }) }],\n };\n}\n\nfunction ok(value: unknown): CallToolResult {\n return { content: [{ type: \"text\", text: JSON.stringify(value) }] };\n}\n\nexport function handleDescribePlugin(\n client: ExtensionClient,\n input: unknown,\n): CallToolResult {\n const { playerId, pluginId } = DescribePluginInput.parse(input);\n const { players, current } = client.getState();\n const id = playerId ?? current.player;\n if (!id) return err(\"no player selected\");\n const player = players[id];\n if (!player) return err(`player not found: ${id}`);\n const plugin = player.plugins[pluginId];\n if (!plugin) return err(`plugin not found: ${pluginId}`);\n if (!plugin.capabilities)\n return err(`plugin \"${pluginId}\" has no capabilities declared`);\n return ok(plugin.capabilities);\n}\n\nexport const describePluginDef: ToolDef = {\n name: \"describe_plugin\",\n description:\n \"Get the capability descriptor declared by a plugin at registration time. Use this to discover what data keys and actions the plugin exposes.\",\n inputSchema: describePluginShape,\n handle: handleDescribePlugin,\n};\n","import type { ExtensionClient } from \"@player-devtools/client\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { z } from \"zod\";\n\nimport type { ToolDef } from \"./index\";\n\nconst selectPlayerShape = {\n playerId: z.string().describe(\"The Player ID to select.\"),\n};\n\nconst invokeActionShape = {\n playerId: z\n .string()\n .optional()\n .describe(\"Player ID. Defaults to the currently selected player.\"),\n pluginId: z.string().describe(\"Plugin ID.\"),\n action: z.string().describe(\"Action name.\"),\n payload: z.string().optional().describe(\"Optional stringified payload.\"),\n};\n\nconst SelectPlayerInput = z.object(selectPlayerShape);\n\nconst InvokeActionInput = z.object(invokeActionShape);\n\nfunction err(message: string): CallToolResult {\n return {\n content: [{ type: \"text\", text: JSON.stringify({ error: message }) }],\n };\n}\n\nfunction ok(value: unknown): CallToolResult {\n return { content: [{ type: \"text\", text: JSON.stringify(value) }] };\n}\n\nexport function handleSelectPlayer(\n client: ExtensionClient,\n input: unknown,\n): CallToolResult {\n const { playerId } = SelectPlayerInput.parse(input);\n const { players } = client.getState();\n if (!players[playerId]) return err(`player not found: ${playerId}`);\n client.selectPlayer(playerId);\n return ok({ selected: playerId });\n}\n\nexport function handleInvokeAction(\n client: ExtensionClient,\n input: unknown,\n): CallToolResult {\n const { playerId, pluginId, action, payload } =\n InvokeActionInput.parse(input);\n const { players, current } = client.getState();\n const id = playerId ?? current.player;\n if (!id) return err(\"no player selected\");\n const player = players[id];\n if (!player) return err(`player not found: ${id}`);\n const plugin = player.plugins[pluginId];\n if (!plugin) return err(`plugin not found: ${pluginId}`);\n if (\n plugin.capabilities?.actions &&\n !(action in plugin.capabilities.actions)\n ) {\n return err(`action \"${action}\" not declared in plugin capabilities`);\n }\n client.handleInteraction({ type: action, payload, target: id });\n return ok({ invoked: action });\n}\n\nexport const selectPlayerDef: ToolDef = {\n name: \"select_player\",\n description:\n \"Select a Player instance as the active target for subsequent tool calls.\",\n inputSchema: selectPlayerShape,\n handle: handleSelectPlayer,\n};\n\nexport const invokeActionDef: ToolDef = {\n name: \"invoke_action\",\n description:\n \"Invoke a named action on a plugin. Use describe_plugin first to discover available actions.\",\n inputSchema: invokeActionShape,\n handle: handleInvokeAction,\n};\n","import type { ExtensionClient } from \"@player-devtools/client\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport type { ZodRawShape } from \"zod\";\n\n/**\n * A tool definition consumed by the MCP server. `inputSchema` is a Zod raw\n * shape — the SDK derives the JSON Schema, validates input, and types the\n * handler's `args`. The handler receives the running devtools client plus the\n * validated args.\n */\nexport type ToolDef<Shape extends ZodRawShape = ZodRawShape> = {\n name: string;\n description: string;\n inputSchema: Shape;\n handle: (client: ExtensionClient, args: unknown) => CallToolResult;\n};\n\nexport * from \"./flow\";\nexport * from \"./players\";\nexport * from \"./plugins\";\nexport * from \"./select\";\n\nimport { listPlayersDef, getPlayerStatusDef } from \"./players\";\nimport { getFlowDef, getDataDef, getLogsDef, getPluginDataDef } from \"./flow\";\nimport { describePluginDef } from \"./plugins\";\nimport { selectPlayerDef, invokeActionDef } from \"./select\";\n\n/** Every tool the MCP server exposes. */\nexport const TOOL_DEFS: ToolDef[] = [\n listPlayersDef,\n getPlayerStatusDef,\n getFlowDef,\n getDataDef,\n getLogsDef,\n getPluginDataDef,\n describePluginDef,\n selectPlayerDef,\n invokeActionDef,\n];\n","import * as os from \"os\";\nimport { instrument } from \"@posthog/mcp\";\nimport { PostHog } from \"posthog-node\";\n\nimport { resolveTelemetryConfig } from \"./config\";\nimport { getInstallId } from \"./installId\";\nimport { allowlistEventProperties } from \"./redaction\";\n\nexport {\n ALLOWED_EVENT_PROPERTIES,\n allowlistEventProperties,\n} from \"./redaction\";\nexport { resolveTelemetryConfig, type TelemetryConfig } from \"./config\";\nexport { getInstallId, type InstallIdDeps } from \"./installId\";\n\ndeclare global {\n const __VERSION__: string;\n}\n\n/**\n * Stamped at release build time by tsup (see devtools/tsup.config.ts). The\n * guard is required — the global is absent in local and test builds.\n */\nexport const MCP_VERSION: string =\n typeof __VERSION__ !== \"undefined\" ? __VERSION__ : \"unstamped\";\n\nexport type AnalyticsDeps = {\n /** Reports whether the devtools transport is currently connected. */\n isTransportConnected: () => boolean;\n};\n\n/**\n * Instruments `server` with anonymous usage analytics.\n *\n * Returns the PostHog client so the caller can flush it on shutdown, or `null`\n * when telemetry is disabled or no durable identity is available. Never throws:\n * telemetry must not be able to prevent the server from starting.\n */\nexport function createAnalytics(\n server: object,\n deps: AnalyticsDeps,\n): PostHog | null {\n try {\n const config = resolveTelemetryConfig();\n if (!config.enabled) return null;\n\n const installId = getInstallId();\n if (installId === null) return null;\n\n const posthog = new PostHog(config.apiKey, {\n host: config.host,\n // The load-bearing privacy control. Runs inside posthog-node's capture(),\n // so it applies to everything the MCP SDK emits regardless of the SDK's\n // own hooks. See redaction.ts for why this is an allowlist.\n before_send: [allowlistEventProperties],\n });\n\n instrument(server, posthog, {\n // Defaults to ON, and would inject a *required* `context` parameter into\n // every tool schema asking the agent to narrate user intent — mutating\n // our public tool API and adding per-call token cost.\n context: false,\n identify: { distinctId: installId },\n eventProperties: () => ({\n mcp_version: MCP_VERSION,\n os_platform: os.platform(),\n node_major: Number.parseInt(\n process.versions.node.split(\".\")[0] ?? \"\",\n 10,\n ),\n transport_connected: deps.isTransportConnected(),\n surface: \"mcp-server\",\n }),\n // Redundant with `before_send` above, kept as a second independent layer.\n // This hook fails closed: the SDK drops the event if it throws.\n beforeSend: allowlistEventProperties,\n });\n\n return posthog;\n } catch {\n // Telemetry is strictly best-effort — a misconfiguration must never take\n // down the server.\n return null;\n }\n}\n","declare global {\n const __POSTHOG_KEY__: string;\n}\n\n/**\n * PostHog project API key, stamped at release build time from the\n * `POSTHOG_PROJECT_KEY` CI environment variable (see\n * helpers/release/workspace-status.sh and tsup.config.ts), mirroring how\n * `__VERSION__` is stamped.\n *\n * This is a *public, write-only* ingestion token — it can only send events and\n * cannot read data back, which is why it is safe to ship in an open-source\n * package.\n *\n * The `typeof` guard is required: the global is absent in local and test\n * builds, where it resolves to an empty string and disables telemetry.\n */\nconst POSTHOG_PROJECT_KEY =\n typeof __POSTHOG_KEY__ !== \"undefined\" ? __POSTHOG_KEY__ : \"\";\n\nconst DEFAULT_POSTHOG_HOST = \"https://us.i.posthog.com\";\n\nexport type TelemetryConfig =\n | { readonly enabled: false }\n | { readonly enabled: true; readonly apiKey: string; readonly host: string };\n\n/**\n * Presence of the variable opts out, *except* for explicit negatives —\n * `DO_NOT_TRACK=0` means \"tracking is fine\", not \"opted out\".\n */\nfunction isTruthy(value: string | undefined): boolean {\n if (value === undefined) return false;\n const normalized = value.trim().toLowerCase();\n if (normalized === \"\" || normalized === \"0\" || normalized === \"false\") {\n return false;\n }\n return true;\n}\n\nfunction isOptedOut(env: NodeJS.ProcessEnv): boolean {\n return (\n isTruthy(env.PLAYER_DEVTOOLS_TELEMETRY_DISABLED) ||\n // Cross-vendor convention (consoledonottrack.com) — honored so a user who\n // sets it once is covered everywhere.\n isTruthy(env.DO_NOT_TRACK)\n );\n}\n\nexport function resolveTelemetryConfig(\n env: NodeJS.ProcessEnv = process.env,\n): TelemetryConfig {\n if (isOptedOut(env)) return { enabled: false };\n\n const apiKey = env.PLAYER_DEVTOOLS_TELEMETRY_KEY ?? POSTHOG_PROJECT_KEY;\n // Unstamped (local/dev builds) or unset in CI — stay silent rather than\n // firing doomed requests at PostHog on every startup.\n if (!apiKey) return { enabled: false };\n // Only public write-only project keys may ship. A `phx_` (personal) or\n // `phs_` (project secret) key is a real credential and must never be baked\n // into a published artifact, so refuse to use one even if stamped.\n if (!apiKey.startsWith(\"phc_\")) return { enabled: false };\n\n const host = (\n env.PLAYER_DEVTOOLS_TELEMETRY_HOST ?? DEFAULT_POSTHOG_HOST\n ).replace(/\\/+$/, \"\");\n\n return { enabled: true, apiKey, host };\n}\n","import { randomUUID } from \"crypto\";\nimport * as fs from \"fs\";\nimport * as os from \"os\";\nimport * as path from \"path\";\n\nexport type InstallIdDeps = {\n /** Resolves the user's home directory. */\n homedir: () => string;\n /** Reads the install file. */\n readFileSync: typeof fs.readFileSync;\n /** Writes the install file. */\n writeFileSync: typeof fs.writeFileSync;\n /** Creates the install directory. */\n mkdirSync: typeof fs.mkdirSync;\n /** Mints a new identifier. */\n randomUUID: () => string;\n};\n\nconst defaultDeps: InstallIdDeps = {\n homedir: os.homedir,\n readFileSync: fs.readFileSync,\n writeFileSync: fs.writeFileSync,\n mkdirSync: fs.mkdirSync,\n randomUUID,\n};\n\ntype InstallFile = { installId: string };\n\nconst UUID_PATTERN =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\nexport const INSTALL_DIR_NAME = \".player-ui-devtools\";\nexport const INSTALL_FILE_NAME = \"install.json\";\n\n/**\n * A stable, anonymous per-machine identifier.\n *\n * Stored under the user's home directory rather than the OS temp dir the\n * flipper refcount uses: temp is periodically reaped, which would regenerate\n * the id on every reboot and turn \"unique installs\" into \"unique boots\".\n *\n * Returns `null` when the id can neither be read nor persisted (read-only FS,\n * sandbox, absent HOME). Callers treat that as \"telemetry off\" — returning an\n * in-memory id instead would register a brand-new install on every run and\n * systematically inflate counts for exactly the sandboxed population least\n * likely to be real users.\n */\nexport function getInstallId(deps: InstallIdDeps = defaultDeps): string | null {\n const dir = path.join(deps.homedir(), INSTALL_DIR_NAME);\n const file = path.join(dir, INSTALL_FILE_NAME);\n\n try {\n const parsed = JSON.parse(\n deps.readFileSync(file, \"utf8\") as string,\n ) as Partial<InstallFile>;\n // Validate the shape, not just the parse: `{\"installId\": 42}` parses fine\n // but is not a usable identity.\n if (\n typeof parsed.installId === \"string\" &&\n UUID_PATTERN.test(parsed.installId)\n ) {\n return parsed.installId;\n }\n } catch {\n /* missing or corrupt — fall through and regenerate */\n }\n\n const installId = deps.randomUUID();\n try {\n deps.mkdirSync(dir, { recursive: true });\n const contents: InstallFile = { installId };\n // 0600: a stable per-user identifier should not be world-readable.\n deps.writeFileSync(file, JSON.stringify(contents), { mode: 0o600 });\n } catch {\n return null;\n }\n\n return installId;\n}\n","/**\n * Event property allowlist.\n *\n * `@posthog/mcp` captures tool arguments (`$mcp_parameters`) and tool results\n * (`$mcp_response`) unconditionally — there is no SDK option to disable it, and\n * its built-in sanitizer only matches sensitive *key names* (`token`,\n * `password`, ...), so a field named `flowContent` would be transmitted\n * verbatim. Devtools tool arguments carry player/plugin ids and `invoke_action`\n * payloads, i.e. potentially customer flow data.\n *\n * This is an allowlist rather than a denylist on purpose: the SDK is 0.x and\n * ships frequently, so a denylist naming today's two payload keys would\n * silently start leaking the moment a release adds a third. Anything not\n * explicitly listed here never reaches the wire.\n */\nexport const ALLOWED_EVENT_PROPERTIES: ReadonlySet<string> = new Set([\n // MCP tool call shape — names and timings only, never payloads.\n \"$mcp_tool_name\",\n \"$mcp_duration_ms\",\n \"$mcp_is_error\",\n \"$mcp_error_type\",\n \"$mcp_listed_tool_names\",\n \"$mcp_missing_capability\",\n // Which editor/agent is driving the server.\n \"$mcp_client_name\",\n \"$mcp_client_version\",\n \"$mcp_server_name\",\n \"$mcp_server_version\",\n \"$mcp_protocol_version\",\n // PostHog bookkeeping.\n \"$session_id\",\n \"$process_person_profile\",\n \"$lib\",\n \"$lib_version\",\n // Our own event properties.\n \"mcp_version\",\n \"os_platform\",\n \"node_major\",\n \"transport_connected\",\n \"surface\",\n]);\n\nexport type CapturedEvent = {\n /** Event name. */\n event?: string;\n /** Event properties. */\n properties?: Record<string, unknown>;\n};\n\n/**\n * Drops every property not in {@link ALLOWED_EVENT_PROPERTIES}.\n *\n * Installed as a `posthog-node` client-level `before_send`, which runs inside\n * `capture()` — a chokepoint the MCP SDK cannot route around, since we own the\n * client instance and it does not.\n *\n * Accepts `null` because `before_send` hooks compose: an earlier hook may have\n * already dropped the event.\n */\nexport function allowlistEventProperties<Event extends CapturedEvent>(\n event: Event | null,\n): Event | null {\n if (!event?.properties) return event;\n\n event.properties = Object.fromEntries(\n Object.entries(event.properties).filter(([key]) =>\n ALLOWED_EVENT_PROPERTIES.has(key),\n ),\n );\n\n return event;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAGO;AAEP,IAAAA,cAA0B;AAC1B,mBAAqC;;;ACHrC,iBAAkB;AAgBlB,IAAM,gBAAgB;AAAA,EACpB,UAAU,aACP,OAAO,EACP,SAAS,EACT,SAAS,uDAAuD;AACrE;AAEA,IAAM,cAAc,aAAE,OAAO,aAAa;AAE1C,SAAS,cACP,QACA,UACoB;AACpB,QAAM,EAAE,SAAS,QAAQ,IAAI,OAAO,SAAS;AAC7C,QAAM,KAAK,YAAY,QAAQ;AAC/B,MAAI,CAAC,GAAI,QAAO,EAAE,OAAO,qBAAqB;AAC9C,QAAM,SAAS,QAAQ,EAAE;AACzB,MAAI,CAAC,OAAQ,QAAO,EAAE,OAAO,qBAAqB,EAAE,GAAG;AACvD,SAAO,EAAE,IAAI,OAAO;AACtB;AAEA,SAAS,mBACP,QACA,UACyB;AACzB,QAAM,WAAW,cAAc,QAAQ,QAAQ;AAC/C,MAAI,WAAW,SAAU,QAAO;AAChC,QAAM,EAAE,IAAI,OAAO,IAAI;AAE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B,IAAI,kCAAqB;AAChD,UAAM,KAAK,OAAO,QAAQ,cAAc;AACxC,QAAI;AACF,YAAM,KAAK,UAAU,QAAQ;AAC7B,WAAK,qBAAqB;AAAA,IAC5B,SAASC,MAAK;AACZ,cAAQ;AAAA,QACN;AAAA,QACAA,gBAAe,QAAQA,KAAI,UAAUA;AAAA,MACvC;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,OAAsB;AAI1B,QAAI;AACF,YAAM,KAAK,WAAW,SAAS;AAAA,IACjC,QAAQ;AAAA,IAER;AACA,SAAK,OAAO,QAAQ;AACpB,UAAM,KAAK,UAAU,MAAM;AAC3B,UAAM,KAAK,OAAO,MAAM;AAAA,EAC1B;AACF;","names":["import_mcp","import_zod","playerIdShape","import_zod","err","ok","import_zod","err","ok","os","err"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/server.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/tools/flow.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/tools/players.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/tools/plugins.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/tools/select.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/tools/flipper.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/tools/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/telemetry/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/telemetry/config.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/telemetry/installId.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/mcp/src/telemetry/redaction.ts"],"sourcesContent":["export { MCPServer } from \"./server\";\n","import {\n createExtensionClient,\n type ExtensionClient,\n} from \"@player-devtools/client\";\nimport type { Transport } from \"@player-devtools/types\";\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport type { PostHog } from \"posthog-node\";\n\nimport { TOOL_DEFS, type ToolDef } from \"./tools\";\nimport { createAnalytics, MCP_VERSION } from \"./telemetry\";\n\nexport class MCPServer {\n private client: ExtensionClient;\n private server: McpServer;\n private analytics: PostHog | null;\n private transportConnected = false;\n\n constructor(private transport: Transport) {\n this.client = createExtensionClient(transport);\n this.server = new McpServer({\n name: \"player-devtools\",\n version: MCP_VERSION,\n });\n // Instrument before registering tools so every handler is wrapped.\n this.analytics = createAnalytics(this.server, {\n isTransportConnected: () => this.transportConnected,\n });\n this.registerTools();\n }\n\n private registerTools(): void {\n for (const def of TOOL_DEFS) {\n // `registerTool` is heavily generic over the Zod input shape; inferring\n // that across a heterogeneous array trips TS2589 (excessively deep). The\n // shapes are validated at runtime by the SDK, so register through a\n // loosely-typed view to keep inference shallow.\n const register = this.server.registerTool.bind(this.server) as (\n name: string,\n config: {\n description: string;\n inputSchema: ToolDef[\"inputSchema\"];\n annotations?: ToolDef[\"annotations\"];\n },\n cb: (args: unknown) => CallToolResult | Promise<CallToolResult>,\n ) => unknown;\n\n register(\n def.name,\n {\n description: def.description,\n inputSchema: def.inputSchema,\n annotations: def.annotations,\n },\n (args) => def.handle(this.client, args, this.transport),\n );\n }\n }\n\n async start(): Promise<void> {\n const stdioTransport = new StdioServerTransport();\n await this.server.connect(stdioTransport);\n try {\n await this.transport.connect();\n this.transportConnected = true;\n } catch (err) {\n console.warn(\n \"[MCPServer] Transport connect failed (will operate in disconnected mode):\",\n err instanceof Error ? err.message : err,\n );\n }\n }\n\n async stop(): Promise<void> {\n // Flush buffered events first: bin/run calls process.exit(0) as soon as\n // this resolves, which would otherwise drop them. Never fail shutdown on a\n // telemetry error.\n try {\n await this.analytics?.shutdown();\n } catch {\n /* best-effort */\n }\n this.client.destroy();\n await this.transport.close();\n await this.server.close();\n }\n}\n","import type { ExtensionClient } from \"@player-devtools/client\";\nimport type { PluginData } from \"@player-devtools/types\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { z } from \"zod\";\n\nimport { ok, err, type ToolDef } from \"./index\";\n\ntype Failure = { error: string };\ntype PlayerOk = {\n id: string;\n player: {\n plugins: Record<string, PluginData>;\n active: boolean;\n config: Record<string, unknown>;\n };\n};\ntype BasicPluginOk = PlayerOk & { basicPlugin: PluginData };\n\n/** Optional player id, shared by the player-scoped read tools. */\nconst playerIdShape = {\n playerId: z\n .string()\n .optional()\n .describe(\"Player ID. Defaults to the currently selected player.\"),\n};\n\nconst PlayerInput = z.object(playerIdShape);\n\nfunction resolvePlayer(\n client: ExtensionClient,\n playerId?: string,\n): Failure | PlayerOk {\n const { players, current } = client.getState();\n const id = playerId ?? current.player;\n if (!id) return { error: \"no player selected\" };\n const player = players[id];\n if (!player) return { error: `player not found: ${id}` };\n return { id, player };\n}\n\nfunction resolveBasicPlugin(\n client: ExtensionClient,\n playerId?: string,\n): Failure | BasicPluginOk {\n const resolved = resolvePlayer(client, playerId);\n if (\"error\" in resolved) return resolved;\n const { id, player } = resolved;\n // Find the first plugin — by convention the basic plugin is registered first\n const [basicPlugin] = Object.values(player.plugins);\n if (!basicPlugin) return { error: \"no plugin registered for this player\" };\n return { id, player, basicPlugin };\n}\n\nexport function handleGetFlow(\n client: ExtensionClient,\n input: unknown,\n): CallToolResult {\n const { playerId } = PlayerInput.parse(input);\n const resolved = resolveBasicPlugin(client, playerId);\n if (\"error\" in resolved) return err(resolved.error);\n return ok(resolved.basicPlugin.flow);\n}\n\nexport function handleGetData(\n client: ExtensionClient,\n input: unknown,\n): CallToolResult {\n const { playerId } = PlayerInput.parse(input);\n const resolved = resolveBasicPlugin(client, playerId);\n if (\"error\" in resolved) return err(resolved.error);\n return ok(resolved.basicPlugin.flow?.data ?? null);\n}\n\nexport function handleGetLogs(\n client: ExtensionClient,\n input: unknown,\n): CallToolResult {\n const { playerId } = PlayerInput.parse(input);\n const resolved = resolveBasicPlugin(client, playerId);\n if (\"error\" in resolved) return err(resolved.error);\n // Logs live in the plugin's flow data under a \"logs\" key by convention\n return ok(\n (resolved.basicPlugin.flow?.data as Record<string, unknown>)?.logs ?? [],\n );\n}\n\nconst getPluginDataShape = {\n ...playerIdShape,\n pluginId: z.string().describe(\"Plugin ID.\"),\n dataKey: z.string().describe(\"Key to retrieve from the plugin's data.\"),\n};\n\nconst GetPluginDataInput = z.object(getPluginDataShape);\n\nexport function handleGetPluginData(\n client: ExtensionClient,\n input: unknown,\n): CallToolResult {\n const { playerId, pluginId, dataKey } = GetPluginDataInput.parse(input);\n const resolved = resolvePlayer(client, playerId);\n if (\"error\" in resolved) return err(resolved.error);\n const plugin = resolved.player.plugins[pluginId];\n if (!plugin) return err(`plugin not found: ${pluginId}`);\n const value = (plugin.flow?.data as Record<string, unknown> | undefined)?.[\n dataKey\n ];\n return ok(value ?? null);\n}\n\nexport const getFlowDef: ToolDef = {\n name: \"get_flow\",\n description:\n \"Get the current flow from the basic devtools plugin for a Player instance.\",\n inputSchema: playerIdShape,\n handle: handleGetFlow,\n};\n\nexport const getDataDef: ToolDef = {\n name: \"get_data\",\n description:\n \"Get the current flow data model from the basic devtools plugin for a Player instance.\",\n inputSchema: playerIdShape,\n handle: handleGetData,\n};\n\nexport const getLogsDef: ToolDef = {\n name: \"get_logs\",\n description:\n \"Get the logs from the basic devtools plugin for a Player instance.\",\n inputSchema: playerIdShape,\n handle: handleGetLogs,\n};\n\nexport const getPluginDataDef: ToolDef = {\n name: \"get_plugin_data\",\n description: \"Get a specific data key from any plugin for a Player instance.\",\n inputSchema: getPluginDataShape,\n handle: handleGetPluginData,\n};\n","import type { ExtensionClient } from \"@player-devtools/client\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { z } from \"zod\";\n\nimport { ok, err, type ToolDef } from \"./index\";\n\nconst playerIdShape = {\n playerId: z\n .string()\n .optional()\n .describe(\"Player ID. Defaults to the currently selected player.\"),\n};\n\nconst GetPlayerStatusInput = z.object(playerIdShape);\n\nexport function handleListPlayers(client: ExtensionClient): CallToolResult {\n const { players, current } = client.getState();\n return ok({ players: Object.keys(players), current: current.player });\n}\n\nexport function handleGetPlayerStatus(\n client: ExtensionClient,\n input: unknown,\n): CallToolResult {\n const { playerId } = GetPlayerStatusInput.parse(input);\n const { players, current } = client.getState();\n const id = playerId ?? current.player;\n if (!id) return err(\"no player selected\");\n const player = players[id];\n if (!player) return err(`player not found: ${id}`);\n return ok({ active: player.active, plugins: Object.keys(player.plugins) });\n}\n\nexport const listPlayersDef: ToolDef = {\n name: \"list_players\",\n description:\n \"List all Player instances known to the devtools, and which one is currently selected.\",\n inputSchema: {},\n handle: (client) => handleListPlayers(client),\n};\n\nexport const getPlayerStatusDef: ToolDef = {\n name: \"get_player_status\",\n description:\n \"Get the active status and registered plugin IDs for a Player instance.\",\n inputSchema: playerIdShape,\n handle: handleGetPlayerStatus,\n};\n","import type { ExtensionClient } from \"@player-devtools/client\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { z } from \"zod\";\n\nimport { ok, err, type ToolDef } from \"./index\";\n\nconst describePluginShape = {\n playerId: z\n .string()\n .optional()\n .describe(\"Player ID. Defaults to the currently selected player.\"),\n pluginId: z.string().describe(\"Plugin ID.\"),\n};\n\nconst DescribePluginInput = z.object(describePluginShape);\n\nexport function handleDescribePlugin(\n client: ExtensionClient,\n input: unknown,\n): CallToolResult {\n const { playerId, pluginId } = DescribePluginInput.parse(input);\n const { players, current } = client.getState();\n const id = playerId ?? current.player;\n if (!id) return err(\"no player selected\");\n const player = players[id];\n if (!player) return err(`player not found: ${id}`);\n const plugin = player.plugins[pluginId];\n if (!plugin) return err(`plugin not found: ${pluginId}`);\n if (!plugin.capabilities)\n return err(`plugin \"${pluginId}\" has no capabilities declared`);\n return ok(plugin.capabilities);\n}\n\nexport const describePluginDef: ToolDef = {\n name: \"describe_plugin\",\n description:\n \"Get the capability descriptor declared by a plugin at registration time. Use this to discover what data keys and actions the plugin exposes.\",\n inputSchema: describePluginShape,\n handle: handleDescribePlugin,\n};\n","import type { ExtensionClient } from \"@player-devtools/client\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { z } from \"zod\";\n\nimport { ok, err, type ToolDef } from \"./index\";\n\nconst selectPlayerShape = {\n playerId: z.string().describe(\"The Player ID to select.\"),\n};\n\nconst invokeActionShape = {\n playerId: z\n .string()\n .optional()\n .describe(\"Player ID. Defaults to the currently selected player.\"),\n pluginId: z.string().describe(\"Plugin ID.\"),\n action: z.string().describe(\"Action name.\"),\n payload: z.string().optional().describe(\"Optional stringified payload.\"),\n};\n\nconst SelectPlayerInput = z.object(selectPlayerShape);\n\nconst InvokeActionInput = z.object(invokeActionShape);\n\nexport function handleSelectPlayer(\n client: ExtensionClient,\n input: unknown,\n): CallToolResult {\n const { playerId } = SelectPlayerInput.parse(input);\n const { players } = client.getState();\n if (!players[playerId]) return err(`player not found: ${playerId}`);\n client.selectPlayer(playerId);\n return ok({ selected: playerId });\n}\n\nexport function handleInvokeAction(\n client: ExtensionClient,\n input: unknown,\n): CallToolResult {\n const { playerId, pluginId, action, payload } =\n InvokeActionInput.parse(input);\n const { players, current } = client.getState();\n const id = playerId ?? current.player;\n if (!id) return err(\"no player selected\");\n const player = players[id];\n if (!player) return err(`player not found: ${id}`);\n const plugin = player.plugins[pluginId];\n if (!plugin) return err(`plugin not found: ${pluginId}`);\n if (\n plugin.capabilities?.actions &&\n !(action in plugin.capabilities.actions)\n ) {\n return err(`action \"${action}\" not declared in plugin capabilities`);\n }\n client.handleInteraction({ type: action, payload, target: id });\n return ok({ invoked: action });\n}\n\nexport const selectPlayerDef: ToolDef = {\n name: \"select_player\",\n description:\n \"Select a Player instance as the active target for subsequent tool calls.\",\n inputSchema: selectPlayerShape,\n handle: handleSelectPlayer,\n};\n\nexport const invokeActionDef: ToolDef = {\n name: \"invoke_action\",\n description:\n \"Invoke a named action on a plugin. Use describe_plugin first to discover available actions.\",\n inputSchema: invokeActionShape,\n handle: handleInvokeAction,\n};\n","import type { ExtensionClient } from \"@player-devtools/client\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport type { Transport } from \"@player-devtools/types\";\nimport { FlipperServerTransport } from \"@player-devtools/client-flipper\";\nimport { z } from \"zod\";\n\nimport { ok, err, type ToolDef } from \"./index\";\n\nconst clientIdShape = {\n clientId: z\n .string()\n .optional()\n .describe(\n \"Flipper client ID — 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 — for enable/disable, only clients not already in the desired state are messaged.\",\n ),\n};\n\nconst ClientIdInput = z.object(clientIdShape);\n\n/** Narrow the generic `Transport` to the concrete Flipper implementation. */\nfunction asFlipperTransport(\n transport: Transport | undefined,\n): FlipperServerTransport | null {\n return transport instanceof FlipperServerTransport ? transport : null;\n}\n\nexport function handleGetFlipperStatus(\n _client: ExtensionClient,\n _args: unknown,\n transport?: Transport,\n): CallToolResult {\n const flipper = asFlipperTransport(transport);\n if (!flipper) return err(\"not using a Flipper transport\");\n\n const { connected, host, port } = flipper.getDiagnostics();\n return ok({ connected, host, port });\n}\n\nexport function handleGetFlipperConsumers(\n _client: ExtensionClient,\n _args: unknown,\n transport?: Transport,\n): CallToolResult {\n const flipper = asFlipperTransport(transport);\n if (!flipper) return err(\"not using a Flipper transport\");\n\n const { owns, refs, activeClientIds, connectedClientIds } =\n flipper.getDiagnostics();\n return ok({ owns, refs, activeClientIds, connectedClientIds });\n}\n\nexport async function handleRestartFlipperServer(\n _client: ExtensionClient,\n _args: unknown,\n transport?: Transport,\n): Promise<CallToolResult> {\n const flipper = asFlipperTransport(transport);\n if (!flipper) return err(\"not using a Flipper transport\");\n\n const result = await flipper.restart();\n if (!result.ok) return err(result.reason);\n return ok({ restarted: true, host: result.host, port: result.port });\n}\n\nexport async function handleGetFlipperPluginInstallStatus(\n _client: ExtensionClient,\n _args: unknown,\n transport?: Transport,\n): Promise<CallToolResult> {\n const flipper = asFlipperTransport(transport);\n if (!flipper) return err(\"not using a Flipper transport\");\n\n if (!flipper.getDiagnostics().connected) {\n return err(\"flipper transport not connected\");\n }\n\n const status = await flipper.getPluginInstallStatus();\n if (!status.installed && status.reason) return err(status.reason);\n return ok(status);\n}\n\nexport const getFlipperStatusDef: ToolDef = {\n name: \"get_flipper_connection_status\",\n description:\n \"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.\",\n inputSchema: {},\n annotations: { readOnlyHint: true, destructiveHint: false },\n handle: handleGetFlipperStatus,\n};\n\nexport const getFlipperConsumersDef: ToolDef = {\n name: \"get_flipper_consumers\",\n description:\n \"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.\",\n inputSchema: {},\n annotations: { readOnlyHint: true, destructiveHint: false },\n handle: handleGetFlipperConsumers,\n};\n\nexport const restartFlipperServerDef: ToolDef = {\n name: \"restart_flipper_server\",\n description:\n \"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.\",\n inputSchema: {},\n annotations: { readOnlyHint: false, destructiveHint: true },\n handle: handleRestartFlipperServer,\n};\n\nexport const getFlipperPluginInstallStatusDef: ToolDef = {\n name: \"get_flipper_plugin_install_status\",\n description:\n \"Check whether the Player UI Devtools Flipper plugin is installed on the connected daemon.\",\n inputSchema: {},\n annotations: { readOnlyHint: true, destructiveHint: false },\n handle: handleGetFlipperPluginInstallStatus,\n};\n\nexport function handleGetFlipperPluginActivationStatus(\n _client: ExtensionClient,\n _args: unknown,\n transport?: Transport,\n): CallToolResult {\n const flipper = asFlipperTransport(transport);\n if (!flipper) return err(\"not using a Flipper transport\");\n\n const { connected, connectedClientIds, activeClientIds } =\n flipper.getDiagnostics();\n if (!connected) return err(\"flipper transport not connected\");\n\n const active = new Set(activeClientIds);\n return ok({\n activeClientIds,\n inactiveClientIds: connectedClientIds.filter((id) => !active.has(id)),\n });\n}\n\nexport async function handleEnableFlipperPlugin(\n _client: ExtensionClient,\n args: unknown,\n transport?: Transport,\n): Promise<CallToolResult> {\n const flipper = asFlipperTransport(transport);\n if (!flipper) return err(\"not using a Flipper transport\");\n\n const { clientId } = ClientIdInput.parse(args);\n try {\n await flipper.enablePlugin(clientId);\n } catch (error) {\n return err(error instanceof Error ? error.message : String(error));\n }\n return ok({ enabled: true, clientId: clientId ?? \"all\" });\n}\n\nexport async function handleDisableFlipperPlugin(\n _client: ExtensionClient,\n args: unknown,\n transport?: Transport,\n): Promise<CallToolResult> {\n const flipper = asFlipperTransport(transport);\n if (!flipper) return err(\"not using a Flipper transport\");\n\n const { clientId } = ClientIdInput.parse(args);\n try {\n await flipper.disablePlugin(clientId);\n } catch (error) {\n return err(error instanceof Error ? error.message : String(error));\n }\n return ok({ disabled: true, clientId: clientId ?? \"all\" });\n}\n\nexport const getFlipperPluginActivationStatusDef: ToolDef = {\n name: \"get_flipper_plugin_activation_status\",\n description:\n \"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.\",\n inputSchema: {},\n annotations: { readOnlyHint: true, destructiveHint: false },\n handle: handleGetFlipperPluginActivationStatus,\n};\n\nexport const enableFlipperPluginDef: ToolDef = {\n name: \"enable_flipper_plugin\",\n description:\n \"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 — after activating, poll list_players until the expected Player appears.\",\n inputSchema: clientIdShape,\n annotations: { readOnlyHint: false, destructiveHint: false },\n handle: handleEnableFlipperPlugin,\n};\n\nexport const disableFlipperPluginDef: ToolDef = {\n name: \"disable_flipper_plugin\",\n description:\n \"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.\",\n inputSchema: clientIdShape,\n annotations: { readOnlyHint: false, destructiveHint: false },\n handle: handleDisableFlipperPlugin,\n};\n","import type { ExtensionClient } from \"@player-devtools/client\";\nimport type {\n CallToolResult,\n ToolAnnotations,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport type { Transport } from \"@player-devtools/types\";\nimport type { ZodRawShape } from \"zod\";\n\n/**\n * A tool definition consumed by the MCP server. `inputSchema` is a Zod raw\n * shape — the SDK derives the JSON Schema, validates input, and types the\n * handler's `args`. The handler receives the running devtools client, the\n * validated args, and the raw `Transport` for tools that need connection-level\n * diagnostics `ExtensionClient` doesn't expose.\n */\nexport type ToolDef<Shape extends ZodRawShape = ZodRawShape> = {\n name: string;\n description: string;\n inputSchema: Shape;\n annotations?: ToolAnnotations;\n handle: (\n client: ExtensionClient,\n args: unknown,\n transport?: Transport,\n ) => CallToolResult | Promise<CallToolResult>;\n};\n\n/** Shared JSON-envelope helpers used by every tool handler in this package. */\nexport function ok(value: unknown): CallToolResult {\n return { content: [{ type: \"text\", text: JSON.stringify(value) }] };\n}\n\nexport function err(message: string): CallToolResult {\n return {\n content: [{ type: \"text\", text: JSON.stringify({ error: message }) }],\n };\n}\n\nexport * from \"./flow\";\nexport * from \"./players\";\nexport * from \"./plugins\";\nexport * from \"./select\";\nexport * from \"./flipper\";\n\nimport { listPlayersDef, getPlayerStatusDef } from \"./players\";\nimport { getFlowDef, getDataDef, getLogsDef, getPluginDataDef } from \"./flow\";\nimport { describePluginDef } from \"./plugins\";\nimport { selectPlayerDef, invokeActionDef } from \"./select\";\nimport {\n getFlipperStatusDef,\n getFlipperConsumersDef,\n restartFlipperServerDef,\n getFlipperPluginInstallStatusDef,\n getFlipperPluginActivationStatusDef,\n enableFlipperPluginDef,\n disableFlipperPluginDef,\n} from \"./flipper\";\n\n/** Every tool the MCP server exposes. */\nexport const TOOL_DEFS: ToolDef[] = [\n listPlayersDef,\n getPlayerStatusDef,\n getFlowDef,\n getDataDef,\n getLogsDef,\n getPluginDataDef,\n describePluginDef,\n selectPlayerDef,\n invokeActionDef,\n getFlipperStatusDef,\n getFlipperConsumersDef,\n restartFlipperServerDef,\n getFlipperPluginInstallStatusDef,\n getFlipperPluginActivationStatusDef,\n enableFlipperPluginDef,\n disableFlipperPluginDef,\n];\n","import * as os from \"os\";\nimport { instrument } from \"@posthog/mcp\";\nimport { PostHog } from \"posthog-node\";\n\nimport { resolveTelemetryConfig } from \"./config\";\nimport { getInstallId } from \"./installId\";\nimport { allowlistEventProperties } from \"./redaction\";\n\nexport {\n ALLOWED_EVENT_PROPERTIES,\n allowlistEventProperties,\n} from \"./redaction\";\nexport { resolveTelemetryConfig, type TelemetryConfig } from \"./config\";\nexport { getInstallId, type InstallIdDeps } from \"./installId\";\n\ndeclare global {\n const __VERSION__: string;\n}\n\n/**\n * Stamped at release build time by tsup (see devtools/tsup.config.ts). The\n * guard is required — the global is absent in local and test builds.\n */\nexport const MCP_VERSION: string =\n typeof __VERSION__ !== \"undefined\" ? __VERSION__ : \"unstamped\";\n\nexport type AnalyticsDeps = {\n /** Reports whether the devtools transport is currently connected. */\n isTransportConnected: () => boolean;\n};\n\n/**\n * Instruments `server` with anonymous usage analytics.\n *\n * Returns the PostHog client so the caller can flush it on shutdown, or `null`\n * when telemetry is disabled or no durable identity is available. Never throws:\n * telemetry must not be able to prevent the server from starting.\n */\nexport function createAnalytics(\n server: object,\n deps: AnalyticsDeps,\n): PostHog | null {\n try {\n const config = resolveTelemetryConfig();\n if (!config.enabled) return null;\n\n const installId = getInstallId();\n if (installId === null) return null;\n\n const posthog = new PostHog(config.apiKey, {\n host: config.host,\n // The load-bearing privacy control. Runs inside posthog-node's capture(),\n // so it applies to everything the MCP SDK emits regardless of the SDK's\n // own hooks. See redaction.ts for why this is an allowlist.\n before_send: [allowlistEventProperties],\n });\n\n instrument(server, posthog, {\n // Defaults to ON, and would inject a *required* `context` parameter into\n // every tool schema asking the agent to narrate user intent — mutating\n // our public tool API and adding per-call token cost.\n context: false,\n identify: { distinctId: installId },\n eventProperties: () => ({\n mcp_version: MCP_VERSION,\n os_platform: os.platform(),\n node_major: Number.parseInt(\n process.versions.node.split(\".\")[0] ?? \"\",\n 10,\n ),\n transport_connected: deps.isTransportConnected(),\n surface: \"mcp-server\",\n }),\n // Redundant with `before_send` above, kept as a second independent layer.\n // This hook fails closed: the SDK drops the event if it throws.\n beforeSend: allowlistEventProperties,\n });\n\n return posthog;\n } catch {\n // Telemetry is strictly best-effort — a misconfiguration must never take\n // down the server.\n return null;\n }\n}\n","declare global {\n const __POSTHOG_KEY__: string;\n}\n\n/**\n * PostHog project API key, stamped at release build time from the\n * `POSTHOG_PROJECT_KEY` CI environment variable (see\n * helpers/release/workspace-status.sh and tsup.config.ts), mirroring how\n * `__VERSION__` is stamped.\n *\n * This is a *public, write-only* ingestion token — it can only send events and\n * cannot read data back, which is why it is safe to ship in an open-source\n * package.\n *\n * The `typeof` guard is required: the global is absent in local and test\n * builds, where it resolves to an empty string and disables telemetry.\n */\nconst POSTHOG_PROJECT_KEY =\n typeof __POSTHOG_KEY__ !== \"undefined\" ? __POSTHOG_KEY__ : \"\";\n\nconst DEFAULT_POSTHOG_HOST = \"https://us.i.posthog.com\";\n\nexport type TelemetryConfig =\n | { readonly enabled: false }\n | { readonly enabled: true; readonly apiKey: string; readonly host: string };\n\n/**\n * Presence of the variable opts out, *except* for explicit negatives —\n * `DO_NOT_TRACK=0` means \"tracking is fine\", not \"opted out\".\n */\nfunction isTruthy(value: string | undefined): boolean {\n if (value === undefined) return false;\n const normalized = value.trim().toLowerCase();\n if (normalized === \"\" || normalized === \"0\" || normalized === \"false\") {\n return false;\n }\n return true;\n}\n\nfunction isOptedOut(env: NodeJS.ProcessEnv): boolean {\n return (\n isTruthy(env.PLAYER_DEVTOOLS_TELEMETRY_DISABLED) ||\n // Cross-vendor convention (consoledonottrack.com) — honored so a user who\n // sets it once is covered everywhere.\n isTruthy(env.DO_NOT_TRACK)\n );\n}\n\nexport function resolveTelemetryConfig(\n env: NodeJS.ProcessEnv = process.env,\n): TelemetryConfig {\n if (isOptedOut(env)) return { enabled: false };\n\n const apiKey = env.PLAYER_DEVTOOLS_TELEMETRY_KEY ?? POSTHOG_PROJECT_KEY;\n // Unstamped (local/dev builds) or unset in CI — stay silent rather than\n // firing doomed requests at PostHog on every startup.\n if (!apiKey) return { enabled: false };\n // Only public write-only project keys may ship. A `phx_` (personal) or\n // `phs_` (project secret) key is a real credential and must never be baked\n // into a published artifact, so refuse to use one even if stamped.\n if (!apiKey.startsWith(\"phc_\")) return { enabled: false };\n\n const host = (\n env.PLAYER_DEVTOOLS_TELEMETRY_HOST ?? DEFAULT_POSTHOG_HOST\n ).replace(/\\/+$/, \"\");\n\n return { enabled: true, apiKey, host };\n}\n","import { randomUUID } from \"crypto\";\nimport * as fs from \"fs\";\nimport * as os from \"os\";\nimport * as path from \"path\";\n\nexport type InstallIdDeps = {\n /** Resolves the user's home directory. */\n homedir: () => string;\n /** Reads the install file. */\n readFileSync: typeof fs.readFileSync;\n /** Writes the install file. */\n writeFileSync: typeof fs.writeFileSync;\n /** Creates the install directory. */\n mkdirSync: typeof fs.mkdirSync;\n /** Mints a new identifier. */\n randomUUID: () => string;\n};\n\nconst defaultDeps: InstallIdDeps = {\n homedir: os.homedir,\n readFileSync: fs.readFileSync,\n writeFileSync: fs.writeFileSync,\n mkdirSync: fs.mkdirSync,\n randomUUID,\n};\n\ntype InstallFile = { installId: string };\n\nconst UUID_PATTERN =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\nexport const INSTALL_DIR_NAME = \".player-ui-devtools\";\nexport const INSTALL_FILE_NAME = \"install.json\";\n\n/**\n * A stable, anonymous per-machine identifier.\n *\n * Stored under the user's home directory rather than the OS temp dir the\n * flipper refcount uses: temp is periodically reaped, which would regenerate\n * the id on every reboot and turn \"unique installs\" into \"unique boots\".\n *\n * Returns `null` when the id can neither be read nor persisted (read-only FS,\n * sandbox, absent HOME). Callers treat that as \"telemetry off\" — returning an\n * in-memory id instead would register a brand-new install on every run and\n * systematically inflate counts for exactly the sandboxed population least\n * likely to be real users.\n */\nexport function getInstallId(deps: InstallIdDeps = defaultDeps): string | null {\n const dir = path.join(deps.homedir(), INSTALL_DIR_NAME);\n const file = path.join(dir, INSTALL_FILE_NAME);\n\n try {\n const parsed = JSON.parse(\n deps.readFileSync(file, \"utf8\") as string,\n ) as Partial<InstallFile>;\n // Validate the shape, not just the parse: `{\"installId\": 42}` parses fine\n // but is not a usable identity.\n if (\n typeof parsed.installId === \"string\" &&\n UUID_PATTERN.test(parsed.installId)\n ) {\n return parsed.installId;\n }\n } catch {\n /* missing or corrupt — fall through and regenerate */\n }\n\n const installId = deps.randomUUID();\n try {\n deps.mkdirSync(dir, { recursive: true });\n const contents: InstallFile = { installId };\n // 0600: a stable per-user identifier should not be world-readable.\n deps.writeFileSync(file, JSON.stringify(contents), { mode: 0o600 });\n } catch {\n return null;\n }\n\n return installId;\n}\n","/**\n * Event property allowlist.\n *\n * `@posthog/mcp` captures tool arguments (`$mcp_parameters`) and tool results\n * (`$mcp_response`) unconditionally — there is no SDK option to disable it, and\n * its built-in sanitizer only matches sensitive *key names* (`token`,\n * `password`, ...), so a field named `flowContent` would be transmitted\n * verbatim. Devtools tool arguments carry player/plugin ids and `invoke_action`\n * payloads, i.e. potentially customer flow data.\n *\n * This is an allowlist rather than a denylist on purpose: the SDK is 0.x and\n * ships frequently, so a denylist naming today's two payload keys would\n * silently start leaking the moment a release adds a third. Anything not\n * explicitly listed here never reaches the wire.\n */\nexport const ALLOWED_EVENT_PROPERTIES: ReadonlySet<string> = new Set([\n // MCP tool call shape — names and timings only, never payloads.\n \"$mcp_tool_name\",\n \"$mcp_duration_ms\",\n \"$mcp_is_error\",\n \"$mcp_error_type\",\n \"$mcp_listed_tool_names\",\n \"$mcp_missing_capability\",\n // Which editor/agent is driving the server.\n \"$mcp_client_name\",\n \"$mcp_client_version\",\n \"$mcp_server_name\",\n \"$mcp_server_version\",\n \"$mcp_protocol_version\",\n // PostHog bookkeeping.\n \"$session_id\",\n \"$process_person_profile\",\n \"$lib\",\n \"$lib_version\",\n // Our own event properties.\n \"mcp_version\",\n \"os_platform\",\n \"node_major\",\n \"transport_connected\",\n \"surface\",\n]);\n\nexport type CapturedEvent = {\n /** Event name. */\n event?: string;\n /** Event properties. */\n properties?: Record<string, unknown>;\n};\n\n/**\n * Drops every property not in {@link ALLOWED_EVENT_PROPERTIES}.\n *\n * Installed as a `posthog-node` client-level `before_send`, which runs inside\n * `capture()` — a chokepoint the MCP SDK cannot route around, since we own the\n * client instance and it does not.\n *\n * Accepts `null` because `before_send` hooks compose: an earlier hook may have\n * already dropped the event.\n */\nexport function allowlistEventProperties<Event extends CapturedEvent>(\n event: Event | null,\n): Event | null {\n if (!event?.properties) return event;\n\n event.properties = Object.fromEntries(\n Object.entries(event.properties).filter(([key]) =>\n ALLOWED_EVENT_PROPERTIES.has(key),\n ),\n );\n\n return event;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAGO;AAEP,IAAAA,cAA0B;AAC1B,mBAAqC;;;ACHrC,iBAAkB;AAgBlB,IAAM,gBAAgB;AAAA,EACpB,UAAU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