Skip to content

Implement dedicated server support#9

Merged
cuspymd merged 10 commits intomainfrom
feature/dedicated-server-support-423232572268798275
Mar 2, 2026
Merged

Implement dedicated server support#9
cuspymd merged 10 commits intomainfrom
feature/dedicated-server-support-423232572268798275

Conversation

@cuspymd
Copy link
Owner

@cuspymd cuspymd commented Feb 28, 2026

This PR adds robust dedicated server support for the MCP mod.

  1. Architecture: Tool calls (execute_commands, get_player_info, etc.) are now abstracted behind interfaces. HTTPMCPServer and IPCServer have been moved to shared source code.
  2. Server Implementation: Created server-side implementations of these interfaces that utilize MinecraftServer and ServerWorld classes without touching MinecraftClient.
  3. Thread Safety: Server operations correctly delegate off the HTTP/IPC worker threads back onto the main MinecraftServer thread using server.submit(...).
  4. Logging & Features: execute_commands accurately captures console output from executed commands.
  5. Documentation: The README.md reflects the changes, explaining the differences between Single Player (Client MCP) and Dedicated Server environments, notably that take_screenshot is unsupported natively on dedicated servers. Configuration file is renamed from mcp-client.json to mcp.json with fallback.

PR created automatically by Jules for task 423232572268798275 started by @cuspymd

- Refactored core logic (HTTPMCPServer, IPCServer, CommandExecutor, etc.) into shared `src/main/java/` and implemented client/server specific interfaces to separate dependencies safely.
- Added `MCPServerModServer` entry point for dedicated servers.
- Made server tools thread-safe by using `server.submit(() -> ...).get()` for operations mutating the world or executing commands.
- Implemented `CommandOutput` interceptor in `ServerCommandExecutor` to retrieve command execution feedback.
- Migrated the config file from `mcp-client.json` to `mcp.json` automatically.
- Updated the `README.md` to clarify Server vs Client mode differences.

Co-authored-by: cuspymd <8870299+cuspymd@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6210eb4274

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

google-labs-jules bot and others added 3 commits February 28, 2026 23:59
- `ServerCommandExecutor` now runs `SafetyValidator` on incoming commands when `validate_safety` is true (the default) to prevent unauthorized/destructive commands via the server console.
- `ServerCommandExecutor` now wraps its result in the standard MCP JSON-RPC format via `MCPProtocol.createSuccessResponse()`, ensuring consistency with the client executor and MCP clients.

Co-authored-by: cuspymd <8870299+cuspymd@users.noreply.github.com>
…mappings

- Moved `MCPServerModServer` and server tools from `src/server` to `src/main` since there is no `server` sourceSet configured, ensuring they are compiled and packaged into the mod JAR.
- Resolved symbol mapping issues with `CommandManager` and `ServerPlayerEntity` for Fabric 1.21.11.
- Updated `BlockCompressor` to use a dedicated `BlockData` object to avoid `JsonObject` mapping conflicts across sides.

Co-authored-by: cuspymd <8870299+cuspymd@users.noreply.github.com>
`ServerBlockScanner` now returns a JSON object with an `"error"` property when validation or execution fails (e.g., no online players, area too large). This ensures that `HTTPMCPServer` correctly interprets the failure and wraps it as a proper MCP error response, instead of misclassifying it as a successful result containing an embedded error payload.

Co-authored-by: cuspymd <8870299+cuspymd@users.noreply.github.com>
@cuspymd
Copy link
Owner Author

cuspymd commented Mar 1, 2026

@codex review latest codes

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 754a75e233

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

google-labs-jules bot and others added 3 commits March 1, 2026 06:40
- Commands executed by the dispatcher now correctly reflect their execution result by assigning `successCount = server.getCommandManager().getDispatcher().execute(...)`. Previously, `successCount` was hardcoded to `1` as long as it didn't throw an exception, resulting in commands with no effect being marked `applied=true`.

Co-authored-by: cuspymd <8870299+cuspymd@users.noreply.github.com>
- Added a separate `appliedCount` integer to track how many commands successfully returned a non-zero side effect from `dispatcher.execute()`. Previously, `appliedCount` was incorrectly set to `acceptedCount`, breaking consistency with the `results[]` array where parsing failures or empty selectors are marked `applied=false` but `accepted=true`.

Co-authored-by: cuspymd <8870299+cuspymd@users.noreply.github.com>
- Updated `ServerBlockScanner` to use `getId().toString()` rather than `getId().getPath()` so that the block `minecraft:stone` is correctly identified rather than just `stone`. This matches the behavior of the client scanner and avoids merging blocks from different namespaces with the same path.

Co-authored-by: cuspymd <8870299+cuspymd@users.noreply.github.com>
google-labs-jules bot and others added 2 commits March 1, 2026 11:11
Co-authored-by: cuspymd <8870299+cuspymd@users.noreply.github.com>
@cuspymd
Copy link
Owner Author

cuspymd commented Mar 2, 2026

@codex review latest codes

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e19c24aadf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -20,13 +20,13 @@ public class IPCServer {
private static final Gson GSON = new Gson();
private static final int IPC_PORT = 25565; // Default port for IPC

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid binding IPC listener to the game's default port

IPCServer hardcodes IPC_PORT to 25565, 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 👍 / 👎.

If a dedicated server runs headless automation via MCP, `get_blocks_in_area` should still function even if the server is completely idle (0 players online). Instead of returning an error, it now falls back to scanning the server's Overworld dimension (`server.getOverworld()`).

Co-authored-by: cuspymd <8870299+cuspymd@users.noreply.github.com>
@cuspymd cuspymd merged commit 50ea637 into main Mar 2, 2026
2 checks passed
@cuspymd cuspymd deleted the feature/dedicated-server-support-423232572268798275 branch March 2, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant