返回市场
MCP-骰子

MCP-骰子

作者:yamaton4 星标更新:2025-01-02

项目介绍

mcp-dice: 用于掷骰子的MCP服务器

smithery徽章 截图

这是一个模型上下文协议(MCP)服务器,使大型语言模型(LLMs)能够掷骰子。它接受标准骰子记法(例如,1d20),并返回单个掷骰结果及其总和。

<a href="https://glama.ai/mcp/servers/vzu553gv26"><img width="380" height="200" src="https://gips2.baidu.com/it/u=3094342136,391447755&fm=3081&app=3081&f=PNG?w=760&h=400" /></a>

功能

  • 支持标准骰子记法(例如,1d203d62d8+1
  • 返回单个掷骰结果及总和
  • 与Claude Desktop轻松集成
  • 兼容MCP Inspector进行调试

安装

通过Smithery安装

要通过Smithery自动安装Dice Roller for Claude Desktop:

npx @smithery/cli install mcp-dice --client claude

确保uv可用:https://docs.astral.sh/uv/getting-started/installation/

使用方法

基本命令行用法

# 使用uvx
uvx mcp-dice

输入格式

服务器接受一个带有notation字段的JSON对象:

{
  "notation": "2d6+3"
}

示例响应:

{
  "rolls": [
    3,
    1
  ],
  "sum": 4,
  "modifier": 3,
  "total": 7,
  "notation": "2d6+3",
  "timestamp": "2024-12-03T16:36:38.926452"
}

Claude Desktop配置

位置

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%/Claude/claude_desktop_config.json

示例

<details> <summary>macOS配置</summary>
{
  "mcpServers": {
    "dice": {
      "command": "uvx",
      "args": ["mcp-dice"]
    }
  }
}
</details> <details> <summary>WSL配置</summary>
{
  "mcpServers": {
    "dice": {
      "command": "wsl",
      "args": [
        "-e",
        "zsh",
        "-lc",
        "uvx mcp-dice"
      ]
    }
  }
}

注意:将zsh替换为您登录时使用的shell。

</details>

开发与调试

安装开发依赖

# 克隆仓库
git clone https://github.com/yourusername/mcp-dice
cd mcp-dice

# 安装开发依赖
uv pip install -e ".[dev]"

运行测试

uv run pytest

使用MCP Inspector

MCP Inspector是一个有用的调试工具。使用npm安装并运行它:

npx @modelcontextprotocol/inspector uvx mcp-dice

开发环境下的Claude Desktop配置

<details> <summary>macOS配置(本地开发)</summary>
{
  "mcpServers": {
    "dice": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "path/to/mcp-dice-repo",
        "mcp-dice"
      ]
    }
  }
}

注意:将path/to/mcp-dice-repo替换为您的文件系统上的仓库路径。

</details> <details> <summary>Windows(WSL)配置(本地开发)</summary>
{
  "mcpServers": {
    "dice": {
      "command": "wsl",
      "args": [
        "-e",
        "zsh",
        "-lc",
        "uv run --directory path/to/mcp-dice-repo mcp-dice"
      ]
    }
  }
}

注意:将zsh替换为您登录时使用的shell。同时,将path/to/mcp-dice-repo替换为您的WSL文件系统上的仓库路径。

</details>