问答工具服务器模板

基于Bun运行时的AI工具开发模板,专注于提供多类别和难度级别的问答功能。

  • by tkc
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 tkc/mcp-server-template

使用说明

MCP服务器模板

用于构建具有Bun运行时的AI工具的MCP入门套件

环境要求

  • 包子:v1.0.0或更高版本
  • Node.js:v18.0.0或更高版本(对于某些依赖项)
  • 操作系统:
    • macOS 12+
    • 使用glibc 2.31的Linux+
    • Windows 10+(通过WSL)

特性

  • 专注于知识问答的MCP服务器实现
  • 具有多个类别和难度级别的测验工具
  • Jest测试设置与MCP集成测试
  • 全面的测试覆盖率

安装

# Clone the repository
git clone https://github.com/username/quiz-mcp-template.git
cd quiz-mcp-template

# Install dependencies
bun install

Claude桌面设置

{
  "quiz": {
    "command": "<your path>/.bun/bin/bun",
    "args": ["run", "<your path>/bun-mcp-template/src/index.ts"]
  }
}

用法

运行服务器

# Start the server
bun start

# Development mode (with auto-restart)
bun dev

测试

# Run all tests
bun test

MCP工具

此服务器提供了一个交互式测验工具:

get_quiz:提供不同类别和难度级别的测验问题

{
  "method": "tools/call",
  "params": {
    "name": "get_quiz",
    "arguments": {
      "category": "science",
      "difficulty": "medium"
    }
  },
  "jsonrpc": "2.0",
  "id": 1
}

可用类别:

  • 通用
  • 科学
  • 历史
  • 地理学
  • 娱乐

难度级别:

  • 容易
  • 中等
  • 硬的

项目结构

quiz-mcp-template/
├── src/
│   └── index.ts       # Main Quiz MCP server implementation
├── tests/
│   └── cli-mcp.test.ts # MCP integration tests
├── package.json
├── tsconfig.json
└── README.md

发展

扩展测验类别

要添加新的测验类别或问题,请修改 quizQuestions 对象在 src/index.ts:

// Add new category
quizQuestions.newCategory = {
  easy: [
    { question: "Easy question 1?", answer: "Answer 1" },
    { question: "Easy question 2?", answer: "Answer 2" },
    // Add more questions...
  ],
  medium: [
    { question: "Medium question 1?", answer: "Answer 1" },
    { question: "Medium question 2?", answer: "Answer 2" },
    // Add more questions...
  ],
  hard: [
    { question: "Hard question 1?", answer: "Answer 1" },
    { question: "Hard question 2?", answer: "Answer 2" },
    // Add more questions...
  ],
};

// Don't forget to update the schema to include the new category
const QuizSchema = z.object({
  category: z
    .enum([
      "general",
      "science",
      "history",
      "geography",
      "entertainment",
      "newCategory",
    ])
    .optional()
    .describe("The category of questions to ask"),
  // ...
});

许可证

麻省理工学院

致谢

该项目使用Anthropic开发的模型上下文协议(MCP),并为人工智能助手提供了一个教育测验工具。