The Model Context Protocol (MCP) server for Minecraft provides AI systems a way to interact with Minecraft through the Mineflayer API. This implementation allows AI assistants to receive game data and send commands to control a Minecraft character, enabling interesting AI-driven gameplay experiences.
git clone https://github.com/yourusername/minecraft-mcp-server.git
cd minecraft-mcp-server
npm install
cp config.example.json config.json
config.json
file with your Minecraft server details:{
"host": "localhost",
"port": 25565,
"username": "your_minecraft_username",
"password": "your_password",
"auth": "microsoft",
"version": "1.19.3"
}
For offline mode servers, you can use:
{
"host": "localhost",
"port": 25565,
"username": "Bot",
"version": "1.19.3"
}
Start the MCP server with the following command:
npm start
You should see output confirming the server is running, typically on port 8000.
The MCP server exposes WebSocket endpoints that clients can connect to:
ws://localhost:8000/
ws://localhost:8000/events
Connect to the WebSocket endpoint and send JSON messages in the MCP format:
{
"type": "command",
"data": {
"command": "move",
"args": {
"direction": "forward",
"distance": 5
}
}
}
move: Move in a direction
{
"type": "command",
"data": {
"command": "move",
"args": {
"direction": "forward|backward|left|right",
"distance": 5
}
}
}
lookAt: Turn to face a specific coordinate
{
"type": "command",
"data": {
"command": "lookAt",
"args": {
"x": 100,
"y": 64,
"z": 200
}
}
}
dig: Mine a block at specific coordinates
{
"type": "command",
"data": {
"command": "dig",
"args": {
"x": 100,
"y": 64,
"z": 200
}
}
}
placeBlock: Place a block from inventory
{
"type": "command",
"data": {
"command": "placeBlock",
"args": {
"x": 100,
"y": 64,
"z": 200,
"blockType": "dirt"
}
}
}
Connect to the events endpoint to receive a stream of game updates:
wscat -c ws://localhost:8000/events
Example event data:
{
"type": "gameState",
"data": {
"player": {
"position": {"x": 100, "y": 64, "z": 200},
"health": 20,
"food": 20,
"inventory": [...]
},
"world": {
"blocks": [...],
"entities": [...]
}
}
}
If the bot disconnects unexpectedly, check the console for error messages that may indicate what went wrong.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.