hub_kernel-mcp 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3113f06c6af7ead9f6321fdb00d2518557f17d03fbc79f3684260c2e146b641e
4
- data.tar.gz: aaa88888cd32c9ea2e28e731c968596d27ce27360c5b4725cb6020c7146de1ba
3
+ metadata.gz: fdf5562d9d62588f25ee064ae1571430d08a6ac2c452b957b1df4784f5c9cc1d
4
+ data.tar.gz: e122d851e02746457f5f4232eb118f3a2cd21100fb1931827f5af939c234076e
5
5
  SHA512:
6
- metadata.gz: facf0d8f1a0d4f9f68ee8f21ee33623dcbcda13fa9d3905337c898b047e0b8f67c16aab0374d6254135b15413e6de2b2efb1b6e972a3c2b2212790196d47ca69
7
- data.tar.gz: ba377f8a885f55972913d953daf6c766609880298cba383e2507ebcfdd564c538ed6d13c669edfa4cdb7540f620b1326e40106d35d7e773912af37a8d039ca00
6
+ metadata.gz: 120c5a8941826f02ceea5d9cf251d3ec30e0061f4282010526fd067da2f5b7fdfde270d90900842b58cefed05aafb9decf8acb52c49d05131eaf8ab0fe4a499d
7
+ data.tar.gz: 9082038898f81950d9a26c9973bc8d05e5d6769485d43f20eea358df2d274a388012fb3a1cd24393b88c73a4fecb2d3330e68923ec296f6ec34f6b0d9860b97c
data/README.md CHANGED
@@ -43,6 +43,18 @@ its input schema names the values the method takes:
43
43
  { "name": "supplies__price_of", "inputSchema": { "type": "object", "properties": { "item": {} } } }
44
44
  ```
45
45
 
46
+ `tools/call` runs the hub method a tool names, for the person and account the host's methods
47
+ give, and returns the method's answer as JSON text:
48
+
49
+ ```json
50
+ { "content": [ { "type": "text", "text": "\"soap costs 3\"" } ], "isError": false }
51
+ ```
52
+
53
+ A hub's refusal, or a value the method requires and the call left out, comes back as a tool
54
+ error carrying the reason, with `isError` set. A tool the caller may not call, a tool that does
55
+ not exist, and a tool naming a hub the host does not serve are all answered with the same
56
+ JSON-RPC error, code -32602, `Unknown tool: <name>`.
57
+
46
58
  A caller the host's sign-in refuses is refused before any hub is asked.
47
59
 
48
60
  ## Installation
@@ -1,12 +1,16 @@
1
1
  module HubKernel
2
2
  module Mcp
3
3
  class MessagesController < HubKernel::Mcp.base_controller.constantize
4
+ UnknownTool = Class.new(StandardError)
5
+
4
6
  PROTOCOL_VERSIONS = %w[2025-11-25 2025-06-18 2025-03-26 2024-11-05].freeze
5
7
 
6
8
  def create
7
9
  return head :accepted unless params.key?(:id)
8
10
 
9
11
  render json: { jsonrpc: "2.0", id: params[:id], result: answer }
12
+ rescue UnknownTool, HubKernel::UnexposedMethodError, HubKernel::NotAllowed
13
+ render json: { jsonrpc: "2.0", id: params[:id], error: { code: -32602, message: "Unknown tool: #{tool_name}" } }
10
14
  end
11
15
 
12
16
  private
@@ -15,6 +19,7 @@ module HubKernel
15
19
  case params[:method]
16
20
  when "initialize" then initialized
17
21
  when "tools/list" then { tools: tools }
22
+ when "tools/call" then called
18
23
  end
19
24
  end
20
25
 
@@ -30,6 +35,19 @@ module HubKernel
30
35
 
31
36
  def tool(served_name, exposure) = { name: "#{served_name}__#{exposure.name}", inputSchema: { type: "object", properties: exposure.takes.index_with { {} } } }
32
37
 
38
+ def called
39
+ served_name, method_name = tool_name.split("__", 2)
40
+ hub = HubKernel::Interface.find(served_name) || raise(UnknownTool)
41
+ answer = hub.call_exposed(method_name, values: arguments, person: caller_person, account: caller_account)
42
+ { content: [ { type: "text", text: answer.to_json } ], isError: false }
43
+ rescue HubKernel::Refused, HubKernel::MissingArgumentError => refusal
44
+ { content: [ { type: "text", text: refusal.message } ], isError: true }
45
+ end
46
+
47
+ def tool_name = params.dig(:params, :name).to_s
48
+
49
+ def arguments = params.dig(:params, :arguments)&.to_unsafe_h.to_h.deep_symbolize_keys
50
+
33
51
  def caller_person = send(HubKernel::Mcp.person_method)
34
52
 
35
53
  def caller_account = send(HubKernel::Mcp.account_method)
@@ -1,5 +1,5 @@
1
1
  module HubKernel
2
2
  module Mcp
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hub_kernel-mcp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider