Minecraft MCPサーバー
Minecraftサーバー管理をRCON経由で行います。簡単なコマンド実行のためにFastMCPを統合し、Claude Desktopや他のMCPクライアントとのインタラクションをサポートし、ローカル開発および本番環境での柔軟なアーキテクチャを提供します。
概要
Minecraft-MCP-Server
RCONを介してMinecraftサーバーを制御するために設計されたPython MCPサーバーで、FastMCPを利用してシームレスな統合とコマンド実行を実現します。
🔧 機能
- コマンド辞書: Minecraftサーバーとのインタラクションを強化するための包括的なコマンドセットを提供します。
- RCON実行: RCONを使用してMinecraftサーバー上でコマンドを直接実行し、リアルタイムで制御します。
- クライアント統合: Claude Desktopまたは任意のMCPクライアントと互換性があり、簡単に管理できます。
- 柔軟な構造:
stdio
を介したローカル開発とHTTP/SSEを介した本番環境の両方をサポートします。
📦 プロジェクト構造
mcp_server/
├── commands.json # 使用例を含むコマンドの内容
├── server.py # MCPのメインサーバースクリプト
├── commands.json # 文脈理解のためのMinecraftコマンド
└── (venv/) # 依存関係のためのオプションの仮想環境
⚙️ インストール
-
リポジトリをクローンします:
cd Minecraft-MCP-Server/mcp_server
-
環境を設定し、依存関係をインストールします:
python -m venv venv venv\Scripts\activate pip install mcp[cli] mcrcon
📝 セットアップ
commands.json
ファイルには、/give
、/weather
、/gamemode
などのさまざまなコマンドが含まれており、説明と使用例が付いています。
Minecraftのserver.properties
ファイルでRCONが有効になっていることを確認してください:
enable-rcon=true
rcon.password=minemcp
rcon.port=25575
🚀 サーバーの実行
サーバーを起動するには、仮想環境をアクティブにし、次のコマンドを実行します:
venv\Scripts\activate
python server.py
デフォルトでは、MCPサーバーはSTDIOモードで起動します。
⚙️ Claude Desktopとの統合
Claude Desktopと統合するには、claude_desktop_config.json
ファイルを変更します(%APPDATA%\Claude\
にあります):
{
"mcpServers": {
"minecraft-controller": {
"type": "stdio",
"command": "C:\\...\\venv\\Scripts\\python.exe",
"args": ["C:\\...\\mcp_server\\server.py"],
"env": {"PATH": "%PATH%"}
}
}
}
Claudeを再起動して、‘minecraft-controller’サーバーがリストに表示されることを確認してください。
🧪 Pythonによるローカルテスト
次のPythonスクリプトを使用して、サーバーをローカルでテストできます:
from fastmcp import Client
import asyncio
async def test():
client = Client("mcp_server/server.py")
async with client:
res = await client.call_tool("run_minecraft_command", {"command": "/list"})
print("プレイヤー:", res)
cmds = await client.read_resource("minecraft://commands")
print("コマンド:", list(cmds.keys())[:5])
asyncio.run(test())
🧰 仕組み
- FastMCP機能: 効率的なコマンド処理のためにツールとリソースを自動的にロードします。
- コマンドリソース: リソース
minecraft://commands
は、利用可能なコマンドの辞書を提供します。 - コマンド実行: ツール
run_minecraft_command
は、mcrcon
を利用してMinecraftサーバーにコマンドを送信します。
📚 参考文献
🛠 次のステップ
- Dockerを使用してHTTP/SSEトランスポートのサポートを実装します。
- コマンド辞書を介して引数の検証とオートコンプリート機能を強化します。
/start
、/stop
、/backup
、/whitelist
などの追加アクションのログを追加します。
Minecraftサーバーの体験を向上させる準備をしましょう! 🚀
詳細
Minecraft-MCP-Server
Python MCP Server to control a Minecraft server via RCON, using FastMCP.
🔧 Features
- Exposes a set of commands (dictionary) to contextualize the LLM
- Executes commands on the Minecraft server via RCON
- Integration with Claude Desktop or any MCP client
- Simple structure:
stdio
(local development) or HTTP/SSE (production)
📦 Project Structure
mcp_server/
├── commands.json # Commands dictionary and examples
├── server.py # Main MCP server
├── commands.json # Minecraft commands for context
└── (venv/) # Virtual environment (optional)
⚙️ Installation
-
Clone the repository:
cd Minecraft-MCP-Server/mcp_server
-
Create an environment and install dependencies:
python -m venv venv venv\Scripts\activate pip install mcp[cli] mcrcon
📝 Setup
In the commands.json
file, you will have a list of commands like /give
, /weather
, /gamemode
, etc., with descriptions and examples.
Don’t forget to enable RCON in the Minecraft server.properties
file:
enable-rcon=true
rcon.password=minemcp
rcon.port=25575
🚀 Running
Activate the virtual environment and run:
venv\Scripts\activate
python server.py
Monkey patch: starts MCP server in STDIO by default (apidog.com, reddit.com, github.com)
⚙️ Integration with Claude Desktop
In claude_desktop_config.json
(e.g., %APPDATA%\Claude\
):
{
"mcpServers": {
"minecraft-controller": {
"type": "stdio",
"command": "C:\\...\\venv\\Scripts\\python.exe",
"args": ["C:\\...\\mcp_server\\server.py"],
"env": {"PATH": "%PATH%"}
}
}
}
Then restart Claude — the ‘minecraft-controller’ server will appear.
🧪 Local Test with Python
from fastmcp import Client
import asyncio
async def test():
client = Client("mcp_server/server.py")
async with client:
res = await client.call_tool("run_minecraft_command", {"command": "/list"})
print("Players:", res)
cmds = await client.read_resource("minecraft://commands")
print("Commands:", list(cmds.keys())[:5])
asyncio.run(test())
🧰 How It Works
- 🎯
FastMCP
automatically loads tools and resources (medium.com, github.com) - Resource
minecraft://commands
provides the commands dictionary - Tool
run_minecraft_command
usesmcrcon
to send commands to Minecraft
📚 References
🛠 Next Steps
- Support for HTTP/SSE transport with Docker
- Argument validation/autocomplete via commands dictionary
- Logging extra actions:
/start
,/stop
,/backup
,/whitelist
Ready to make your server smart! 🚀
サーバー設定
{
"mcpServers": {
"minecraft-controller": {
"type": "stdio",
"command": "C:\\...\\venv\\Scripts\\python.exe",
"args": [
"C:\\...\\mcp_server\\server.py"
],
"env": {
"PATH": "%PATH%"
}
}
}
}