Class: ZeroMcp::Registry::ToolRegistry

Inherits:
Struct
  • Object
show all
Defined in:
lib/zeromcp/registry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject

Returns the value of attribute config

Returns:

  • (Object)

    the current value of config



11
12
13
# File 'lib/zeromcp/registry.rb', line 11

def config
  @config
end

#credential_cacheObject

Returns the value of attribute credential_cache

Returns:

  • (Object)

    the current value of credential_cache



11
12
13
# File 'lib/zeromcp/registry.rb', line 11

def credential_cache
  @credential_cache
end

#mcpObject

Returns the value of attribute mcp

Returns:

  • (Object)

    the current value of mcp



11
12
13
# File 'lib/zeromcp/registry.rb', line 11

def mcp
  @mcp
end

#openapiObject

Returns the value of attribute openapi

Returns:

  • (Object)

    the current value of openapi



11
12
13
# File 'lib/zeromcp/registry.rb', line 11

def openapi
  @openapi
end

#routesObject

Returns the value of attribute routes

Returns:

  • (Object)

    the current value of routes



11
12
13
# File 'lib/zeromcp/registry.rb', line 11

def routes
  @routes
end

Instance Method Details

#context_for(tool) ⇒ Object

Build a ready-to-use Context for tool, using the same config-driven credential/permission rules Server#call_tool already applies — so a caller invoking a routed tool directly (route.tool.call(args, ctx)) doesn't have to hand-roll credential lookup.



16
17
18
19
20
21
22
23
# File 'lib/zeromcp/registry.rb', line 16

def context_for(tool)
  ZeroMcp::Context.new(
    tool_name: tool.name,
    permissions: tool.permissions,
    bypass: config.bypass_permissions,
    credentials: ZeroMcp::Credentials.resolve(tool.name, config, cache: credential_cache)
  )
end