Labsco
Peterson047 logo

Minecraft MCP Server

β˜… 6

from Peterson047

A Python MCP server to control a Minecraft server via RCON using FastMCP.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeAdvanced setup

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/
β”œβ”€β”€ __pycache__/
β”œβ”€β”€ .env                   # Environment variables for Gemini and paths
β”œβ”€β”€ commands.json          # Commands dictionary and examples  
β”œβ”€β”€ mcp_chat_client.py     # NEW: Client that listens to @ai messages from chat
β”œβ”€β”€ server.py              # Main MCP server  
β”œβ”€β”€ .gitattributes
β”œβ”€β”€ .gitignore
β”œβ”€β”€ readme.md
└── requirements.txt

βš™οΈ Integration with Claude Desktop

In claude_desktop_config.json (e.g., %APPDATA%\Claude\):

{
  "mcpServers": {
    "minecraft-controller": {
      "type": "stdio",
      "command": "/home/qkeq/Documentos/GitHub/Minecraft-MCP-Server/venv/bin/python3",
      "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 uses mcrcon to send commands to Minecraft

πŸ“š References

  • [FastMCP v2 – Sample README] (pypi.org)
  • [mcrcon – Python RCON client] (pypi.org)

πŸ›  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! πŸš€