Class ToolInvocationGate

java.lang.Object
eu.mrapik.minecraftservermcp.internal.ToolInvocationGate

public final class ToolInvocationGate extends Object
Bridges MCP McpToolDefinition instances to the SDK's McpServerFeatures.AsyncToolSpecification by enforcing access control before the handler runs.

Flow for each call:

  1. Read the token string from McpTransportContext (set by McpHttpServer's context extractor from the HTTP request).
  2. Resolve the token to a profile via PluginSettings.profileByToken(String).
  3. Load ToolAccessConfig for this tool id; if ToolAccessConfig.enabled() is false, return an error result.
  4. Build McpToolInvocationImpl and invoke McpToolDefinition.call(McpToolInvocation).
This is the only path for both built-in and plugin-registered tools.
  • Method Summary

    Modifier and Type
    Method
    Description
    static io.modelcontextprotocol.server.McpServerFeatures.AsyncToolSpecification
    Wraps a definition so every invocation goes through runWithAccess(java.lang.String, io.modelcontextprotocol.server.McpAsyncServerExchange, io.modelcontextprotocol.spec.McpSchema.CallToolRequest, java.util.function.Supplier<eu.mrapik.minecraftservermcp.config.PluginSettings>, org.bukkit.plugin.java.JavaPlugin, eu.mrapik.minecraftservermcp.fs.ServerFilePaths, java.util.function.Function<eu.mrapik.minecraftservermcp.api.McpToolInvocation, reactor.core.publisher.Mono<io.modelcontextprotocol.spec.McpSchema.CallToolResult>>).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • wrapDefinition

      public static io.modelcontextprotocol.server.McpServerFeatures.AsyncToolSpecification wrapDefinition(McpToolDefinition def, Supplier<PluginSettings> settings, JavaPlugin mcpPlugin, ServerFilePaths paths)
      Wraps a definition so every invocation goes through runWithAccess(java.lang.String, io.modelcontextprotocol.server.McpAsyncServerExchange, io.modelcontextprotocol.spec.McpSchema.CallToolRequest, java.util.function.Supplier<eu.mrapik.minecraftservermcp.config.PluginSettings>, org.bukkit.plugin.java.JavaPlugin, eu.mrapik.minecraftservermcp.fs.ServerFilePaths, java.util.function.Function<eu.mrapik.minecraftservermcp.api.McpToolInvocation, reactor.core.publisher.Mono<io.modelcontextprotocol.spec.McpSchema.CallToolResult>>).
      Parameters:
      def - tool metadata and handler
      settings - current plugin settings (token → profile map)
      mcpPlugin - MCP plugin instance passed into McpToolInvocationImpl
      paths - server file path helper for invocations
      Returns:
      SDK tool specification registered on McpAsyncServer