From 4d192414cafac814fba14a9d77ad58fd5d454680 Mon Sep 17 00:00:00 2001 From: Kushagra Agarwal Date: Sun, 8 Feb 2026 00:06:10 +0530 Subject: [PATCH] Make CLI more robust to project names --- packages/cli/src/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 9331aae..4c2b24b 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -99,6 +99,14 @@ Global Options: ` ); +// Helper to convert project-name to ProjectName for valid class names +function toPascalCase(str: string): string { + return str + .split(/[-_\s]+/) + .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) + .join(''); +} + program .command('create ') .description('Create a new LeanMCP project with Streamable HTTP transport') @@ -206,7 +214,8 @@ program await fs.writeFile(path.join(targetDir, 'main.ts'), mainTs); // Create an example service file - const exampleServiceTs = getExampleServiceTemplate(projectName); + const className = toPascalCase(projectName); + const exampleServiceTs = getExampleServiceTemplate(className); await fs.writeFile(path.join(targetDir, 'mcp', 'example', 'index.ts'), exampleServiceTs); const gitignore = gitignoreTemplate;