completion-kit 0.28.6 → 0.28.7
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/app/controllers/completion_kit/mcp_controller.rb +10 -1
- data/lib/completion_kit/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: 15a1909a7793a8a6cb9e0d95eb333483823c0040dd902b40a4a50e3ced485bee
|
|
4
|
+
data.tar.gz: fc407f0abd09a7505d56a96d4adcad8f9aedfa7ec6aaa4de928fb71fb8a9859c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 16242a62b2e34fc8667093e88cb77cba25fcdaab65c4603cfd693fbe3dcce71ac34a76a501ffb1725a8d868ee78107775984d42135d9b98ca846f48712416634
|
|
7
|
+
data.tar.gz: a3b5ba5d4eda948f3c2e2d0c5f75262793e3ddf439aac7e4a33c782df93dd0a4944e1b2b8655836fb4df25ae0f4e1e6a70ccb3b795a53d78951cac30456256dd
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
module CompletionKit
|
|
2
2
|
class McpController < Api::V1::BaseController
|
|
3
|
-
|
|
3
|
+
PUBLIC_METHODS = %w[initialize notifications/initialized tools/list].freeze
|
|
4
|
+
|
|
5
|
+
skip_before_action :authenticate_api!, only: [:stream, :handle], raise: false
|
|
4
6
|
|
|
5
7
|
def stream
|
|
6
8
|
response.set_header("Allow", "POST, DELETE")
|
|
@@ -9,6 +11,7 @@ module CompletionKit
|
|
|
9
11
|
|
|
10
12
|
def handle
|
|
11
13
|
request_body = JSON.parse(request.body.read)
|
|
14
|
+
return unless authorize_mcp_method(request_body["method"])
|
|
12
15
|
|
|
13
16
|
if request_body["method"] == "initialize"
|
|
14
17
|
result = McpDispatcher.initialize_session
|
|
@@ -48,6 +51,12 @@ module CompletionKit
|
|
|
48
51
|
|
|
49
52
|
private
|
|
50
53
|
|
|
54
|
+
def authorize_mcp_method(method)
|
|
55
|
+
return true if PUBLIC_METHODS.include?(method)
|
|
56
|
+
authenticate_api!
|
|
57
|
+
!performed?
|
|
58
|
+
end
|
|
59
|
+
|
|
51
60
|
def jsonrpc_response(id, result)
|
|
52
61
|
{jsonrpc: "2.0", id: id, result: result}
|
|
53
62
|
end
|