fix: allow description field to be absent from Tool (#159)

* fix: allow description field to be absent from `Tool`
* description field is not a requried field of Tool

* Apply suggestions from code review

* Update Tests/MCPTests/ToolTests.swift

---------

Co-authored-by: Mattt <mattt@me.com>
This commit is contained in:
Yifan Liu 2025-09-07 19:30:19 +08:00 • committed by GitHub
commit fb6fffbecd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -182,7 +182,7 @@ public struct Tool: Hashable, Codable, Sendable {
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
name = try container.decode(String.self, forKey: .name)
description = try container.decode(String.self, forKey: .description)
description = try container.decodeIfPresent(String.self, forKey: .description)
inputSchema = try container.decode(Value.self, forKey: .inputSchema)
annotations =
try container.decodeIfPresent(Tool.Annotations.self, forKey: .annotations) ?? .init()