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: 862fda276ef5442ec0c9ee381134e33ce27b1dd797d386db7db95defc29fa1ee
4
- data.tar.gz: 2d7892d5eceb1acc3643451e3786cc208cfa1fea1e4b440b05b6ec5a5c440ac8
3
+ metadata.gz: 1552f0de026c1ac0790e5fa34924b9263c0ce93ed7b331d174267e2b7dc2f7da
4
+ data.tar.gz: 7450308c7d05d625aa5f51e81695afa84039a0994ff055db068794ea8c9274fa
5
5
  SHA512:
6
- metadata.gz: b14998a48988aef825e41603d34a3ec571df2ffb5dff804494ecfe137f4fadc138d55b462580dca5097341bc098fab890d1fe8456a90c29ee25b64a6337cf8d3
7
- data.tar.gz: ab594bcf8c596d1f6f47c93f3a1c14163113b2767fb2dd9fb64cb9c92d97799144819d0b8870242562e02069c19fcee3eb0cde660b2c42c64f2783a35a300a4f
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
- property :title, :string
63
- property :content, :string
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
- property :param1, :string, required: true, description: 'First parameter description'
133
- property :param2, :string, required: false, description: 'Second parameter description'
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
- property :name, :string, required: true, description: 'User name'
151
- property :age, :integer, required: false, description: 'User age'
152
- property :addresses, :array, required: false, description: 'User addresses'
153
- property :preferences, :object, required: false, description: 'User preferences'
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 `authorized?` class method:
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
- property :command, :string, required: true, description: "Admin command to execute"
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.authorized?(auth_info)
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
- property :resource_id, :string, required: true, description: 'ID of the resource to access'
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
- property :email, :string, required: false, description: 'Email to search for'
349
- property :name, :string, required: false, description: 'Name to search for'
350
- property :limit, :integer, required: false, description: 'Maximum number of records to return'
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
- property :title, :string, required: false, description: 'Title to search for'
371
- property :author_id, :integer, required: false, description: 'Author ID to filter by'
372
- property :limit, :integer, required: false, description: 'Maximum number of records to return'
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 = {}
@@ -3,7 +3,7 @@ module ActiveMcp
3
3
  class Tools
4
4
  def self.to_hash(auth_info:)
5
5
  Tool.registered_tools.select do |tool_class|
6
- tool_class.authorized?(auth_info)
6
+ tool_class.visible?(auth_info)
7
7
  end.map do |tool_class|
8
8
  {
9
9
  name: tool_class.tool_name,
@@ -31,7 +31,7 @@ module ActiveMcp
31
31
  }
32
32
  end
33
33
 
34
- unless tool_class.authorized?(auth_info)
34
+ unless tool_class.visible?(auth_info)
35
35
  return {
36
36
  isError: true,
37
37
  content: [
@@ -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 authorized?(auth_info)
42
+ def visible?(auth_info)
39
43
  true
40
44
  end
41
45
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveMcp
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
@@ -1,13 +1,13 @@
1
1
  class <%= class_name %> < ActiveMcp::Tool
2
2
  description "<%= file_name.humanize %>"
3
3
 
4
- property :param1, :string, required: true, description: "First parameter description"
5
- property :param2, :string, required: false, description: "Second parameter description"
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.authorized?(auth_info)
10
+ # def self.visible?(auth_info)
11
11
  # # Example: require authentication
12
12
  # # return false unless auth_info
13
13
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_mcp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moeki Kawakami