hub_kernel-mcp 0.4.0 → 0.5.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: 363a48c785a072c9ba3c744969cb93de55d2514c0e68008873a9bb7312fd8fb0
4
- data.tar.gz: c3f27a9e3a246c1742cd101415b286f7096dfeed8e52bb618e604b7e5127060b
3
+ metadata.gz: 90fe375e57411dd604b4bbcd46776ba7d3f64b829ab6d79c5ad9b0de4a14c1cd
4
+ data.tar.gz: eefdf79205bb8a4b8a5be1ec171dc4eac15316bede5f3ad3069efe3f1a2301d0
5
5
  SHA512:
6
- metadata.gz: 58097086aeed03bd87cb0d10ae8b554b2963823300f1d70f85f8efd7ddcaf5d195eaf2e397edf5cad03fc98966fa754fe0eb489251bc3e3c552178d50d5cc292
7
- data.tar.gz: 581abee68889b126bb28291ad58329fab0b7d5c48e7bef6be0860a766105fde7afe633d5ca72e715defe35721268f7572dc4e35421b3050c6d2be752cbf6c2f4
6
+ metadata.gz: 2d964c38b18504184297666e94174507baf671c754dfd131b428be747efb337574e32292c331c7f23908edbc9a11dd44e46414a0e141c1d41a9e9d04e043c24c
7
+ data.tar.gz: 6a98d684583139acc2ace28041202f55f59d19cc06ec894dbd5929101502fecdd91b8904aa356a56690e2a609d9637df0c0bf61232bcd7db194b42ff2e314044
data/README.md CHANGED
@@ -65,10 +65,13 @@ give, and returns the method's answer as JSON text:
65
65
  { "content": [ { "type": "text", "text": "\"soap costs 3\"" } ], "isError": false }
66
66
  ```
67
67
 
68
- A hub's refusal, or a value the method requires and the call left out, comes back as a tool
69
- error carrying the reason, with `isError` set. A tool the caller may not call, a tool that does
70
- not exist, and a tool naming a hub the host does not serve are all answered with the same
71
- JSON-RPC error, code -32602, `Unknown tool: <name>`.
68
+ A hub's refusal, a value the method requires and the call left out, a value the method is not
69
+ listed with, and a record the call names that does not exist each come back as a tool error
70
+ carrying the reason, with `isError` set. The last two reasons come from hub_kernel-interface, so
71
+ they read the same in every interface gem, such as `price_of does not take colour` and
72
+ `No item has the id 9`. A tool the caller may not call, a tool that does not exist, and a tool
73
+ naming a hub the host does not serve are all answered with the same JSON-RPC error, code
74
+ -32602, `Unknown tool: <name>`, whatever values the call sends.
72
75
 
73
76
  A caller the host's sign-in refuses is refused before any hub is asked.
74
77
 
@@ -38,12 +38,18 @@ module HubKernel
38
38
  def called
39
39
  served_name, method_name = tool_name.split("__", 2)
40
40
  hub = HubKernel::Interface.find(served_name) || raise(UnknownTool)
41
+ raise UnknownTool unless hub.exposed(method_name)
42
+ HubKernel::Interface::CallReasons.refuse_unlisted_values(hub, method_name, values: arguments, person: caller_person, account: caller_account)
41
43
  answer = hub.call_exposed(method_name, values: arguments, person: caller_person, account: caller_account)
42
44
  { content: [ { type: "text", text: answer.to_json } ], isError: false }
43
45
  rescue HubKernel::Refused, HubKernel::MissingArgumentError => refusal
44
- { content: [ { type: "text", text: refusal.message } ], isError: true }
46
+ tool_error(refusal.message)
47
+ rescue ActiveRecord::RecordNotFound => missing
48
+ tool_error(HubKernel::Interface::CallReasons.missing_record(missing))
45
49
  end
46
50
 
51
+ def tool_error(reason) = { content: [ { type: "text", text: reason } ], isError: true }
52
+
47
53
  def tool_name = params.dig(:params, :name).to_s
48
54
 
49
55
  def arguments = params.dig(:params, :arguments)&.to_unsafe_h.to_h.deep_symbolize_keys
@@ -1,5 +1,5 @@
1
1
  module HubKernel
2
2
  module Mcp
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.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.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider