Extract MCP::Annotations into a dedicated file
This PR moves `MCP::Annotations` from lib/mcp.rb to lib/mcp/annotations.rb for better organization, following the pattern used for other classes such as `Tool::Annotations`. This PR also adds the missing `last_modified` attribute to `MCP::Annotations`: https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/2025-11-25/schema.ts#L1701-L1736 It also adds a `to_h` method for serialization and includes comprehensive test coverage. NOTE: This code is unused within the ruby-sdk repository, but it is kept for compatibility, as it may be used by users.
This commit is contained in:
parent
3addc525df
commit
a85fa028f7
2 changed files with 81 additions and 9 deletions
10
lib/mcp.rb
10
lib/mcp.rb
|
|
@ -1,6 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_relative "json_rpc_handler"
|
||||
require_relative "mcp/annotations"
|
||||
require_relative "mcp/configuration"
|
||||
require_relative "mcp/content"
|
||||
require_relative "mcp/icon"
|
||||
|
|
@ -39,13 +40,4 @@ module MCP
|
|||
@configuration ||= Configuration.new
|
||||
end
|
||||
end
|
||||
|
||||
class Annotations
|
||||
attr_reader :audience, :priority
|
||||
|
||||
def initialize(audience: nil, priority: nil)
|
||||
@audience = audience
|
||||
@priority = priority
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
21
lib/mcp/annotations.rb
Normal file
21
lib/mcp/annotations.rb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module MCP
|
||||
class Annotations
|
||||
attr_reader :audience, :priority, :last_modified
|
||||
|
||||
def initialize(audience: nil, priority: nil, last_modified: nil)
|
||||
@audience = audience
|
||||
@priority = priority
|
||||
@last_modified = last_modified
|
||||
end
|
||||
|
||||
def to_h
|
||||
{
|
||||
audience: audience,
|
||||
priority: priority,
|
||||
lastModified: last_modified,
|
||||
}.compact
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue