@@ -6,7 +6,6 @@ import { mkdir, readFile, writeFile } from "node:fs/promises";
66import { dirname , join , relative } from "node:path" ;
77import ora , { type Ora } from "ora" ;
88
9- import { App , listApps } from "../services/bootstrap.js" ;
109import {
1110 ConfigPaths ,
1211 getServersConfig ,
@@ -17,21 +16,15 @@ import {
1716import { configStore } from "../stores/config.js" ;
1817import { handleError } from "../utils/errors.js" ;
1918import { fileExists } from "../utils/file.js" ;
20- import {
21- appIdOption ,
22- configScopeOption ,
23- editorOption ,
24- } from "../utils/options.js" ;
19+ import { configScopeOption , editorOption } from "../utils/options.js" ;
2520
2621export const mcpAction = async ( options : {
2722 editor ?: SupportedEditor ;
28- appId ?: string ;
2923 scope ?: "local" | "global" ;
3024} ) => {
3125 const config = configStore . getConfig ( ) ;
3226 let spinner : Ora | undefined ;
3327 let selectedEditor = options . editor ;
34- let selectedApp : App | undefined ;
3528
3629 // Select Editor/Client
3730 if ( ! selectedEditor ) {
@@ -44,45 +37,6 @@ export const mcpAction = async (options: {
4437 } ) ;
4538 }
4639
47- // Select App ID
48- try {
49- spinner = ora ( `Loading apps from ${ chalk . cyan ( config . baseUrl ) } ...` ) . start ( ) ;
50- const apps = listApps ( ) ;
51- spinner . succeed ( `Loaded apps from ${ chalk . cyan ( config . baseUrl ) } .` ) ;
52-
53- if ( apps . length === 0 ) {
54- throw new Error ( "You don't have any apps yet. Please create one." ) ;
55- }
56-
57- let selectedAppId : string ;
58- if ( options . appId ) {
59- // If appId is provided, try to find it directly
60- const app = apps . find ( ( { id } ) => id === options . appId ) ;
61- if ( ! app ) {
62- throw new Error ( `Could not find app with ID: ${ options . appId } ` ) ;
63- }
64-
65- selectedAppId = app . id ;
66- } else {
67- // Otherwise, show selection prompt
68- const nonDemoApp = apps . find ( ( app ) => ! app . demo ) ;
69- const longestName = Math . max ( ...apps . map ( ( app ) => app . name . length ) ) ;
70-
71- selectedAppId = await select ( {
72- message : "Select an app" ,
73- default : config . appId ?? nonDemoApp ?. id ,
74- choices : apps . map ( ( app ) => ( {
75- name : `${ app . name . padEnd ( longestName , " " ) } ${ app . demo ? " [Demo]" : "" } ` ,
76- value : app . id ,
77- } ) ) ,
78- } ) ;
79- }
80- selectedApp = apps . find ( ( app ) => app . id === selectedAppId ) ! ;
81- } catch ( error ) {
82- spinner ?. fail ( "Loading apps failed." ) ;
83- handleError ( error , "MCP Configuration" ) ;
84- }
85-
8640 // Determine Config Path
8741 const projectPath = configStore . getProjectPath ( ) ;
8842 const globalPath = resolveConfigPath ( selectedEditor , false ) ;
@@ -152,7 +106,7 @@ export const mcpAction = async (options: {
152106
153107 // Prompt for Add/Update
154108 let targetEntryKey : string ;
155- const defaultNewKey = `Reflag - ${ selectedApp . name } ` ;
109+ const defaultNewKey = `Reflag` ;
156110
157111 if ( existingReflagEntries . length === 0 ) {
158112 targetEntryKey = defaultNewKey ;
@@ -183,13 +137,8 @@ export const mcpAction = async (options: {
183137 }
184138
185139 // Construct the MCP endpoint URL
186- const mcpUrlBase = config . apiUrl + "/mcp" ;
187- const mcpUrlWithAppId = `${ mcpUrlBase } ?appId=${ selectedApp . id } ` ;
188-
189140 const newEntryValue = {
190- type : "stdio" ,
191- command : "npx" ,
192- args : [ "mcp-remote@latest" , mcpUrlWithAppId ] ,
141+ url : config . apiUrl + "/mcp" ,
193142 } ;
194143
195144 // Update Config Object
@@ -228,16 +177,7 @@ export function registerMcpCommand(cli: Command) {
228177 cli
229178 . command ( "mcp" )
230179 . description ( "Configure Reflag's remote MCP server for your AI assistant." )
231- . addOption ( appIdOption )
232180 . addOption ( editorOption )
233181 . addOption ( configScopeOption )
234182 . action ( mcpAction ) ;
235-
236- // Update the config with the cli override values
237- cli . hook ( "preAction" , ( _ , command ) => {
238- const { appId } = command . opts ( ) ;
239- configStore . setConfig ( {
240- appId,
241- } ) ;
242- } ) ;
243183}
0 commit comments