Skip to content

Commit e0632f3

Browse files
committed
add helper to generate / print .mcp.json cfg
1 parent 57ffd50 commit e0632f3

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

packages/cli/src/commands/studio.ts

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ async function launchStudio(coursePath: string, options: StudioOptions) {
176176
console.log(chalk.white(`🎨 Studio URL: http://localhost:${studioUIPort}`));
177177
console.log(chalk.gray(` Database: ${studioDatabaseName} on port ${options.port}`));
178178
console.log(chalk.gray(` Express API: ${expressManager.getConnectionDetails().url}`));
179-
179+
180180
// Display MCP connection information
181181
const mcpInfo = getMCPConnectionInfo(unpackResult, couchDBManager);
182182
console.log(chalk.blue(`🔗 MCP Server: ${mcpInfo.command}`));
@@ -185,7 +185,12 @@ async function launchStudio(coursePath: string, options: StudioOptions) {
185185
Object.entries(mcpInfo.env).forEach(([key, value]) => {
186186
console.log(chalk.gray(` ${key}=${value}`));
187187
});
188-
188+
189+
// Display .mcp.json content for Claude Code integration
190+
const mcpJsonContent = generateMCPJson(unpackResult, couchDBManager);
191+
console.log(chalk.blue(`📋 .mcp.json content:`));
192+
console.log(chalk.gray(mcpJsonContent));
193+
189194
if (options.browser) {
190195
console.log(chalk.cyan(`🌐 Opening browser...`));
191196
await openBrowser(`http://localhost:${studioUIPort}`);
@@ -1255,3 +1260,35 @@ function getMCPConnectionInfo(
12551260
},
12561261
};
12571262
}
1263+
1264+
/**
1265+
* Generate .mcp.json content for Claude Code integration
1266+
*/
1267+
function generateMCPJson(
1268+
unpackResult: UnpackResult,
1269+
couchDBManager: CouchDBManager,
1270+
serverName: string = 'vue-skuilder-studio'
1271+
): string {
1272+
const couchDetails = couchDBManager.getConnectionDetails();
1273+
const port = couchDetails.port || 5985;
1274+
1275+
// Use relative path to mcp-server.js for portability
1276+
const mcpServerRelativePath = './packages/cli/dist/mcp-server.js';
1277+
1278+
const mcpConfig = {
1279+
mcpServers: {
1280+
[serverName]: {
1281+
command: mcpServerRelativePath,
1282+
args: [unpackResult.databaseName, port.toString()],
1283+
env: {
1284+
COUCHDB_SERVER_URL: couchDetails.url.replace(/^https?:\/\//, ''),
1285+
COUCHDB_SERVER_PROTOCOL: couchDetails.url.startsWith('https') ? 'https' : 'http',
1286+
COUCHDB_USERNAME: couchDetails.username,
1287+
COUCHDB_PASSWORD: couchDetails.password,
1288+
},
1289+
},
1290+
},
1291+
};
1292+
1293+
return JSON.stringify(mcpConfig, null, 2);
1294+
}

0 commit comments

Comments
 (0)