From 701f6faab6fc75d2739873db55862e927eb61d42 Mon Sep 17 00:00:00 2001 From: Topher Bullock Date: Mon, 6 Oct 2025 09:35:42 -0400 Subject: [PATCH] add `title` field to prompt argument `PromptArgument extends BaseMetadata`, which includes both name and title - https://github.com/modelcontextprotocol/modelcontextprotocol/blob/51e093b8ebfde5e968879024566b7380d30c52d0/schema/2025-06-18/schema.ts#L686-L698 - https://github.com/modelcontextprotocol/modelcontextprotocol/blob/51e093b8ebfde5e968879024566b7380d30c52d0/schema/2025-06-18/schema.ts#L294-l309 --- README.md | 5 ++++- lib/mcp/prompt/argument.rb | 13 +++++++++---- test/mcp/prompt_test.rb | 7 ++++++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ba66f1c..64606e8 100644 --- a/README.md +++ b/README.md @@ -624,6 +624,7 @@ class MyPrompt < MCP::Prompt arguments [ MCP::Prompt::Argument.new( name: "message", + title: "Message Title", description: "Input message", required: true ) @@ -661,6 +662,7 @@ prompt = MCP::Prompt.define( arguments: [ MCP::Prompt::Argument.new( name: "message", + title: "Message Title", description: "Input message", required: true ) @@ -692,6 +694,7 @@ server.define_prompt( arguments: [ Prompt::Argument.new( name: "message", + title: "Message Title", description: "Input message", required: true ) @@ -718,7 +721,7 @@ e.g. around authentication state or user preferences. ### Key Components -- `MCP::Prompt::Argument` - Defines input parameters for the prompt template +- `MCP::Prompt::Argument` - Defines input parameters for the prompt template with name, title, description, and required flag - `MCP::Prompt::Message` - Represents a message in the conversation with a role and content - `MCP::Prompt::Result` - The output of a prompt template containing description and messages - `MCP::Content::Text` - Text content for messages diff --git a/lib/mcp/prompt/argument.rb b/lib/mcp/prompt/argument.rb index 8ec0cb0..336e2b1 100644 --- a/lib/mcp/prompt/argument.rb +++ b/lib/mcp/prompt/argument.rb @@ -3,17 +3,22 @@ module MCP class Prompt class Argument - attr_reader :name, :description, :required, :arguments + attr_reader :name, :title, :description, :required - def initialize(name:, description: nil, required: false) + def initialize(name:, title: nil, description: nil, required: false) @name = name + @title = title @description = description @required = required - @arguments = arguments end def to_h - { name:, description:, required: }.compact + { + name: name, + title: title, + description: description, + required: required, + }.compact end end end diff --git a/test/mcp/prompt_test.rb b/test/mcp/prompt_test.rb index 878fd06..c5853be 100644 --- a/test/mcp/prompt_test.rb +++ b/test/mcp/prompt_test.rb @@ -113,7 +113,12 @@ module MCP title: "Mock Prompt", description: "a mock prompt for testing", arguments: [ - Prompt::Argument.new(name: "test_argument", description: "Test argument", required: true), + Prompt::Argument.new( + name: "test_argument", + title: "Test argument title", + description: "This is a test argument description", + required: true, + ), ], ) do |args, server_context:| content = Content::Text.new(args["test_argument"] + " user: #{server_context[:user_id]}")