-
Notifications
You must be signed in to change notification settings - Fork 1
Implement dedicated server support #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cuspymd
merged 10 commits into
main
from
feature/dedicated-server-support-423232572268798275
Mar 2, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6210eb4
Implement dedicated server support for the MCP Server Mod
google-labs-jules[bot] 5f28551
Address PR feedback: safety validation and response format
google-labs-jules[bot] 2c4a07b
Fix build: Move server classes to main source set and resolve symbol …
google-labs-jules[bot] 754a75e
Return correct error format from ServerBlockScanner
google-labs-jules[bot] 40c915e
Fix ServerCommandExecutor to capture command failure states
google-labs-jules[bot] a5feab7
Fix appliedCount metric in ServerCommandExecutor
google-labs-jules[bot] 3b8b875
Fix block scanner to include full namespace
google-labs-jules[bot] 6fc6d65
Empty commit for comment resolution
google-labs-jules[bot] e19c24a
Fix server MCP tool exposure and runServer dev setup
cuspymd 16d0970
Fallback to overworld on ServerBlockScanner when no players online
google-labs-jules[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package cuspymd.mcp.mod; | ||
|
|
||
| import net.fabricmc.api.DedicatedServerModInitializer; | ||
| import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; | ||
| import cuspymd.mcp.mod.bridge.HTTPMCPServer; | ||
| import cuspymd.mcp.mod.bridge.IPCServer; | ||
| import cuspymd.mcp.mod.config.MCPConfig; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class MCPServerModServer implements DedicatedServerModInitializer { | ||
| public static final Logger LOGGER = LoggerFactory.getLogger("mcp-server-mod"); | ||
| private HTTPMCPServer httpServer; | ||
| private IPCServer ipcServer; | ||
|
|
||
| @Override | ||
| public void onInitializeServer() { | ||
| LOGGER.info("Initializing Minecraft MCP Dedicated Server"); | ||
|
|
||
| ServerLifecycleEvents.SERVER_STARTED.register(server -> { | ||
| try { | ||
| MCPConfig config = MCPConfig.load(); | ||
| if (config.getServer().isAutoStart()) { | ||
| String transport = config.getServer().getTransport(); | ||
|
|
||
| if ("http".equals(transport)) { | ||
| httpServer = new HTTPMCPServer(config, | ||
| new cuspymd.mcp.mod.server.tools.ServerCommandExecutor(config, server), | ||
| new cuspymd.mcp.mod.server.tools.ServerPlayerInfoProvider(server), | ||
| new cuspymd.mcp.mod.server.tools.ServerBlockScanner(server), | ||
| new cuspymd.mcp.mod.server.tools.ServerScreenshotUtils(), | ||
| false | ||
| ); | ||
| httpServer.start(); | ||
| LOGGER.info("HTTP MCP Server started on port {}", httpServer.getPort()); | ||
| } else { | ||
| // Default to stdio transport | ||
| ipcServer = new IPCServer(config, new cuspymd.mcp.mod.server.tools.ServerCommandExecutor(config, server)); | ||
| ipcServer.start(); | ||
| LOGGER.info("IPC Server started on port {}", ipcServer.getPort()); | ||
| } | ||
| } | ||
| } catch (Exception e) { | ||
| LOGGER.error("Failed to start MCP Server", e); | ||
| } | ||
| }); | ||
|
|
||
| ServerLifecycleEvents.SERVER_STOPPING.register(server -> { | ||
| if (ipcServer != null) { | ||
| ipcServer.stop(); | ||
| LOGGER.info("IPC Server stopped"); | ||
| } | ||
| if (httpServer != null) { | ||
| httpServer.stop(); | ||
| LOGGER.info("HTTP MCP Server stopped"); | ||
| } | ||
| }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package cuspymd.mcp.mod.command; | ||
|
|
||
| import com.google.gson.JsonObject; | ||
|
|
||
| public interface ICommandExecutor { | ||
| JsonObject executeCommands(JsonObject arguments); | ||
| } |
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IPCServerhardcodesIPC_PORTto25565, and this commit now starts that listener on dedicated servers when non-HTTP transport is selected. On servers using the normal gameplay port, this creates a bind collision and MCP fails to start for that transport mode. Make the IPC port configurable (or otherwise distinct from the gameplay listener) so dedicated deployments can actually use IPC mode.Useful? React with 👍 / 👎.