Minecraft MCP Server
Gestione del server Minecraft tramite RCON. Integra FastMCP per un'esecuzione facile dei comandi, supporta l'interazione con Claude Desktop e altri client MCP, e offre un'architettura flessibile per lo sviluppo locale e l'uso in produzione.
Panoramica
Minecraft-MCP-Server
Un server MCP in Python progettato per controllare un server Minecraft tramite RCON, utilizzando FastMCP per un'integrazione e un'esecuzione dei comandi senza soluzione di continuità.
🔧 Caratteristiche
- Dizionario dei Comandi: Fornisce un insieme completo di comandi per migliorare l'interazione con il server Minecraft.
- Esecuzione RCON: Esegue comandi direttamente sul server Minecraft utilizzando RCON per un controllo in tempo reale.
- Integrazione Client: Compatibile con Claude Desktop o qualsiasi client MCP per una gestione facile.
- Struttura Flessibile: Supporta sia lo sviluppo locale tramite
stdio
che ambienti di produzione tramite HTTP/SSE.
📦 Struttura del Progetto
mcp_server/
├── commands.json # Contiene comandi ed esempi per l'uso
├── server.py # Lo script principale del server per MCP
├── commands.json # Comandi di Minecraft per una comprensione contestuale
└── (venv/) # Ambiente virtuale opzionale per le dipendenze
⚙️ Installazione
-
Clona il Repository:
cd Minecraft-MCP-Server/mcp_server
-
Imposta l'Ambiente e Installa le Dipendenze:
python -m venv venv venv\Scripts\activate pip install mcp[cli] mcrcon
📝 Configurazione
Nel file commands.json
, troverai una varietà di comandi come /give
, /weather
e /gamemode
, completi di descrizioni ed esempi di utilizzo.
Assicurati che RCON sia abilitato nel tuo file server.properties
di Minecraft:
enable-rcon=true
rcon.password=minemcp
rcon.port=25575
🚀 Esecuzione del Server
Per avviare il server, attiva l'ambiente virtuale ed esegui:
venv\Scripts\activate
python server.py
Per impostazione predefinita, il server MCP si avvia in modalità STDIO.
⚙️ Integrazione con Claude Desktop
Per integrare con Claude Desktop, modifica il file claude_desktop_config.json
(situato in %APPDATA%\Claude\
):
{
"mcpServers": {
"minecraft-controller": {
"type": "stdio",
"command": "C:\\...\\venv\\Scripts\\python.exe",
"args": ["C:\\...\\mcp_server\\server.py"],
"env": {"PATH": "%PATH%"}
}
}
}
Riavvia Claude per vedere il server ‘minecraft-controller’ elencato.
🧪 Test Locale con Python
Puoi testare il server localmente utilizzando il seguente script 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("Giocatori:", res)
cmds = await client.read_resource("minecraft://commands")
print("Comandi:", list(cmds.keys())[:5])
asyncio.run(test())
🧰 Come Funziona
- Funzionalità FastMCP: Carica automaticamente strumenti e risorse per una gestione efficiente dei comandi.
- Risorsa Comandi: La risorsa
minecraft://commands
fornisce un dizionario dei comandi disponibili. - Esecuzione dei Comandi: Lo strumento
run_minecraft_command
utilizzamcrcon
per inviare comandi al server Minecraft.
📚 Riferimenti
🛠 Prossimi Passi
- Implementare il supporto per il trasporto HTTP/SSE utilizzando Docker.
- Migliorare la validazione degli argomenti e le funzionalità di completamento automatico tramite il dizionario dei comandi.
- Aggiungere logging per azioni aggiuntive come
/start
,/stop
,/backup
e/whitelist
.
Preparati a elevare la tua esperienza con il server Minecraft! 🚀
Dettaglio
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! 🚀
Configurazione Server
{
"mcpServers": {
"minecraft-controller": {
"type": "stdio",
"command": "C:\\...\\venv\\Scripts\\python.exe",
"args": [
"C:\\...\\mcp_server\\server.py"
],
"env": {
"PATH": "%PATH%"
}
}
}
}