@@ -185,7 +185,6 @@ async function launchStudio(coursePath: string, options: StudioOptions) {
185185 // Phase 9.5: Launch Express backend
186186 const expressResult = await startExpressBackend (
187187 couchDBManager . getConnectionDetails ( ) ,
188- resolvedPath ,
189188 unpackResult . databaseName
190189 ) ;
191190 expressServer = expressResult . server ;
@@ -210,7 +209,7 @@ async function launchStudio(coursePath: string, options: StudioOptions) {
210209 console . log ( chalk . gray ( ` Express API: ${ expressResult . url } ` ) ) ;
211210
212211 // Display MCP connection information
213- const mcpInfo = getMCPConnectionInfo ( unpackResult , couchDBManager , resolvedPath ) ;
212+ const mcpInfo = getMCPConnectionInfo ( unpackResult , couchDBManager ) ;
214213 console . log ( chalk . blue ( `🔗 MCP Server: ${ mcpInfo . command } ` ) ) ;
215214 console . log ( chalk . gray ( ` Connect MCP clients using the command above` ) ) ;
216215 console . log ( chalk . gray ( ` Environment variables for MCP:` ) ) ;
@@ -219,7 +218,7 @@ async function launchStudio(coursePath: string, options: StudioOptions) {
219218 } ) ;
220219
221220 // Display .mcp.json content for Claude Code integration
222- const mcpJsonContent = generateMCPJson ( unpackResult , couchDBManager , resolvedPath ) ;
221+ const mcpJsonContent = generateMCPJson ( unpackResult , couchDBManager ) ;
223222 console . log ( chalk . blue ( `📋 .mcp.json content:` ) ) ;
224223 console . log ( chalk . gray ( mcpJsonContent ) ) ;
225224
@@ -569,7 +568,6 @@ async function openBrowser(url: string): Promise<void> {
569568 */
570569async function startExpressBackend (
571570 couchDbConnectionDetails : ConnectionDetails ,
572- _projectPath : string ,
573571 databaseName : string
574572) : Promise < { server : http . Server ; port : number ; url : string } > {
575573 console . log ( chalk . blue ( '⚡ Starting Express backend server...' ) ) ;
@@ -603,7 +601,7 @@ async function startExpressBackend(
603601 try {
604602 // Set NODE_ENV for studio mode authentication bypass
605603 process . env . NODE_ENV = 'studio' ;
606-
604+
607605 // Create Express app using factory
608606 const app = createExpressApp ( config ) ;
609607
@@ -1317,7 +1315,7 @@ export default defineConfig({
13171315 },
13181316 dedupe: [
13191317 'vue',
1320- 'vuetify',
1318+ 'vuetify',
13211319 'vue-router',
13221320 'pinia',
13231321 '@vue-skuilder/db',
@@ -1334,45 +1332,18 @@ export default defineConfig({
13341332}
13351333
13361334/**
1337- * Determine the correct MCP server executable path/command based on project context
1335+ * Determine the correct MCP server executable path.
1336+ * This is now greatly simplified because the bundled server is always
1337+ * located relative to this `studio.ts` file.
13381338 */
1339- function resolveMCPExecutable ( projectPath : string ) : {
1340- command : string ;
1341- args : string [ ] ;
1342- isNpx : boolean ;
1343- } {
1344- // Check if we're in the monorepo (packages/cli exists)
1345- const monorepoCliPath = path . join ( projectPath , 'packages' , 'cli' , 'dist' , 'mcp-server.js' ) ;
1346- if ( fs . existsSync ( monorepoCliPath ) ) {
1347- return {
1348- command : './packages/cli/dist/mcp-server.js' ,
1349- args : [ ] ,
1350- isNpx : false ,
1351- } ;
1352- }
1339+ function resolveMCPExecutable ( ) : { command : string ; args : string [ ] } {
1340+ // Resolve the path to the bundled server relative to the current file.
1341+ // __dirname is the `dist/commands` directory.
1342+ const serverPath = path . resolve ( __dirname , '..' , 'mcp-server.js' ) ;
13531343
1354- // Check if @vue -skuilder/cli is installed as a dependency
1355- const scaffoldedCliPath = path . join (
1356- projectPath ,
1357- 'node_modules' ,
1358- '@vue-skuilder' ,
1359- 'cli' ,
1360- 'dist' ,
1361- 'mcp-server.js'
1362- ) ;
1363- if ( fs . existsSync ( scaffoldedCliPath ) ) {
1364- return {
1365- command : './node_modules/@vue-skuilder/cli/dist/mcp-server.js' ,
1366- args : [ ] ,
1367- isNpx : false ,
1368- } ;
1369- }
1370-
1371- // Fallback to npx approach
13721344 return {
1373- command : 'npx' ,
1374- args : [ '@vue-skuilder/cli' , 'mcp-server' ] ,
1375- isNpx : true ,
1345+ command : 'node' ,
1346+ args : [ serverPath ] ,
13761347 } ;
13771348}
13781349
@@ -1381,19 +1352,16 @@ function resolveMCPExecutable(projectPath: string): {
13811352 */
13821353function getMCPConnectionInfo (
13831354 unpackResult : UnpackResult ,
1384- couchDBManager : CouchDBManager ,
1385- projectPath : string
1355+ couchDBManager : CouchDBManager
13861356) : { command : string ; env : Record < string , string > } {
13871357 const couchDetails = couchDBManager . getConnectionDetails ( ) ;
1388- const executable = resolveMCPExecutable ( projectPath ) ;
1358+ const executable = resolveMCPExecutable ( ) ;
1359+ const port = couchDetails . port || 5985 ;
13891360
13901361 // Build command string for display
1391- let commandStr : string ;
1392- if ( executable . isNpx ) {
1393- commandStr = `${ executable . command } ${ executable . args . join ( ' ' ) } ${ unpackResult . databaseName } ${ couchDetails . port } ` ;
1394- } else {
1395- commandStr = `node ${ executable . command } ${ unpackResult . databaseName } ${ couchDetails . port } ` ;
1396- }
1362+ const commandStr = `${ executable . command } ${ executable . args . join ( ' ' ) } ${
1363+ unpackResult . databaseName
1364+ } ${ port } `;
13971365
13981366 return {
13991367 command : commandStr ,
@@ -1412,12 +1380,11 @@ function getMCPConnectionInfo(
14121380function generateMCPJson (
14131381 unpackResult : UnpackResult ,
14141382 couchDBManager : CouchDBManager ,
1415- projectPath : string ,
14161383 serverName : string = 'vue-skuilder-studio'
14171384) : string {
14181385 const couchDetails = couchDBManager . getConnectionDetails ( ) ;
14191386 const port = couchDetails . port || 5985 ;
1420- const executable = resolveMCPExecutable ( projectPath ) ;
1387+ const executable = resolveMCPExecutable ( ) ;
14211388
14221389 const mcpConfig = {
14231390 mcpServers : {
0 commit comments