Module: ZeroMcp::Registry
- Defined in:
- lib/zeromcp/registry.rb
Defined Under Namespace
Classes: RouteDefinition, ToolRegistry
Class Method Summary collapse
-
.create(tools, config: nil, title: nil, execute_timeout: nil) ⇒ Object
tools: Hash[String, ZeroMcp::Tool] — already-constructed Tool instances, the same object Scanner#load_tool produces.
Class Method Details
.create(tools, config: nil, title: nil, execute_timeout: nil) ⇒ Object
tools: Hash[String, ZeroMcp::Tool] — already-constructed Tool instances, the same object Scanner#load_tool produces. Not raw hashes, and not file paths. config: optional ZeroMcp::Config. Defaults to ZeroMcp::Config.new (in-memory defaults, no zeromcp.config.json file read). When supplied, title:/execute_timeout: are ignored (the config already fully specifies them). title: OpenAPI info.title override. Ignored if config: is given. execute_timeout: default per-tool execute timeout in seconds. Ignored if config: is given.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/zeromcp/registry.rb', line 38 def create(tools, config: nil, title: nil, execute_timeout: nil) cfg = config || Config.new(title: title, execute_timeout: execute_timeout) server = Server.new(cfg, tools: tools) credential_cache = {} routes = tools.each_with_object([]) do |(name, tool), acc| next unless tool.route.is_a?(Hash) acc << RouteDefinition.new(name: name, method: tool.route_method, path: tool.route_path, tool: tool) end ToolRegistry.new( routes: routes, openapi: OpenApi.build(tools, cfg), mcp: ->(request) { server.handle_request(request) }, config: cfg, credential_cache: credential_cache ) end |