这是一个用于Minecraft游戏技能和MCP集成的客户端库。
Fairies MCP客户端(https://fairies.ai/)也支持单击直接连接。
npx --y -- @fundamentallabs/minecraft-mcp
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服务器:
# 不使用默认设置(每个机器人指定连接)
minecraft-mcp
# 使用默认连接设置
minecraft-mcp -h play.example.com -p 25565
选项:
-p, --port <port> Minecraft服务器端口(默认:25565)
-h, --host <host> Minecraft服务器主机(默认:localhost)
--help 显示帮助
添加到你的Claude Desktop配置中(在macOS上是~/Library/Application Support/Claude/claude_desktop_config.json):
对于远程安装(推荐)
{
"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替换为你克隆仓库的实际路径。
服务器使用stdio传输,并可以与任何MCP客户端集成:
# 使用MCP检查器进行测试
cd minecraft-client/mcp-server
npx @modelcontextprotocol/inspector node dist/mcp-server.js -- -p 25565
joinGame - 在Minecraft游戏中生成一个新的机器人
username(必需):机器人的用户名host(可选):服务器主机(默认为'localhost'或命令行选项)port(可选):服务器端口(默认为25565或命令行选项)leaveGame - 断开机器人与游戏的连接
username(可选):特定要断开的机器人disconnectAll(可选):如果为真,则断开所有机器人当与MCP客户端集成时,你可以这样控制机器人:
// 首先,生成一个机器人
await client.callTool('joinGame', { username: 'MyBot' });
// 让机器人开采一些木材
await client.callTool('mineResource', { name: 'oak_log', count: 1 0});
// 制作木板
await client.callTool('craftItems', { item: 'oak_planks', count: 40 });
// 导航到坐标
await client.callTool('goToKnownLocation', { x: 100, y: 64, z: 200 });
// 使用命令建造结构(需要作弊) - 脚本模式
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" }
]
});
// 使用JavaScript动态建造(需要作弊) - 代码模式
await client.callTool('buildSomething', {
code: `
// 在机器人中心建造金字塔
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); // 层级之间的小延迟
}
log('金字塔完成!');
`
});
// 根据图像建造像素艺术(需要作弊)
await client.callTool('buildPixelArt', {
imagePath: 'https://example.com/logo.png',
width: 64,
height: 64,
x: 0,
y: 80,
z: 100,
facing: 'north'
});
// 读取最新的聊天消息
await client.callTool('readChat', {
count: 30,
timeLimit: 300, // 最近5分钟
filterType: 'chat' // 只有玩家的消息
});
// 发送一条聊天消息
await client.callTool('sendChat', {
message: '大家好!我是机器人。'
});
// 发送一个命令
await client.callTool('sendChat', {
message: '/time set day'
});
// 发送一个私信
await client.callTool('sendChat', {
message: '/msg Steve 我可以帮助你建造!',
delay: 1000 // 发送前等待1秒
});
MCP服务器:
MCP服务器需要从克隆的仓库中带有已构建技能运行。确保你:
npm installnpm run build欢迎贡献!请随时提交Pull Request。
MIT - 详情见LICENSE文件
对于问题和功能请求,请使用GitHub问题跟踪器。
要使用Anthropic MPC检查器进行测试
'npx @modelcontextprotocol/inspector node ./dist/mcp-server.js'