add _meta field to Prompt
> See [General fields: `_meta`](/specification/2025-06-18/basic/index#meta) for notes on `_meta` usage.
51e093b8eb/schema/2025-06-18/schema.ts (L680-L683)
This commit is contained in:
parent
701f6faab6
commit
a1dd3dd005
1 changed files with 67 additions and 4 deletions
|
|
@ -120,6 +120,7 @@ module MCP
|
|||
required: true,
|
||||
),
|
||||
],
|
||||
meta: { foo: "bar" },
|
||||
) do |args, server_context:|
|
||||
content = Content::Text.new(args["test_argument"] + " user: #{server_context[:user_id]}")
|
||||
|
||||
|
|
@ -135,6 +136,10 @@ module MCP
|
|||
assert_equal "mock_prompt", prompt.name_value
|
||||
assert_equal "a mock prompt for testing", prompt.description
|
||||
assert_equal "test_argument", prompt.arguments.first.name
|
||||
assert_equal "Test argument title", prompt.arguments.first.title
|
||||
assert_equal "This is a test argument description", prompt.arguments.first.description
|
||||
assert prompt.arguments.first.required
|
||||
assert_equal({ foo: "bar" }, prompt.meta_value)
|
||||
|
||||
expected = {
|
||||
description: "Hello, world!",
|
||||
|
|
@ -147,5 +152,43 @@ module MCP
|
|||
result = prompt.template({ "test_argument" => "Hello, friend!" }, server_context: { user_id: 123 })
|
||||
assert_equal expected, result.to_h
|
||||
end
|
||||
|
||||
test "#to_h returns a hash with name, title, description, arguments, and meta" do
|
||||
class FullPrompt < Prompt
|
||||
prompt_name "test_prompt"
|
||||
description "Test prompt description"
|
||||
title "Test Prompt title"
|
||||
arguments [
|
||||
Prompt::Argument.new(name: "test_argument", description: "Test argument", required: true),
|
||||
]
|
||||
meta({ test: "meta" })
|
||||
end
|
||||
|
||||
expected = {
|
||||
name: "test_prompt",
|
||||
title: "Test Prompt title",
|
||||
description: "Test prompt description",
|
||||
arguments: [
|
||||
{ name: "test_argument", description: "Test argument", required: true },
|
||||
],
|
||||
_meta: { test: "meta" },
|
||||
}
|
||||
|
||||
assert_equal expected, FullPrompt.to_h
|
||||
end
|
||||
|
||||
test "#to_h handles nil arguments value" do
|
||||
class NoArgumentsPrompt < Prompt
|
||||
description "No arguments prompt"
|
||||
end
|
||||
prompt = NoArgumentsPrompt
|
||||
|
||||
expected = {
|
||||
name: "no_arguments_prompt",
|
||||
description: "No arguments prompt",
|
||||
}
|
||||
|
||||
assert_equal expected, prompt.to_h
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue