A Node.js and TypeScript server project that provides a simple starter example with Express.js web server, supporting hot-reload, testing, and modular structure.
基于 Model Context Protocol (MCP) 开发的服务集合,用于支持 Cursor IDE 的智能功能。目前包含示例服务和天气服务。
mcp-servers/
├── src/ # 源代码目录
│ ├── demo/ # 示例服务
│ │ ├── config/ # 配置层:常量、类型定义
│ │ │ ├── constants.ts # 常量定义
│ │ │ └── types.ts # 类型定义
│ │ ├── controllers/ # 控制器层:请求处理
│ │ │ └── GreetingController.ts # 问候控制器
│ │ ├── service/ # 服务层:业务逻辑
│ │ │ └── GreetingService.ts # 问候服务
│ │ ├── package.json # 服务配置文件
│ │ ├── tsconfig.json # TypeScript 配置
│ │ └── index.ts # 服务入口文件
│ │
│ └── weather/ # 天气服务
│ ├── config/ # 配置层:常量、类型定义
│ │ ├── constants.ts # 常量定义
│ │ └── types.ts # 类型定义
│ ├── controllers/ # 控制器层:请求处理
│ │ └── WeatherController.ts # 天气控制器
│ ├── service/ # 服务层:业务逻辑
│ │ └── WeatherService.ts # 天气服务
│ ├── package.json # 服务配置文件
│ ├── tsconfig.json # TypeScript 配置
│ └── index.ts # 服务入口文件
│
├── build/ # 编译输出目录
├── node_modules/ # 依赖包
├── package.json # 项目配置
├── tsconfig.json # TypeScript 配置
└── README.md # 项目文档
项目采用三层架构设计,每个服务都遵循相同的结构模式:
位置:服务目录/config/
constants.ts
: 常量定义types.ts
: 类型定义位置:服务目录/controllers/
XXXController.ts
: 具体业务控制器位置:服务目录/service/
XXXService.ts
: 具体业务服务位置:服务目录/index.ts
新建服务
mkdir -p src/new-service/{config,controllers,service}
实现各层功能
创建配置文件
package.json
: 服务依赖和脚本tsconfig.json
: TypeScript 配置编写入口文件
index.ts
git clone cd mcp-servers
npm install
# 构建所有服务 npm run build # 构建单个服务 npm run build:weather # 构建天气服务 npm run build:demo # 构建示例服务
编辑 ~/.cursor/mcp.json
文件:
{ "mcpServers": { "weather": { "command": "node", "args": [ "/your/path/to/mcp-servers/build/weather/index.js" ], "env": { "OPENWEATHER_API_KEY": "your_api_key_here" } } } }
# 启动天气服务 npm run start:weather # 启动示例服务 npm run start:demo
src/demo/
src/weather/
查看各服务详细文档:
src
目录下创建新服务目录package.json
添加相应的构建和启动脚本console.error()
输出调试信息# 运行所有测试 npm test # 运行特定服务的测试 npm run test:weather
服务无法启动
API 调用失败
Cursor IDE 无法识别服务
MIT License
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!