@@ -5,10 +5,11 @@ 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 , install ?: boolean } ) {
8+ export async function createProject ( name ?: string , options ?: { http ?: boolean , cors ?: boolean , port ?: number , install ?: boolean , example ?: boolean } ) {
99 let projectName : string ;
10- // Default install to true if not specified
10+ // Default install and example to true if not specified
1111 const shouldInstall = options ?. install !== false ;
12+ const shouldCreateExample = options ?. example !== false ;
1213
1314 if ( ! name ) {
1415 const response = await prompts ( [
@@ -147,14 +148,21 @@ class ExampleTool extends MCPTool<ExampleInput> {
147148
148149export default ExampleTool;` ;
149150
150- console . log ( "Creating project files..." ) ;
151- await Promise . all ( [
151+ // Prepare the files to write
152+ const filesToWrite = [
152153 writeFile ( join ( projectDir , "package.json" ) , JSON . stringify ( packageJson , null , 2 ) ) ,
153154 writeFile ( join ( projectDir , "tsconfig.json" ) , JSON . stringify ( tsconfig , null , 2 ) ) ,
154155 writeFile ( join ( projectDir , "README.md" ) , generateReadme ( projectName ) ) ,
155156 writeFile ( join ( srcDir , "index.ts" ) , indexTs ) ,
156- writeFile ( join ( toolsDir , "ExampleTool.ts" ) , exampleToolTs ) ,
157- ] ) ;
157+ ] ;
158+
159+ // Conditionally add the example tool
160+ if ( shouldCreateExample ) {
161+ filesToWrite . push ( writeFile ( join ( toolsDir , "ExampleTool.ts" ) , exampleToolTs ) ) ;
162+ }
163+
164+ console . log ( "Creating project files..." ) ;
165+ await Promise . all ( filesToWrite ) ;
158166
159167 process . chdir ( projectDir ) ;
160168
0 commit comments