MCP服务器脚手架工具

一个用于快速生成集成Web功能的Model Context Protocol (MCP)服务器项目的CLI工具,提供完整的项目结构和可配置选项。

  • by bsmi021
  • TypeScript
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 bsmi021/create-advanced-mcp-server

使用说明

创建mcp服务器

一种CLI工具,用于构建具有集成web功能的模型上下文协议(MCP)服务器。

此包按照MCP高级节点规范中记录的架构创建了一个完全结构化的MCP服务器项目,为MCP服务器开发提供了坚实的基础。

特性

  • 生成完整的MCP服务器项目结构
  • web API、WebSocket和数据库集成的可配置选项
  • 基于TypeScript的现代ES模块
  • 包括Prisma ORM集成(可选)
  • 基于表达式的web API(可选)
  • WebSocket服务器集成(可选)
  • 工具、资源和提示的示例实现
  • 完整的错误处理和日志记录基础设施
  • 支持环境变量的配置系统

安装

npm install -g create-advanced-mcp-server

用法

# Create a new project with interactive prompts
npx create-advanced-mcp-server my-mcp-server

# Create a new project with default options
npx create-advanced-mcp-server my-mcp-server --yes

# Skip dependency installation
npx create-advanced-mcp-server my-mcp-server --skip-install

# Show verbose output
npx create-advanced-mcp-server my-mcp-server --verbose

生成的项目结构

生成的项目遵循MCP高级节点规范中概述的结构:

src/
├── index.ts                  # Entry point
├── initialize.ts             # Initialization logic
├── config.ts                 # Configuration management
├── types.ts                  # Type definitions
├── utils/                    # Utility modules
│   ├── index.ts              # Utility exports
│   ├── logging.ts            # Logging utilities
│   ├── errors.ts             # Error classes
│   └── ...                   # Additional utilities
├── tools/                    # Individual tool implementations
│   ├── index.ts              # Tool registration
│   ├── exampleTool.ts        # Example tool implementation
│   └── ...                   # Additional tools
├── resources/                # Resource implementations
│   ├── index.ts              # Resource registration  
│   ├── exampleResource.ts    # Example resource implementation
│   └── ...                   # Additional resources
├── prompts/                  # Prompt implementations
│   ├── index.ts              # Prompt registration
│   ├── examplePrompt.ts      # Example prompt implementation
│   └── ...                   # Additional prompts
├── services/                 # Service layer
│   ├── index.ts              # Service exports
│   ├── exampleService.ts     # Example service implementation
│   └── ...                   # Additional services

根据您的选择,可能会包括其他目录:

Web API(如果启用)

├── web/                      # Web API components
│   ├── index.ts              # Web server setup
│   ├── middleware/           # Express middleware
│   │   ├── index.ts          # Middleware exports
│   │   ├── errorHandler.ts   # Error handling middleware
│   │   └── ...               # Additional middleware
│   ├── routes/               # API routes
│   │   ├── index.ts          # Route registration
│   │   ├── exampleRoutes.ts  # Example route definitions
│   │   └── ...               # Additional routes
│   └── controllers/          # API controllers
│       ├── index.ts          # Controller exports
│       ├── exampleController.ts # Example controller logic
│       └── ...               # Additional controllers

WebSocket(如果启用)

├── websocket/                # WebSocket components
│   ├── index.ts              # WebSocket server setup
│   ├── events/               # Event definitions
│   │   ├── index.ts          # Event exports
│   │   ├── exampleEvents.ts  # Example event handlers
│   │   └── ...               # Additional events
│   └── ...                   # Additional WebSocket components

Prisma(如果启用)

├── data/                     # Data access layer
│   ├── index.ts              # Data layer exports
│   ├── client.ts             # Prisma client initialization
│   ├── database.ts           # Database management (migrations)
│   ├── repositories/         # Repository implementations
│   │   ├── index.ts          # Repository exports
│   │   ├── baseRepository.ts # Base repository pattern
│   │   └── ...               # Additional repositories
│   └── ...                   # Additional data components
├── prisma/                   # Prisma configuration
│   ├── schema.prisma         # Database schema definition

许可证

麻省理工学院