Module: Riffer::Mcp

Defined in:
lib/riffer/mcp.rb

Overview

Riffer::Mcp provides integration with Model Context Protocol (MCP) servers.

Register MCP servers globally; agents opt-in by tag via the use_mcp DSL. Tags are application-defined; see docs/14_MCP.md (Tags section).

Riffer::Mcp.register(
  name: "github",
  tags: [:github],
  endpoint: "https://mcp.github.com",
  discovery_headers: -> { {"Authorization" => "Bearer #{ENV['GITHUB_TOKEN']}"} }
)

class MyAgent < Riffer::Agent
  model "openai/gpt-4o"
  use_mcp :github
end

Defined Under Namespace

Modules: AuthenticatedTool, Registry, ToolFactory Classes: Client, CredentialsDeniedError, Error, Manifest, Registration

Class Method Summary collapse

Class Method Details

.register(manifest_or_hash) ⇒ Object

Registers an MCP server, blocking until tool discovery completes.

Raises on discovery failure. Pass a Manifest instance or a hash with the same keys.

– : ((Hash[Symbol, untyped] | Riffer::Mcp::Manifest)) -> Riffer::Mcp::Registration



36
37
38
# File 'lib/riffer/mcp.rb', line 36

def self.register(manifest_or_hash)
  Registry.register(manifest_or_hash)
end

.registrationsObject

Returns all current registrations keyed by name (for introspection).

– : () -> Hash[String, Riffer::Mcp::Registration]



54
55
56
# File 'lib/riffer/mcp.rb', line 54

def self.registrations
  Registry.registrations
end

.unregister(name) ⇒ Object

Removes a registration by name.

Subsequent agent runs will not see tools from this server.

– : (String) -> void



46
47
48
# File 'lib/riffer/mcp.rb', line 46

def self.unregister(name)
  Registry.unregister(name)
end