install_next_project
Create a Next.js project with TypeScript support, install dependencies, and open it in VSCode for immediate development.
Instructions
Create a new Next.js project and open it in VSCode
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectName | Yes | Name of the Next.js project | |
| destination | Yes | Directory where to create the project (e.g., ~/Desktop) | |
| typescript | No | Use TypeScript (default: true) | |
| installDependencies | No | Install dependencies after creating project (default: true) |
Implementation Reference
- src/index.ts:389-433 (handler)The handler function for the 'install_next_project' tool. It creates a new Next.js project using 'npx create-next-app' with options for TypeScript, Tailwind, App Router, no Git init, optional dependency installation skip, ensures directory, resolves paths, executes the command, and opens the project in VSCode.case "install_next_project": { const { projectName, destination, typescript = true, installDependencies = true } = args as { projectName: string; destination: string; typescript?: boolean; installDependencies?: boolean; }; const destPath = resolvePath(destination); await ensureDirectory(destPath); const tsFlag = typescript ? "--typescript" : "--javascript"; const skipInstallFlag = installDependencies ? "" : "--skip-install"; const command = `npx create-next-app@latest ${projectName} ${tsFlag} --tailwind --app --no-git ${skipInstallFlag}`; const { stdout, stderr } = await execa(command, { shell: true, cwd: destPath, }); const projectPath = path.join(destPath, projectName); // Open in VSCode await openInVSCode(projectPath); return { content: [ { type: "text", text: `Next.js project "${projectName}" created successfully at ${projectPath}\n\n` + `TypeScript: ${typescript ? "Yes" : "No"}\n` + `Dependencies: ${installDependencies ? "Installed" : "Not installed (run npm install manually)"}\n` + `VSCode: Opened\n\n` + `To start development:\n` + ` cd ${projectPath}\n` + ` ${installDependencies ? "" : "npm install\n "}npm run dev`, }, ], }; }
- src/index.ts:172-196 (registration)Registration of the 'install_next_project' tool in the list of available tools, including its name, description, and input schema definition.name: "install_next_project", description: "Create a new Next.js project and open it in VSCode", inputSchema: { type: "object", properties: { projectName: { type: "string", description: "Name of the Next.js project", }, destination: { type: "string", description: "Directory where to create the project (e.g., ~/Desktop)", }, typescript: { type: "boolean", description: "Use TypeScript (default: true)", }, installDependencies: { type: "boolean", description: "Install dependencies after creating project (default: true)", }, }, required: ["projectName", "destination"], }, },
- src/index.ts:172-196 (schema)Input schema for the 'install_next_project' tool, defining parameters like projectName (required), destination (required), typescript (boolean, default true), installDependencies (boolean, default true).name: "install_next_project", description: "Create a new Next.js project and open it in VSCode", inputSchema: { type: "object", properties: { projectName: { type: "string", description: "Name of the Next.js project", }, destination: { type: "string", description: "Directory where to create the project (e.g., ~/Desktop)", }, typescript: { type: "boolean", description: "Use TypeScript (default: true)", }, installDependencies: { type: "boolean", description: "Install dependencies after creating project (default: true)", }, }, required: ["projectName", "destination"], }, },
- src/index.ts:34-57 (helper)Helper function to open a project directory in VSCode, trying multiple possible 'code' command paths if the default fails.async function openInVSCode(projectPath: string): Promise<void> { try { await execa("code", [projectPath]); } catch (error) { // If 'code' command fails, try common VSCode executable paths const vscodePaths = [ "code", "/usr/local/bin/code", "/usr/bin/code", "C:\\Program Files\\Microsoft VS Code\\Code.exe", "C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe", ]; for (const codePath of vscodePaths) { try { await execa(codePath, [projectPath]); return; } catch { // Continue to next path } } throw new Error("VSCode not found. Please ensure VSCode is installed and 'code' command is available in PATH"); }
- src/index.ts:17-22 (helper)Helper function to ensure a directory exists, creating it recursively if necessary.async function ensureDirectory(dirPath: string): Promise<void> { try { await fs.mkdir(dirPath, { recursive: true }); } catch (error) { console.error(`Error creating directory ${dirPath}:`, error); }