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 +4 -4
- data/README.md +32 -1
- data/lib/active_mcp/prompt/base.rb +1 -1
- data/lib/active_mcp/tool/base.rb +1 -1
- data/lib/active_mcp/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: b553c506022715ad2f57af006408ab14b08167505efd4aac1fc0bb08ffdde6c4
|
4
|
+
data.tar.gz: b6c2818a416c3da6021e04a8852e08820f757a33cba12b4ca88e7d0ad212caa5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/active_mcp/tool/base.rb
CHANGED
@@ -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:
|
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}
|
data/lib/active_mcp/version.rb
CHANGED