active_mcp 0.10.0 → 0.10.1

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: 40c074a297950ebddab382dabdb7e373e3aeebf5e11017bd40f6dea597ca7215
4
- data.tar.gz: 72ac9984228f99aa5a787e09af86b144a1f66837b1eadb38c6b857be8d455416
3
+ metadata.gz: b553c506022715ad2f57af006408ab14b08167505efd4aac1fc0bb08ffdde6c4
4
+ data.tar.gz: b6c2818a416c3da6021e04a8852e08820f757a33cba12b4ca88e7d0ad212caa5
5
5
  SHA512:
6
- metadata.gz: 984057ffb2c91a788e0c69e19101a98aae9a6b526471e346cb4fc5151f0a978aaa454eb1ab6ed4e4c9e598c55e074027212214e19c37187c288a2d35621a84c5
7
- data.tar.gz: c046c53ec3523d3f800fbd8350fe44233ddd13218ff72022f5367e0b15062774e40de789644f609a56cc5e1e163f9a1d8ceb80d915d695dd96fec183f1bd9857
6
+ metadata.gz: f022889f1b6dba59d4fe68586d102cd6671948e8b402e8ebcf268fa68d2a6c45b1f8cfaecc097e70499f941d9e432e8efd53c25637ce480a6b4b45f4dfb5a294
7
+ data.tar.gz: 5c9293d59c6d9f2f66d756baa505daaec323108b5921e761502894a54bdb008e879441ba873f0cae57b4813bdd741d50310fcce92af4656875176fbf2f2bf54d
data/README.md CHANGED
@@ -38,6 +38,7 @@ A Ruby on Rails engine for the [Model Context Protocol (MCP)](https://modelconte
38
38
  - [Creating Resource Templates](#creating-resource-templates)
39
39
  - [💬 MCP Prompts](#-mcp-prompts)
40
40
  - [Creating Prompt](#creating-prompt)
41
+ - [📥 Using Context in the Schema](#-using-context-in-the-schema)
41
42
  - [💡 Best Practices](#-best-practices)
42
43
  - [1. Create Specific Tool Classes](#1-create-specific-tool-classes)
43
44
  - [2. Validate and Sanitize Inputs](#2-validate-and-sanitize-inputs)
@@ -527,7 +528,7 @@ Resources are Ruby classes `**Prompt`:
527
528
 
528
529
  ```ruby
529
530
  class HelloPrompt < ActiveMcp::Prompt::Base
530
- argument :name, ->(value) do
531
+ argument :name, required: true, description: "User name", complete: ->(value) do
531
532
  User.all.pluck(:name).filter { _1.match(value) }
532
533
  end
533
534
 
@@ -582,6 +583,36 @@ class MySchema < ActiveMcp::Schema::Base
582
583
  end
583
584
  ```
584
585
 
586
+ ## 📥 Using Context in the Schema
587
+
588
+ ```ruby
589
+ class MySchema < ActiveMcp::Schema::Base
590
+ def prompts
591
+ user = User.find_by_token(context[:auth_info][:token])
592
+
593
+ user.greetings.map do |greeting|
594
+ GreetingPrompt.new(greeting: greeting)
595
+ end
596
+ end
597
+ end
598
+ ```
599
+
600
+ ```ruby
601
+ class GreetingPrompt < ActiveMcp::Prompt::Base
602
+ def initialize(greeting:)
603
+ @greeting = greeting
604
+ end
605
+
606
+ def prompt_name
607
+ "greeting_#{@greeting.text}"
608
+ end
609
+
610
+ def messages
611
+ # ...
612
+ end
613
+ end
614
+ ```
615
+
585
616
  ## 💡 Best Practices
586
617
 
587
618
  ### 1. Create Specific Tool Classes
@@ -4,7 +4,7 @@ module ActiveMcp
4
4
  class << self
5
5
  attr_reader :arguments
6
6
 
7
- def argument(name, required: false, description: nil, complete: -> {})
7
+ def argument(name, required: false, description: "", complete: -> {})
8
8
  @arguments ||= []
9
9
 
10
10
  @arguments << {
@@ -6,7 +6,7 @@ module ActiveMcp
6
6
  class << self
7
7
  attr_reader :schema
8
8
 
9
- def argument(name, type, required: false, description: nil)
9
+ def argument(name, type, required: false, description: "")
10
10
  @schema ||= default_schema
11
11
 
12
12
  @schema["properties"][name.to_s] = {"type" => type.to_s}
@@ -1,3 +1,3 @@
1
1
  module ActiveMcp
2
- VERSION = "0.10.0"
2
+ VERSION = "0.10.1"
3
3
  end
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.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moeki Kawakami