Skip to main content
Glama
server.py1.16 kB
import json from mcp.server.fastmcp import FastMCP from mcrcon import MCRcon # Configurações RCON HOST = "localhost" PORT = 25575 PASSWORD = "minemcp" def send_rcon(cmd: str) -> str: """Sending command by RCON.""" with MCRcon(HOST, PASSWORD, port=PORT) as mcr: return mcr.command(cmd) # Inicia o servidor MCP mcp = FastMCP("Minecraft MCP Server") # Carrega os comandos do arquivo commands.json commands_dict = {} try: with open("commands.json", "r", encoding="utf-8") as f: commands_dict = json.load(f) print("Commands loaded successfully from commands.json.") except FileNotFoundError: print("commands.json not found. The server will start without command definitions.") except json.JSONDecodeError: print("Error decoding commands.json. The server will start without command definitions.") @mcp.tool() def run_command(command: str) -> str: """Executes any command on the server via RCON.""" # O commands_dict pode ser usado aqui para validação, # ou para fornecer mais contexto à LLM sobre os comandos disponíveis. return send_rcon(command) if __name__ == "__main__": mcp.run()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Peterson047/Minecraft-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server