active_mcp 0.3.2 → 0.3.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1552f0de026c1ac0790e5fa34924b9263c0ce93ed7b331d174267e2b7dc2f7da
|
4
|
+
data.tar.gz: 7450308c7d05d625aa5f51e81695afa84039a0994ff055db068794ea8c9274fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 392a25227f1dc6d0d073821dec6f6e0b17fa3fcdf1c2bb55793b4d71eab2422c173abb21a70820134d119e785f0991fe2e68cfa85aee987ef5f542cd966b5b49
|
7
|
+
data.tar.gz: fb1af057ea0a2f4a0dcdb664c2228013a8f058f13850be2de19be1516e26febbb9df06d51c9d74ec6262d2aa1a14f283067390ee579b5a93c96c1a736b2b15fa
|
data/README.md
CHANGED
@@ -59,8 +59,8 @@ end
|
|
59
59
|
class CreateNoteTool < ActiveMcp::Tool
|
60
60
|
description "Create Note!!"
|
61
61
|
|
62
|
-
|
63
|
-
|
62
|
+
argument :title, :string
|
63
|
+
argument :content, :string
|
64
64
|
|
65
65
|
def call(title:, content:)
|
66
66
|
Note.create(title:, content:)
|
@@ -129,8 +129,8 @@ This creates a new tool file at `app/tools/search_users_tool.rb` with the follow
|
|
129
129
|
class SearchUsersTool < ActiveMcp::Tool
|
130
130
|
description 'Search users'
|
131
131
|
|
132
|
-
|
133
|
-
|
132
|
+
argument :param1, :string, required: true, description: 'First parameter description'
|
133
|
+
argument :param2, :string, required: false, description: 'Second parameter description'
|
134
134
|
# Add more parameters as needed
|
135
135
|
|
136
136
|
def call(param1:, param2: nil, auth_info: nil, **args)
|
@@ -147,10 +147,10 @@ You can then customize the generated tool to fit your needs.
|
|
147
147
|
## Input Schema
|
148
148
|
|
149
149
|
```ruby
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
150
|
+
argument :name, :string, required: true, description: 'User name'
|
151
|
+
argument :age, :integer, required: false, description: 'User age'
|
152
|
+
argument :addresses, :array, required: false, description: 'User addresses'
|
153
|
+
argument :preferences, :object, required: false, description: 'User preferences'
|
154
154
|
```
|
155
155
|
|
156
156
|
Supported types include:
|
@@ -179,16 +179,16 @@ ActiveMcp supports both authentication (verifying who a user is) and authorizati
|
|
179
179
|
|
180
180
|
### Authorization for Tools
|
181
181
|
|
182
|
-
You can control which tools are visible and accessible to different users by overriding the `
|
182
|
+
You can control which tools are visible and accessible to different users by overriding the `visible?` class method:
|
183
183
|
|
184
184
|
```ruby
|
185
185
|
class AdminOnlyTool < ActiveMcp::Tool
|
186
186
|
description "This tool is only accessible by admins"
|
187
187
|
|
188
|
-
|
188
|
+
argument :command, :string, required: true, description: "Admin command to execute"
|
189
189
|
|
190
190
|
# Define authorization logic - only admin tokens can access this tool
|
191
|
-
def self.
|
191
|
+
def self.visible?(auth_info)
|
192
192
|
return false unless auth_info
|
193
193
|
return false unless auth_info[:type] == :bearer
|
194
194
|
|
@@ -274,7 +274,7 @@ Authentication information is automatically passed to your tools through the `au
|
|
274
274
|
class SecuredDataTool < ActiveMcp::Tool
|
275
275
|
description 'Access secured data'
|
276
276
|
|
277
|
-
|
277
|
+
argument :resource_id, :string, required: true, description: 'ID of the resource to access'
|
278
278
|
|
279
279
|
def call(resource_id:, auth_info: nil, **args)
|
280
280
|
# Check if auth info exists
|
@@ -345,9 +345,9 @@ For example, instead of creating a generic search tool, create specific search t
|
|
345
345
|
class SearchUsersTool < ActiveMcp::Tool
|
346
346
|
description 'Search users by criteria'
|
347
347
|
|
348
|
-
|
349
|
-
|
350
|
-
|
348
|
+
argument :email, :string, required: false, description: 'Email to search for'
|
349
|
+
argument :name, :string, required: false, description: 'Name to search for'
|
350
|
+
argument :limit, :integer, required: false, description: 'Maximum number of records to return'
|
351
351
|
|
352
352
|
def call(email: nil, name: nil, limit: 10)
|
353
353
|
criteria = {}
|
@@ -367,9 +367,9 @@ end
|
|
367
367
|
class SearchPostsTool < ActiveMcp::Tool
|
368
368
|
description 'Search posts by criteria'
|
369
369
|
|
370
|
-
|
371
|
-
|
372
|
-
|
370
|
+
argument :title, :string, required: false, description: 'Title to search for'
|
371
|
+
argument :author_id, :integer, required: false, description: 'Author ID to filter by'
|
372
|
+
argument :limit, :integer, required: false, description: 'Maximum number of records to return'
|
373
373
|
|
374
374
|
def call(title: nil, author_id: nil, limit: 10)
|
375
375
|
criteria = {}
|
data/lib/active_mcp/tool.rb
CHANGED
@@ -25,6 +25,10 @@ module ActiveMcp
|
|
25
25
|
@schema["required"] << name.to_s if required
|
26
26
|
end
|
27
27
|
|
28
|
+
def argument(...)
|
29
|
+
property(...)
|
30
|
+
end
|
31
|
+
|
28
32
|
def registered_tools
|
29
33
|
@registered_tools ||= []
|
30
34
|
end
|
@@ -35,7 +39,7 @@ module ActiveMcp
|
|
35
39
|
registered_tools << subclass
|
36
40
|
end
|
37
41
|
|
38
|
-
def
|
42
|
+
def visible?(auth_info)
|
39
43
|
true
|
40
44
|
end
|
41
45
|
end
|
data/lib/active_mcp/version.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
class <%= class_name %> < ActiveMcp::Tool
|
2
2
|
description "<%= file_name.humanize %>"
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
argument :param1, :string, required: true, description: "First parameter description"
|
5
|
+
argument :param2, :string, required: false, description: "Second parameter description"
|
6
6
|
# Add more parameters as needed
|
7
7
|
|
8
8
|
# Uncomment and modify this method to implement authorization control
|
9
9
|
# This controls who can see and use this tool
|
10
|
-
# def self.
|
10
|
+
# def self.visible?(auth_info)
|
11
11
|
# # Example: require authentication
|
12
12
|
# # return false unless auth_info
|
13
13
|
#
|