Skip to main content
Glama
bsmi021

Node Omnibus MCP Server

by bsmi021

create_project

Create a new Node.js project with enhanced configuration for React, Node, Next, Express, or Fastify applications, including TypeScript support.

Instructions

Create a new Node.js project with enhanced configuration

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesProject name
typeYesProject type
pathYesProject directory path
typescriptNoEnable TypeScript support

Implementation Reference

  • The handler function that implements the core logic of the 'create_project' tool. It creates the project directory, initializes the project using appropriate templates (create-react-app, create-next-app, etc.), installs dependencies and devDependencies, sets up TypeScript configuration if requested, generates a README.md, and stores documentation in memory.
    private async handleCreateProject(args: CreateProjectArgs) { try { // Create the project directory first const projectPath = path.join(args.path, args.name); await fs.mkdir(projectPath, { recursive: true }); const typescript = args.typescript !== false; const template = this.getProjectTemplate(args.type, args.name, typescript); // Execute project creation command in the project directory const { stdout: createOutput } = await execAsync(template.command, { cwd: projectPath }); // Install dependencies directly in the project directory if (template.dependencies.length > 0) { const installCmd = `npm install ${template.dependencies.join(' ')}`; await execAsync(installCmd, { cwd: projectPath }); } // Install dev dependencies if (template.devDependencies.length > 0) { const installDevCmd = `npm install --save-dev ${template.devDependencies.join(' ')}`; await execAsync(installDevCmd, { cwd: projectPath }); } // Setup TypeScript configuration if needed if (typescript) { const tsConfig = { compilerOptions: { target: "es2020", module: "commonjs", outDir: "./dist", rootDir: "./src", strict: true, esModuleInterop: true, skipLibCheck: true, forceConsistentCasingInFileNames: true, jsx: args.type === 'react' || args.type === 'next' ? "react-jsx" : undefined, }, include: ["src/**/*"], exclude: ["node_modules", "dist"] }; await fs.mkdir(path.join(projectPath, 'src'), { recursive: true }); await fs.writeFile( path.join(projectPath, 'tsconfig.json'), JSON.stringify(tsConfig, null, 2) ); } // Create initial documentation const readmeContent = this.generateReadme(args.name, args.type, typescript); await fs.writeFile( path.join(projectPath, 'README.md'), readmeContent ); // Store documentation in memory this.projectDocs.set(args.name, readmeContent); return { content: [ { type: 'text', text: `Project ${args.name} created successfully with ${typescript ? 'TypeScript' : 'JavaScript'} configuration`, }, ], }; } catch (error: unknown) { throw new McpError( ErrorCode.InternalError, `Failed to create project: ${error instanceof Error ? error.message : String(error)}` ); } }
  • JSON schema definition for the 'create_project' tool inputs, registered in the ListToolsRequestSchema handler. Defines properties, types, enum for project type, descriptions, and required fields.
    name: 'create_project', description: 'Create a new Node.js project with enhanced configuration', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Project name', }, type: { type: 'string', enum: ['react', 'node', 'next', 'express', 'fastify'], description: 'Project type', }, path: { type: 'string', description: 'Project directory path', }, typescript: { type: 'boolean', description: 'Enable TypeScript support', default: true, }, }, required: ['name', 'type', 'path'], }, },
  • src/index.ts:394-396 (registration)
    Registration and dispatch logic in the CallToolRequestSchema handler. The switch statement routes calls to 'create_project' to the handleCreateProject method.
    switch (request.params.name) { case 'create_project': return await this.handleCreateProject(args as CreateProjectArgs);
  • TypeScript interface defining the shape of arguments expected by the create_project handler, used for type safety.
    interface CreateProjectArgs extends Record<string, unknown> { name: string; type: 'react' | 'node' | 'next' | 'express' | 'fastify'; path: string; typescript?: boolean; }
  • Helper function that provides project creation templates, including commands and dependency lists for different project types (react, next, express, etc.), used by the handler.
    private getProjectTemplate(type: string, name: string, typescript: boolean): { command: string; dependencies: string[]; devDependencies: string[]; } { const templates: Record<string, { command: string; dependencies: string[]; devDependencies: string[]; }> = { react: { command: typescript ? `npx create-react-app ./ --template typescript` : `npx create-react-app ./`, dependencies: ['react', 'react-dom'], devDependencies: typescript ? ['@types/react', '@types/react-dom', '@types/node'] : [], }, next: { command: `npx create-next-app@latest ./ ${typescript ? '--typescript' : ''} --tailwind --eslint`, dependencies: ['next', 'react', 'react-dom'], devDependencies: typescript ? ['@types/node', '@types/react', '@types/react-dom'] : [], }, express: { command: `npm init -y`, dependencies: ['express', 'cors', 'dotenv'], devDependencies: typescript ? ['typescript', '@types/node', '@types/express', '@types/cors', 'ts-node', 'nodemon'] : ['nodemon'], }, fastify: { command: `npm init -y`, dependencies: ['fastify', '@fastify/cors', '@fastify/env'], devDependencies: typescript ? ['typescript', '@types/node', 'ts-node', 'nodemon'] : ['nodemon'], }, node: { command: `npm init -y`, dependencies: [], devDependencies: typescript ? ['typescript', '@types/node', 'ts-node', 'nodemon'] : ['nodemon'], }, }; const template = templates[type]; if (!template) { throw new McpError(ErrorCode.InvalidParams, `Unsupported project type: ${type}`); } return template; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bsmi021/mcp-node-omnibus-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server