Minecraft游戏技能库

一个用于控制Minecraft游戏内AI代理的客户端库,支持多机器人管理和30多种已验证技能。

  • by FundamentalLabs
  • TypeScript
  • 本地部署
  • 77 星标
  • 更新于
在 GitHub 查看 FundamentalLabs/minecraft-mcp

使用说明

基础实验室/Minecraft客户端

此库是Minecraft游戏技能和MCP集成的客户端库。

Fairies MCP客户端(https://fairies.ai/)还支持一键直接连接。

特性

  • 完全Minecraft控制:将AI代理连接到Minecraft服务器并控制机器人
  • 30验证技能:用于常见Minecraft任务的预构建、测试技能
  • 柔性连接:使用可选的每机器人配置连接到任何Minecraft服务器
  • 多机器人支持:同时管理多个机器人
  • MCP标准:兼容任何MCP客户端(克劳德桌面等)

安装

通过npx直接呼叫(推荐)

npx --y -- @fundamentallabs/minecraft-mcp

通过npm(推荐)

npm install -g @fundamentallabs/minecraft-mcp

来源

git clone https://github.com/FundamentalLabs/minecraft-mcp.git
cd minecraft-mcp/minecraft-client/mcp-server
npm install
npm run build

用法

启动服务器

您可以使用可选的默认连接设置启动MCP服务器:

# Start with no defaults (connection specified per bot)
minecraft-mcp

# Start with default connection settings
minecraft-mcp -h play.example.com -p 25565

命令行选项

Options:
  -p, --port <port>  Minecraft server port (default: 25565)
  -h, --host <host>  Minecraft server host (default: localhost)
  --help            Display help

与Claude Desktop或JSON配置本地集成

添加到您的Claude Desktop配置(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):

用于远程安装(推荐)

{
  "mcpServers": {
    "minecraft": {
      "command": "npx",
      "args": ["-y", "-- @fundamentallabs/minecraft-mcp"]
    }
  }
}

如果从源代码本地运行:

{
  "mcpServers": {
    "minecraft": {
      "command": "node",
      "args": ["/path/to/minecraft-mcp/minecraft-client/mcp-server/dist/mcp-server.js"]
    }
  }
}

替换 /path/to/minecraft-mcp 使用克隆存储库的实际路径。

与其他MCP客户端集成

服务器使用stdio传输,可以与任何MCP客户端集成:

# Using the MCP inspector for testing
cd minecraft-client/mcp-server
npx @modelcontextprotocol/inspector node dist/mcp-server.js -- -p 25565

可用技能

机器人管理

  • joinGame -在Minecraft游戏中生成一个新的机器人

    • username (必填):机器人的用户名
    • host (可选):服务器主机(默认为“localhost”或命令行选项)
    • port (可选):服务器端口(默认为25565或命令行选项)
  • 离开游戏 -断开机器人与游戏的连接

    • username (可选):要断开连接的特定机器人
    • disconnectAll (可选):如果为真,则断开所有机器人

移动与导航

  • goToSomeone -导航到其他玩家
  • goToKnownLocate -导航到特定坐标
  • 失控的 -逃离威胁
  • 游泳到陆地 -在水中游到最近的陆地

战斗与狩猎

  • 攻击某人 -攻击玩家、暴徒或动物
  • 狩猎 -猎杀动物或暴徒

资源采集

  • 矿产资源 -矿山特定区块或资源
  • 收割成熟作物 -从农田里收割成熟作物
  • 皮卡山 -从地上捡起物品

工艺与冶炼

  • 工艺品 -使用制作桌制作物品
  • 炊具 -在炉子里煮东西
  • smeltItem -在熔炉中熔炼物品
  • 从NearbyFurnace检索项目 -从熔炉中取出熔炼物

库存管理

  • openInventory -打开机器人的库存
  • 团队Item -装备盔甲、工具或武器
  • dropItem -从库存中删除项目
  • giveItemTo某人 -将物品交给其他玩家

建筑与农业

  • 将其放置在您附近 -在机器人附近放置块
  • 为农业准备土地 -准备耕地
  • useItemOnBlockOrEntity -在块或实体上使用项目

生存

  • eatFood -吃食物来恢复饥饿
  • 休息 -休息以恢复健康
  • 睡在附近的床上 -寻找并睡在床上

存储

  • openNearbyChest -打开附近的箱子

乐趣

  • 舞蹈 -让机器人跳舞

视觉

  • 环顾四周 -环顾四周,观察环境

沟通

  • readChat -从服务器读取最近的聊天消息
  • sendChat -向服务器发送聊天消息或命令

建筑

  • 构建某物 -使用Minecraft命令构建结构(需要作弊/操作员权限)。支持静态命令数组和动态JavaScript代码。
  • buildPixelArt -从Minecraft中的图像构建像素艺术(需要作弊/操作员权限)。使用彩色块将图像转换为像素艺术。最大大小为256x256个块。

API示例

当与MCP客户端集成时,您可以这样控制机器人:

// First, spawn a bot
await client.callTool('joinGame', { username: 'MyBot' });

// Make the bot mine some wood
await client.callTool('mineResource', { name: 'oak_log', count: 10 });

// Craft wooden planks
await client.callTool('craftItems', { item: 'oak_planks', count: 40 });

// Navigate to coordinates
await client.callTool('goToKnownLocation', { x: 100, y: 64, z: 200 });

// Build a structure using commands (requires cheats) - Script mode
await client.callTool('buildSomething', {
  buildScript: [
    { command: "fill", x1: 0, y1: 64, z1: 0, x2: 10, y2: 64, z2: 10, block: "stone" },
    { command: "fill", x1: 1, y1: 65, z1: 1, x2: 9, y2: 68, z2: 9, block: "oak_planks" },
    { command: "setblock", x: 5, y: 65, z: 1, block: "oak_door" }
  ]
});

// Build dynamically with JavaScript (requires cheats) - Code mode
await client.callTool('buildSomething', {
  code: `
    // Build a pyramid centered on the bot
    const size = 10;
    for (let y = 0; y < size; y++) {
      const level = size - y;
      fill(pos.x - level, pos.y + y, pos.z - level,
           pos.x + level, pos.y + y, pos.z + level, 'sandstone');
      await wait(5); // Small delay between levels
    }
    log('Pyramid complete!');
  `
});

// Build pixel art from an image (requires cheats)
await client.callTool('buildPixelArt', {
  imagePath: 'https://example.com/logo.png',
  width: 64,
  height: 64,
  x: 0,
  y: 80,
  z: 100,
  facing: 'north'
});

// Read recent chat messages
await client.callTool('readChat', {
  count: 30,
  timeLimit: 300,  // Last 5 minutes
  filterType: 'chat'  // Only player messages
});

// Send a chat message
await client.callTool('sendChat', {
  message: 'Hello everyone! I am a bot.'
});

// Send a command
await client.callTool('sendChat', {
  message: '/time set day'
});

// Send a whisper
await client.callTool('sendChat', {
  message: '/msg Steve I can help you build!',
  delay: 1000  // Wait 1 second before sending
});

建筑

MCP服务器:

  • 使用stdio传输与AI客户端通信
  • 从已验证的技能目录动态加载技能
  • 管理多个机器人实例(目前所有操作都使用第一个机器人)
  • 为所有机器人操作提供统一的界面

需求

  • Node.js>=18.0.0
  • 要连接的Minecraft服务器(Java版)
  • MCP兼容客户端(如Claude Desktop)

故障排除

“未找到技能实现”错误

MCP服务器需要使用内置技能从克隆的存储库运行。确保您:

  1. 已克隆完整存储库
  2. 跑 npm install 在minecraft客户端目录中
  3. 跑 npm run build 在minecraft客户端目录中
  4. 正在从正确的目录运行MCP服务器

Bot无法连接

  • 确保您的Minecraft服务器正在运行且可访问
  • 检查端口和主机是否正确
  • 验证服务器是否允许机器人使用Minecraft版本

技能不起作用

  • 在使用技能之前,确保机器人已经成功生成
  • 有些技能需要特定的项目或条件
  • 检查机器人的控制台输出是否有错误消息

贡献

欢迎投稿!请随时提交拉取请求。

许可证

MIT-有关详细信息,请参阅LICENSE文件

支持

有关问题和功能请求,请使用 GitHub问题跟踪器.

测试

使用Anthropic MPC检查员进行测试

'npx@modelcontextprotocol/检查器节点。/dist/mcp服务器.js