Make description and mime_type optional keyword arguments in Resource

This change is related to #29.

According to the specification, both `description` and `mimeType` of Resource are optional:
https://modelcontextprotocol.io/specification/2025-03-26/server/resources#resource

Therefore, it makes sense to treat them as optional keyword arguments,
similar to how this is done in `ResourceTemplate`:
https://github.com/modelcontextprotocol/ruby-sdk/blob/0b49c3/lib/mcp/resource_template.rb#L8

As additional context, the TypeScript SDK also treats them as optional.
https://github.com/modelcontextprotocol/typescript-sdk/blob/1.12.1/src/types.ts#L438-L466
This commit is contained in:
Koichi ITO 2025-05-31 01:24:23 +09:00
commit eb1c93909b

View file

@ -5,7 +5,7 @@ module MCP
class Resource
attr_reader :uri, :name, :description, :mime_type
def initialize(uri:, name:, description:, mime_type:)
def initialize(uri:, name:, description: nil, mime_type: nil)
@uri = uri
@name = name
@description = description