Skip to content

Commit 4497680

Browse files
committed
fix(cli-mcp): wire mcp subcommand via early dispatch in main to avoid Layer conflict
Layer.launch is incompatible with @effect/cli's layer composition, so dispatch the mcp subcommand before the CLI pipeline runs. The mcpCommand stub remains registered so it appears in --help output. Also adds root dependency link for @forgerock/login-framework-cli.
1 parent 286be25 commit 4497680

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@
9999
"picomatch@2": "2.3.2",
100100
"picomatch@4": "4.0.4",
101101
"uuid": "^14.0.0",
102-
"yaml": ">=2.8.3"
102+
"yaml": ">=2.8.3",
103+
"@forgerock/login-framework-cli": "link:tools/cli"
103104
}
105+
},
106+
"dependencies": {
107+
"@forgerock/login-framework-cli": "link:tools/cli"
104108
}
105109
}

tools/cli/src/main.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,18 @@ function readCliVersion(): string {
2828
}
2929
}
3030

31+
if (process.argv[2] === 'mcp') {
32+
const { runMcpServer } = await import('./mcp.js');
33+
runMcpServer();
34+
}
35+
3136
const version = readCliVersion();
3237

3338
const rootCommand = Command.make('ping-lf').pipe(
3439
Command.withDescription(
3540
'CLI for initializing, scaffolding, and updating Ping Login Widget and Login App custom component projects.',
3641
),
37-
Command.withSubcommands([
38-
initCommand,
39-
generateCommand,
40-
updateCommand,
41-
releasesCommand,
42-
mcpCommand,
43-
]),
42+
Command.withSubcommands([initCommand, generateCommand, updateCommand, releasesCommand, mcpCommand]),
4443
);
4544

4645
const cli = Command.run(rootCommand, {

tools/cli/src/mcp.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ const ServerLayer = McpServer.toolkit(mcpToolkit).pipe(
264264

265265
export const runMcpServer = () => Layer.launch(ServerLayer).pipe(NodeRuntime.runMain);
266266

267-
export const mcpCommand = Command.make('mcp', {}, () => Layer.launch(ServerLayer)).pipe(
267+
// mcpCommand is registered only so `ping-lf --help` lists `mcp` as a subcommand.
268+
// The actual dispatch happens in main.ts before the @effect/cli pipeline runs,
269+
// because Layer.launch is incompatible with the CLI's layer composition.
270+
export const mcpCommand = Command.make('mcp', {}, () => Effect.void).pipe(
268271
Command.withDescription('Start as an MCP server over stdio.'),
269272
);

0 commit comments

Comments
 (0)