hub_kernel-mcp 0.1.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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +56 -0
- data/Rakefile +6 -0
- data/app/controllers/hub_kernel/mcp/messages_controller.rb +38 -0
- data/config/routes.rb +3 -0
- data/lib/hub_kernel/mcp/engine.rb +7 -0
- data/lib/hub_kernel/mcp/version.rb +5 -0
- data/lib/hub_kernel/mcp.rb +11 -0
- data/lib/hub_kernel-mcp.rb +1 -0
- metadata +82 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 3113f06c6af7ead9f6321fdb00d2518557f17d03fbc79f3684260c2e146b641e
|
|
4
|
+
data.tar.gz: aaa88888cd32c9ea2e28e731c968596d27ce27360c5b4725cb6020c7146de1ba
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: facf0d8f1a0d4f9f68ee8f21ee33623dcbcda13fa9d3905337c898b047e0b8f67c16aab0374d6254135b15413e6de2b2efb1b6e972a3c2b2212790196d47ca69
|
|
7
|
+
data.tar.gz: ba377f8a885f55972913d953daf6c766609880298cba383e2507ebcfdd564c538ed6d13c669edfa4cdb7540f620b1326e40106d35d7e773912af37a8d039ca00
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright tylercschneider
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# hub_kernel-mcp
|
|
2
|
+
|
|
3
|
+
Serves the methods every hub a host serves exposes as MCP tools, at one address. Every
|
|
4
|
+
request goes through the host's own sign-in, then hub_kernel's permission check and account
|
|
5
|
+
scope.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
Add the gem, then in an initializer name the controller the endpoint inherits from and the two
|
|
10
|
+
methods on it that give the person and the account a request is made for:
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
HubKernel::Mcp.base_controller = "Api::HubBaseController"
|
|
14
|
+
HubKernel::Mcp.person_method = :current_person
|
|
15
|
+
HubKernel::Mcp.account_method = :current_account
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The hubs served are the host's one list in hub_kernel-interface, which every interface gem
|
|
19
|
+
serves:
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
Rails.application.config.to_prepare do
|
|
23
|
+
HubKernel::Interface.hubs = [ Supplies, { "money" => Billing::Ledger } ]
|
|
24
|
+
end
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Mount the engine:
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
mount HubKernel::Mcp::Engine => "/mcp"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The endpoint takes MCP's JSON-RPC requests by POST. `initialize` answers the server's name,
|
|
34
|
+
its version, a tools capability, and the protocol version the client asked for when the gem
|
|
35
|
+
supports it, or else the newest it does: 2025-11-25, 2025-06-18, 2025-03-26 or 2024-11-05. A
|
|
36
|
+
notification is accepted with no answer.
|
|
37
|
+
|
|
38
|
+
`tools/list` returns one tool for each method the caller may call, across every served hub.
|
|
39
|
+
Each tool is named `<hub>__<method>`, where the hub part is the name the hub is served at, and
|
|
40
|
+
its input schema names the values the method takes:
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{ "name": "supplies__price_of", "inputSchema": { "type": "object", "properties": { "item": {} } } }
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
A caller the host's sign-in refuses is refused before any hub is asked.
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
```ruby
|
|
51
|
+
gem "hub_kernel-mcp"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module HubKernel
|
|
2
|
+
module Mcp
|
|
3
|
+
class MessagesController < HubKernel::Mcp.base_controller.constantize
|
|
4
|
+
PROTOCOL_VERSIONS = %w[2025-11-25 2025-06-18 2025-03-26 2024-11-05].freeze
|
|
5
|
+
|
|
6
|
+
def create
|
|
7
|
+
return head :accepted unless params.key?(:id)
|
|
8
|
+
|
|
9
|
+
render json: { jsonrpc: "2.0", id: params[:id], result: answer }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def answer
|
|
15
|
+
case params[:method]
|
|
16
|
+
when "initialize" then initialized
|
|
17
|
+
when "tools/list" then { tools: tools }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def initialized = { protocolVersion: protocol_version, serverInfo: { name: "hub_kernel-mcp", version: HubKernel::Mcp::VERSION }, capabilities: { tools: {} } }
|
|
22
|
+
|
|
23
|
+
def protocol_version = PROTOCOL_VERSIONS.include?(params.dig(:params, :protocolVersion)) ? params.dig(:params, :protocolVersion) : PROTOCOL_VERSIONS.first
|
|
24
|
+
|
|
25
|
+
def tools
|
|
26
|
+
HubKernel::Interface.served.flat_map do |served_name, hub|
|
|
27
|
+
hub.exposures_for(person: caller_person, account: caller_account).map { |exposure| tool(served_name, exposure) }
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def tool(served_name, exposure) = { name: "#{served_name}__#{exposure.name}", inputSchema: { type: "object", properties: exposure.takes.index_with { {} } } }
|
|
32
|
+
|
|
33
|
+
def caller_person = send(HubKernel::Mcp.person_method)
|
|
34
|
+
|
|
35
|
+
def caller_account = send(HubKernel::Mcp.account_method)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require "hub_kernel-interface"
|
|
2
|
+
require "hub_kernel/mcp/version"
|
|
3
|
+
require "hub_kernel/mcp/engine"
|
|
4
|
+
|
|
5
|
+
module HubKernel
|
|
6
|
+
module Mcp
|
|
7
|
+
mattr_accessor :base_controller, default: "ActionController::API"
|
|
8
|
+
mattr_accessor :person_method
|
|
9
|
+
mattr_accessor :account_method
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "hub_kernel/mcp"
|
metadata
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: hub_kernel-mcp
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- tylercschneider
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: rails
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: 8.1.3
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: 8.1.3
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: hub_kernel-interface
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0.3'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0.3'
|
|
40
|
+
description: hub_kernel-mcp serves the methods every hub a host serves exposes as
|
|
41
|
+
MCP tools at one address, with every call going through the host's sign-in, permission
|
|
42
|
+
check and account scope.
|
|
43
|
+
email:
|
|
44
|
+
- tylercschneider@gmail.com
|
|
45
|
+
executables: []
|
|
46
|
+
extensions: []
|
|
47
|
+
extra_rdoc_files: []
|
|
48
|
+
files:
|
|
49
|
+
- MIT-LICENSE
|
|
50
|
+
- README.md
|
|
51
|
+
- Rakefile
|
|
52
|
+
- app/controllers/hub_kernel/mcp/messages_controller.rb
|
|
53
|
+
- config/routes.rb
|
|
54
|
+
- lib/hub_kernel-mcp.rb
|
|
55
|
+
- lib/hub_kernel/mcp.rb
|
|
56
|
+
- lib/hub_kernel/mcp/engine.rb
|
|
57
|
+
- lib/hub_kernel/mcp/version.rb
|
|
58
|
+
homepage: https://github.com/DYB-Development/hub_kernel-mcp
|
|
59
|
+
licenses:
|
|
60
|
+
- MIT
|
|
61
|
+
metadata:
|
|
62
|
+
allowed_push_host: https://rubygems.org
|
|
63
|
+
homepage_uri: https://github.com/DYB-Development/hub_kernel-mcp
|
|
64
|
+
source_code_uri: https://github.com/DYB-Development/hub_kernel-mcp
|
|
65
|
+
rdoc_options: []
|
|
66
|
+
require_paths:
|
|
67
|
+
- lib
|
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
|
+
requirements:
|
|
70
|
+
- - ">="
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
version: 3.2.0
|
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
|
+
requirements:
|
|
75
|
+
- - ">="
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: '0'
|
|
78
|
+
requirements: []
|
|
79
|
+
rubygems_version: 4.0.20
|
|
80
|
+
specification_version: 4
|
|
81
|
+
summary: Serves a hub_kernel hub's exposed methods as MCP tools.
|
|
82
|
+
test_files: []
|