active_mcp 0.10.4 → 0.10.6

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: 4e5f0c16d5def1392e446cb729d43ec33699f3162662657b13c60ee28b796d87
4
- data.tar.gz: 1fa830ca3cac342d8474aab4bf5ffdcd6b5d3c93d13e8818e0576135ae9d7dc1
3
+ metadata.gz: 93ccaa05722a21cba3848bdd01f1e06093336995c160a95627d0ce959bc43c41
4
+ data.tar.gz: 21c775034a7dfbdab65bdab4dd9875920a80a0f8398f600f7ce7edfe6775f174
5
5
  SHA512:
6
- metadata.gz: 985e527de84d6d16a879a3c4f54a202d95145e7a35edd78d3f692141370993278d298a62341be892f8f9a83b04bea7411607db0c98410112287544bb8e9d5abf
7
- data.tar.gz: c2bf6587bf7725f23f345ac21f43d113e7fb4eb8b9f2a20631f42492f06ceddac18351adc732a35ac7b655f051917bbad90ec15656c3d5d41be75bb5f711dd1d
6
+ metadata.gz: c82327781df5e274a63cdf39156e962906ad8dc572ea20a52a27a5b1f9a1bad21d499fa71fc0b3d1384508f3d894a480ac95e5bfc4e34de13d3f51fe80a48a5e
7
+ data.tar.gz: db3f5fb7f7ca0d6e97bda8b3cbce693b950df17a4f3378e8ce3903932ee52c8ef708c02dd94b9ed59bc5b2fa2c842e937c05a4e0d1a8934ce036863ac8eeb8c9
data/README.md CHANGED
@@ -350,6 +350,12 @@ Resources are Ruby classes `**Resource`:
350
350
 
351
351
  ```ruby
352
352
  class UserResource < ActiveMcp::Resource::Base
353
+ class << self
354
+ def mime_type
355
+ "application/json"
356
+ end
357
+ end
358
+
353
359
  def initialize(id:)
354
360
  @user = User.find(id)
355
361
  end
@@ -362,10 +368,6 @@ class UserResource < ActiveMcp::Resource::Base
362
368
  "data://localhost/users/#{@user.id}"
363
369
  end
364
370
 
365
- def mime_type
366
- "application/json"
367
- end
368
-
369
371
  def description
370
372
  @user.profile
371
373
  end
@@ -482,7 +484,7 @@ class UserResource < ActiveMcp::Resource::Base
482
484
  end
483
485
  end
484
486
 
485
- argument :id, complete: ->(value) do
487
+ argument :id, complete: ->(value, context) do
486
488
  User.all.pluck(:id).filter { _1.match(value) }
487
489
  end
488
490
 
@@ -528,7 +530,7 @@ Resources are Ruby classes `**Prompt`:
528
530
 
529
531
  ```ruby
530
532
  class HelloPrompt < ActiveMcp::Prompt::Base
531
- argument :name, required: true, description: "User name", complete: ->(value) do
533
+ argument :name, required: true, description: "User name", complete: ->(value, context) do
532
534
  User.all.pluck(:name).filter { _1.match(value) }
533
535
  end
534
536
 
@@ -8,11 +8,11 @@ module ActiveMcp
8
8
 
9
9
  if uri_template
10
10
  resource_class = refs.find { _1.uri_template == uri_template }
11
- values = resource_class.arguments[arg_name.to_sym].call(value)
11
+ values = resource_class.arguments[arg_name.to_sym].call(value, context)
12
12
  {values:, total: values.length}
13
13
  elsif ref_name
14
14
  prompt = refs.find { _1.prompt_name == ref_name }
15
- values = prompt.class.arguments.find { _1[:name] == arg_name.to_sym }[:complete].call(value)
15
+ values = prompt.class.arguments.find { _1[:name] == arg_name.to_sym }[:complete].call(value, context)
16
16
  {values:, total: values.length}
17
17
  end
18
18
  end
@@ -6,14 +6,11 @@ module ActiveMcp
6
6
  [
7
7
  Rails.root.join("app", "mcp", "tools"),
8
8
  Rails.root.join("app", "mcp", "resources"),
9
- Rails.root.join("app", "mcp", "resource_templates"),
10
9
  Rails.root.join("app", "mcp", "prompts"),
11
10
  Rails.root.join("app", "mcp", "schemas")
12
- ].each do |tools_path|
13
- if Dir.exist?(tools_path)
14
- Dir[tools_path.join("*.rb")].sort.each do |file|
15
- require_dependency file
16
- end
11
+ ].each do |path|
12
+ if Dir.exist?(path)
13
+ app.autoloaders.main.push_dir(path)
17
14
  end
18
15
  end
19
16
  end
@@ -39,6 +39,7 @@ module ActiveMcp
39
39
  request = Net::HTTP::Post.new(uri)
40
40
  request.body = JSON.generate(params)
41
41
  request["Content-Type"] = "application/json"
42
+ request["Accept"] = "application/json"
42
43
  request["Authorization"] = @auth_header
43
44
 
44
45
  begin
@@ -1,3 +1,3 @@
1
1
  module ActiveMcp
2
- VERSION = "0.10.4"
2
+ VERSION = "0.10.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_mcp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.4
4
+ version: 0.10.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moeki Kawakami
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-04-09 00:00:00.000000000 Z
11
+ date: 2025-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails