Minecraft MCP Server
Minecraft server management via RCON. Integrates FastMCP for easy command execution, supports interaction with Claude Desktop and other MCP clients, and offers a flexible architecture for local development and production use.
Overview
Minecraft-MCP-Server
A Python MCP Server designed to control a Minecraft server via RCON, utilizing FastMCP for seamless integration and command execution.
🔧 Features
- Command Dictionary: Provides a comprehensive set of commands to enhance the interaction with the Minecraft server.
- RCON Execution: Executes commands directly on the Minecraft server using RCON for real-time control.
- Client Integration: Compatible with Claude Desktop or any MCP client for easy management.
- Flexible Structure: Supports both local development through
stdio
and production environments via HTTP/SSE.
📦 Project Structure
mcp_server/
├── commands.json # Contains commands and examples for usage
├── server.py # The main server script for MCP
├── commands.json # Minecraft commands for contextual understanding
└── (venv/) # Optional virtual environment for dependencies
⚙️ Installation
-
Clone the Repository:
cd Minecraft-MCP-Server/mcp_server
-
Set Up Environment and Install Dependencies:
python -m venv venv venv\Scripts\activate pip install mcp[cli] mcrcon
📝 Setup
In the commands.json
file, you will find a variety of commands such as /give
, /weather
, and /gamemode
, complete with descriptions and usage examples.
Ensure RCON is enabled in your Minecraft server.properties
file:
enable-rcon=true
rcon.password=minemcp
rcon.port=25575
🚀 Running the Server
To start the server, activate the virtual environment and execute:
venv\Scripts\activate
python server.py
By default, the MCP server starts in STDIO mode.
⚙️ Integration with Claude Desktop
To integrate with Claude Desktop, modify the claude_desktop_config.json
file (located in %APPDATA%\Claude\
):
{
"mcpServers": {
"minecraft-controller": {
"type": "stdio",
"command": "C:\\...\\venv\\Scripts\\python.exe",
"args": ["C:\\...\\mcp_server\\server.py"],
"env": {"PATH": "%PATH%"}
}
}
}
Restart Claude to see the ‘minecraft-controller’ server listed.
🧪 Local Testing with Python
You can test the server locally using the following Python script:
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 Functionality: Automatically loads tools and resources for efficient command handling.
- Commands Resource: The resource
minecraft://commands
provides a dictionary of available commands. - Command Execution: The tool
run_minecraft_command
utilizesmcrcon
to send commands to the Minecraft server.
📚 References
🛠 Next Steps
- Implement support for HTTP/SSE transport using Docker.
- Enhance argument validation and autocomplete features via the commands dictionary.
- Add logging for additional actions such as
/start
,/stop
,/backup
, and/whitelist
.
Get ready to elevate your Minecraft server experience! 🚀
Details
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! 🚀
Server Config
{
"mcpServers": {
"minecraft-controller": {
"type": "stdio",
"command": "C:\\...\\venv\\Scripts\\python.exe",
"args": [
"C:\\...\\mcp_server\\server.py"
],
"env": {
"PATH": "%PATH%"
}
}
}
}