MCP 服务器模板:AI 工具开发
使用 Bun 运行时构建 AI 工具的 MCP 启动套件,专注于交互式测验。
快速入门
环境要求
- Bun: v1.0.0 或更高版本(安装指南:https://bun.sh/docs/installation)
- Node.js: v18.0.0 或更高版本
- 操作系统:macOS 12+ / Linux (glibc 2.31+) / Windows 10+ (WSL)
安装步骤
- 克隆仓库:
git clone https://github.com/username/quiz-mcp-template.git
- 进入目录:
cd quiz-mcp-template
- 安装依赖:
bun install
启动服务
- 启动服务器:
bun start
- 开发模式(自动重启):
bun dev
使用方法
- 获取测验问题:通过
get_quiz
方法指定类别和难度。 - 示例请求: { "method": "tools/call", "params": { "name": "get_quiz", "arguments": { "category": "science", "difficulty": "medium" } }, "jsonrpc": "2.0", "id": 1 }
支持的类别:general, science, history, geography, entertainment 支持的难度:easy, medium, hard
测试
运行测试:bun test