Class: PermissionedServer

Inherits:
MCP::Server
  • Object
show all
Defined in:
app/mcp/permissioned_server.rb

Overview

MCP::Server that gates tools/call on service permissions, so a tool hidden
from tools/list can't just be invoked by name.

Why a subclass rather than overriding @handlers[TOOLS_CALL]: the gem does NOT
route tools/call through the handler hash — MCP::Server#handle_request has a
hard-coded when Methods::TOOLS_CALL then call_tool(...) branch, so a handler
override there silently no-ops and leaves every tool callable. Overriding the
(private) call_tool is what actually intercepts execution.

Instance Method Summary collapse

Constructor Details

#initialize(tool_service_map:) ⇒ PermissionedServer

Returns a new instance of PermissionedServer.

Parameters:

  • tool_service_map (Hash{String => Array<String>})

    tool name → service
    keys that grant it. A tool is callable when the caller holds ANY of them.



28
29
30
31
# File 'app/mcp/permissioned_server.rb', line 28

def initialize(tool_service_map:, **)
  @tool_service_map = tool_service_map
  super(**)
end