Minecraft Servidor MCP
Gestión de servidores de Minecraft a través de RCON. Integra FastMCP para una fácil ejecución de comandos, soporta la interacción con Claude Desktop y otros clientes MCP, y ofrece una arquitectura flexible para el desarrollo local y el uso en producción.
Resumen
Minecraft-MCP-Server
Un servidor MCP en Python diseñado para controlar un servidor de Minecraft a través de RCON, utilizando FastMCP para una integración y ejecución de comandos sin problemas.
🔧 Características
- Diccionario de Comandos: Proporciona un conjunto completo de comandos para mejorar la interacción con el servidor de Minecraft.
- Ejecución RCON: Ejecuta comandos directamente en el servidor de Minecraft usando RCON para un control en tiempo real.
- Integración con Cliente: Compatible con Claude Desktop o cualquier cliente MCP para una gestión fácil.
- Estructura Flexible: Soporta tanto el desarrollo local a través de
stdio
como entornos de producción vía HTTP/SSE.
📦 Estructura del Proyecto
mcp_server/
├── commands.json # Contiene comandos y ejemplos de uso
├── server.py # El script principal del servidor para MCP
├── commands.json # Comandos de Minecraft para comprensión contextual
└── (venv/) # Entorno virtual opcional para dependencias
⚙️ Instalación
-
Clona el Repositorio:
cd Minecraft-MCP-Server/mcp_server
-
Configura el Entorno e Instala Dependencias:
python -m venv venv venv\Scripts\activate pip install mcp[cli] mcrcon
📝 Configuración
En el archivo commands.json
, encontrarás una variedad de comandos como /give
, /weather
y /gamemode
, completos con descripciones y ejemplos de uso.
Asegúrate de que RCON esté habilitado en tu archivo server.properties
de Minecraft:
enable-rcon=true
rcon.password=minemcp
rcon.port=25575
🚀 Ejecutando el Servidor
Para iniciar el servidor, activa el entorno virtual y ejecuta:
venv\Scripts\activate
python server.py
Por defecto, el servidor MCP se inicia en modo STDIO.
⚙️ Integración con Claude Desktop
Para integrar con Claude Desktop, modifica el archivo claude_desktop_config.json
(ubicado en %APPDATA%\Claude\
):
{
"mcpServers": {
"minecraft-controller": {
"type": "stdio",
"command": "C:\\...\\venv\\Scripts\\python.exe",
"args": ["C:\\...\\mcp_server\\server.py"],
"env": {"PATH": "%PATH%"}
}
}
}
Reinicia Claude para ver el servidor ‘minecraft-controller’ listado.
🧪 Pruebas Locales con Python
Puedes probar el servidor localmente usando el siguiente script de 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("Jugadores:", res)
cmds = await client.read_resource("minecraft://commands")
print("Comandos:", list(cmds.keys())[:5])
asyncio.run(test())
🧰 Cómo Funciona
- Funcionalidad de FastMCP: Carga automáticamente herramientas y recursos para un manejo eficiente de comandos.
- Recurso de Comandos: El recurso
minecraft://commands
proporciona un diccionario de comandos disponibles. - Ejecución de Comandos: La herramienta
run_minecraft_command
utilizamcrcon
para enviar comandos al servidor de Minecraft.
📚 Referencias
🛠 Próximos Pasos
- Implementar soporte para transporte HTTP/SSE usando Docker.
- Mejorar la validación de argumentos y las características de autocompletado a través del diccionario de comandos.
- Agregar registro para acciones adicionales como
/start
,/stop
,/backup
, y/whitelist
.
¡Prepárate para elevar tu experiencia en el servidor de Minecraft! 🚀
Detalle
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! 🚀
Configuración del Servidor
{
"mcpServers": {
"minecraft-controller": {
"type": "stdio",
"command": "C:\\...\\venv\\Scripts\\python.exe",
"args": [
"C:\\...\\mcp_server\\server.py"
],
"env": {
"PATH": "%PATH%"
}
}
}
}