@@ -5,8 +5,10 @@ import prompts from "prompts";
55import { generateReadme } from "../templates/readme.js" ;
66import { execa } from "execa" ;
77
8- export async function createProject ( name ?: string , options ?: { http ?: boolean , cors ?: boolean , port ?: number } ) {
8+ export async function createProject ( name ?: string , options ?: { http ?: boolean , cors ?: boolean , port ?: number , install ?: boolean } ) {
99 let projectName : string ;
10+ // Default install to true if not specified
11+ const shouldInstall = options ?. install !== false ;
1012
1113 if ( ! name ) {
1214 const response = await prompts ( [
@@ -166,47 +168,60 @@ export default ExampleTool;`;
166168 throw new Error ( "Failed to initialize git repository" ) ;
167169 }
168170
169- console . log ( "Installing dependencies..." ) ;
170- const npmInstall = spawnSync ( "npm" , [ "install" ] , {
171- stdio : "inherit" ,
172- shell : true
173- } ) ;
171+ if ( shouldInstall ) {
172+ console . log ( "Installing dependencies..." ) ;
173+ const npmInstall = spawnSync ( "npm" , [ "install" ] , {
174+ stdio : "inherit" ,
175+ shell : true
176+ } ) ;
174177
175- if ( npmInstall . status !== 0 ) {
176- throw new Error ( "Failed to install dependencies" ) ;
177- }
178-
179- console . log ( "Building project..." ) ;
180- const tscBuild = await execa ( 'npx' , [ 'tsc' ] , {
181- cwd : projectDir ,
182- stdio : "inherit" ,
183- } ) ;
178+ if ( npmInstall . status !== 0 ) {
179+ throw new Error ( "Failed to install dependencies" ) ;
180+ }
184181
185- if ( tscBuild . exitCode !== 0 ) {
186- throw new Error ( "Failed to build TypeScript" ) ;
187- }
182+ console . log ( "Building project..." ) ;
183+ const tscBuild = await execa ( 'npx' , [ 'tsc' ] , {
184+ cwd : projectDir ,
185+ stdio : "inherit" ,
186+ } ) ;
188187
189- const mcpBuild = await execa ( 'npx' , [ 'mcp-build' ] , {
190- cwd : projectDir ,
191- stdio : "inherit" ,
192- env : {
193- ...process . env ,
194- MCP_SKIP_VALIDATION : "true"
188+ if ( tscBuild . exitCode !== 0 ) {
189+ throw new Error ( "Failed to build TypeScript" ) ;
195190 }
196- } ) ;
197191
198- if ( mcpBuild . exitCode !== 0 ) {
199- throw new Error ( "Failed to run mcp-build" ) ;
200- }
192+ const mcpBuild = await execa ( 'npx' , [ 'mcp-build' ] , {
193+ cwd : projectDir ,
194+ stdio : "inherit" ,
195+ env : {
196+ ...process . env ,
197+ MCP_SKIP_VALIDATION : "true"
198+ }
199+ } ) ;
200+
201+ if ( mcpBuild . exitCode !== 0 ) {
202+ throw new Error ( "Failed to run mcp-build" ) ;
203+ }
201204
202- console . log ( `
205+ console . log ( `
203206Project ${ projectName } created and built successfully!
204207
205208You can now:
2062091. cd ${ projectName }
2072102. Add more tools using:
208211 mcp add tool <n>
209212 ` ) ;
213+ } else {
214+ console . log ( `
215+ Project ${ projectName } created successfully (without dependencies)!
216+
217+ You can now:
218+ 1. cd ${ projectName }
219+ 2. Run 'npm install' to install dependencies
220+ 3. Run 'npm run build' to build the project
221+ 4. Add more tools using:
222+ mcp add tool <n>
223+ ` ) ;
224+ }
210225 } catch ( error ) {
211226 console . error ( "Error creating project:" , error ) ;
212227 process . exit ( 1 ) ;
0 commit comments