Class: BundleUp::Unify::MCP

Inherits:
Object
  • Object
show all
Defined in:
lib/bundleup/unify/mcp.rb

Overview

The Unified MCP server.

Same protocol and headers as Proxy MCP, but the tools are BundleUp's normalized ones rather than the provider's. Tools only — Unified MCP exposes no resources or prompts.

The server is stateless and POST-only, so there is no session to close.

Constant Summary collapse

BASE_URL =
'https://unify.bundleup.io/v1/mcp'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, connection_id) ⇒ MCP

Returns a new instance of MCP.



17
18
19
20
21
# File 'lib/bundleup/unify/mcp.rb', line 17

def initialize(api_key, connection_id)
  @api_key = api_key
  @connection_id = connection_id
  @client = ::BundleUp::MCPClient.new(BASE_URL, api_key, connection_id)
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



15
16
17
# File 'lib/bundleup/unify/mcp.rb', line 15

def api_key
  @api_key
end

#connection_idObject (readonly)

Returns the value of attribute connection_id.



15
16
17
# File 'lib/bundleup/unify/mcp.rb', line 15

def connection_id
  @connection_id
end

Instance Method Details

#call_tool(name, args = {}) ⇒ Object

Call a unified tool with optional arguments.

Raises:

  • (ArgumentError)


37
38
39
40
41
# File 'lib/bundleup/unify/mcp.rb', line 37

def call_tool(name, args = {})
  raise ArgumentError, 'Tool name is required to call a tool.' if name.nil? || name.to_s.empty?

  @client.call_tool(name, args)
end

#hostedObject

The URL and a single bearer token carrying both the API key and the connection, for model-hosted MCP clients that cannot set headers.



25
26
27
28
29
# File 'lib/bundleup/unify/mcp.rb', line 25

def hosted
  separator = ::BundleUp::MCP::CREDENTIAL_SEPARATOR

  { url: BASE_URL, token: "#{@api_key}#{separator}#{@connection_id}" }
end

#list_toolsObject

List the available unified tools.



32
33
34
# File 'lib/bundleup/unify/mcp.rb', line 32

def list_tools
  @client.list_tools
end