diff --git a/README.md b/README.md index 2a3a1304..fc1e1797 100644 --- a/README.md +++ b/README.md @@ -51,11 +51,9 @@ let server = Server( name: "MyServer", version: "1.0.0", capabilities: .init( - prompts: .init(), - resources: .init( - subscribe: true - ), - tools: .init() + prompts: true, + resources: true, + tools: true ) ) diff --git a/Sources/MCP/Client/Client.swift b/Sources/MCP/Client/Client.swift index e910ac8f..8f9fa245 100644 --- a/Sources/MCP/Client/Client.swift +++ b/Sources/MCP/Client/Client.swift @@ -408,3 +408,17 @@ public actor Client { return value } } + +// MARK: - ExpressibleByBooleanLiteral + +extension Client.Capabilities.Roots: ExpressibleByBooleanLiteral { + public init(booleanLiteral value: Bool) { + self.init() + } +} + +extension Client.Capabilities.Sampling: ExpressibleByBooleanLiteral { + public init(booleanLiteral value: Bool) { + self.init() + } +} diff --git a/Sources/MCP/Server/Server.swift b/Sources/MCP/Server/Server.swift index 168b0625..5f07aded 100644 --- a/Sources/MCP/Server/Server.swift +++ b/Sources/MCP/Server/Server.swift @@ -408,3 +408,29 @@ public actor Server { self.isInitialized = true } } + +// MARK: - ExpressibleByBooleanLiteral + +extension Server.Capabilities.Logging: ExpressibleByBooleanLiteral { + public init(booleanLiteral value: Bool) { + self.init() + } +} + +extension Server.Capabilities.Prompts: ExpressibleByBooleanLiteral { + public init(booleanLiteral value: Bool) { + self.init() + } +} + +extension Server.Capabilities.Resources: ExpressibleByBooleanLiteral { + public init(booleanLiteral value: Bool) { + self.init() + } +} + +extension Server.Capabilities.Tools: ExpressibleByBooleanLiteral { + public init(booleanLiteral value: Bool) { + self.init() + } +} diff --git a/Tests/MCPTests/RoundtripTests.swift b/Tests/MCPTests/RoundtripTests.swift index 681c77e9..282794e2 100644 --- a/Tests/MCPTests/RoundtripTests.swift +++ b/Tests/MCPTests/RoundtripTests.swift @@ -34,9 +34,9 @@ struct RoundtripTests { name: "TestServer", version: "1.0.0", capabilities: .init( - prompts: .init(), - resources: .init(), - tools: .init() + prompts: true, + resources: true, + tools: true ) ) await server.withMethodHandler(ListTools.self) { _ in