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 +4 -4
- data/README.md +7 -4
- data/app/controllers/hub_kernel/mcp/messages_controller.rb +7 -1
- data/lib/hub_kernel/mcp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 90fe375e57411dd604b4bbcd46776ba7d3f64b829ab6d79c5ad9b0de4a14c1cd
|
|
4
|
+
data.tar.gz: eefdf79205bb8a4b8a5be1ec171dc4eac15316bede5f3ad3069efe3f1a2301d0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
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
|