1. Conduid
  2. AI
  3. Mcpdemo
MCP server · AI

Mcpdemo

Model Context Protocol 的一个简单示例代码

Unclaimed last commit a year ago ai
43Fair

Scored 11 days ago · breakdown

About Mcpdemo

Mcpdemo is an MCP server published by pmhw in the AI category: model Context Protocol 的一个简单示例代码.

The repository has 2 stars and 0 forks, with the last commit a year ago. Six months or more without a commit doesn't mean the server is broken, but check the open issues before depending on it in production.

Install

From source
git clone https://github.com/pmhw/McpDemo

This server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.

Ask AI

✦

Ask AI about Mcpdemo

Powered by Claude · Grounded in docs

I know everything about Mcpdemo. Ask me about installation, configuration, usage, or troubleshooting.

Security checks

Static checks derived from the repository 4 days ago. Heuristics on the source, not an audit.

  • ✓README presentThe repository ships documentation.
  • !License declaredNo license file. Legally you have no right to use it in a product.
  • !Tests presentNo tests found. Behaviour changes may go unnoticed between versions.
  • !Dependencies pinnedNo lockfile. Installs can pull different code over time.
  • ✓No dynamic code executionSource scan found no eval, dynamic Function, or shell execution.
  • !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.

README

MCP 抽签工具演示

这是一个完整的 MCP (Model Context Protocol) 插件示例,实现了抽签、投骰子、抛硬币等随机功能。

功能特性

  • 🎲 抽签工具:从选项列表中随机抽取结果
  • 🎯 投骰子:支持自定义面数和数量
  • 🪙 抛硬币:简单的正面/反面随机选择

安装和运行

  1. 安装依赖:
npm install
  1. 启动 MCP 服务器:

方式一:标准输入输出模式(推荐用于 AI 客户端集成)

npm start

方式二:HTTP 服务器模式(支持 Web 界面和网络访问)

npm run start:http

启动后访问:

  • 🌐 Web 界面:http://localhost:3000
  • 📡 MCP 端点:http://localhost:3000/mcp
  • ❤️ 健康检查:http://localhost:3000/health

工具说明

1. draw_lottery - 抽签工具

从给定的选项列表中随机抽取一个或多个结果。

参数:

  • options (必需): 抽签选项列表
  • count (可选): 抽取数量,默认为1
  • allow_duplicate (可选): 是否允许重复抽取,默认为false

示例:

{
  "name": "draw_lottery",
  "arguments": {
    "options": ["苹果", "香蕉", "橙子", "葡萄"],
    "count": 2,
    "allow_duplicate": false
  }
}

2. roll_dice - 投骰子

投掷骰子,支持自定义面数和数量。

参数:

  • sides (可选): 骰子面数,默认为6
  • count (可选): 骰子数量,默认为1

示例:

{
  "name": "roll_dice",
  "arguments": {
    "sides": 20,
    "count": 3
  }
}

3. flip_coin - 抛硬币

抛硬币,返回正面或反面。

参数:

  • count (可选): 抛硬币次数,默认为1

示例:

{
  "name": "flip_coin",
  "arguments": {
    "count": 5
  }
}

演示 Prompt

以下是一些可以触发这些工具的示例 prompt:

基础抽签

帮我从这些水果中随机选一个:苹果、香蕉、橙子、葡萄、草莓

多人抽签

我们5个人要分这些奖品:一等奖、二等奖、三等奖、四等奖、五等奖。请帮我们随机分配,每个人一个奖品。

投骰子游戏

我想玩一个20面骰子的游戏,投3次,看看结果如何

抛硬币决定

帮我抛5次硬币,看看正反面各出现多少次

复杂抽签场景

我们班有30个同学,要选出5个代表参加活动。请帮我随机选择,不能重复。

项目结构

mcp-lottery-demo/
├── package.json          # 项目配置和依赖
├── README.md            # 项目说明文档
├── demo-prompts.md      # 演示 prompt 集合
├── test-client.js       # 标准输入输出测试客户端
├── test-http-client.js  # HTTP 测试客户端
├── demo.js             # 演示脚本
└── src/
    ├── server.js        # 标准输入输出 MCP 服务器
    └── server-http.js   # HTTP MCP 服务器

技术实现

  • 使用 @modelcontextprotocol/sdk 构建 MCP 服务器
  • 两种传输模式:
    • 标准输入输出传输协议(用于 AI 客户端集成)
    • HTTP/SSE 传输协议(支持 Web 界面和网络访问)
  • 实现了完整的工具注册和调用机制
  • 包含错误处理和参数验证
  • 提供 Web 界面和 RESTful API

扩展建议

你可以基于这个示例扩展更多功能:

  1. 添加更多随机工具:如随机数生成器、随机颜色选择等
  2. 持久化存储:保存抽签历史记录
  3. 用户偏好:记住用户的常用选项
  4. 统计分析:提供抽签结果的统计分析
  5. 可视化:生成图表展示结果分布

许可证

MIT License

README fetched from the repository 4 days ago. The original is authoritative.

Questions

About Mcpdemo

How do I install Mcpdemo?

No package has been published for this server, so install it from source: clone the repository and follow its README.

Is Mcpdemo safe to use with an AI agent?

Its trust score is 43 out of 100 (fair). It passes 2 of the 6 static security checks run so far; the failures are listed above. It has no ConduID identity yet, so agent calls to it are not receipted.

Is Mcpdemo still maintained?

The last commit was a year ago. That's long enough that you should check whether the maintainer is responding to issues before depending on it.