Remove nonstandard read and list capabilities for resources (#15)

* Remove nonstandard read and list capabilities for server

* Update README
This commit is contained in:
Mattt 2025-03-17 04:17:23 -07:00 • committed by GitHub
commit a2a0044abb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 74 additions and 14 deletions

View file

@ -313,7 +313,7 @@ public actor Client {
// MARK: - Resources
public func readResource(uri: String) async throws -> [Resource.Content] {
_ = try checkCapability(\.resources?.read, "Resource reading")
_ = try checkCapability(\.resources, "Resources")
let request = ReadResource.request(.init(uri: uri))
let result = try await send(request)
return result.contents
@ -322,7 +322,7 @@ public actor Client {
public func listResources(cursor: String? = nil) async throws -> (
resources: [Resource], nextCursor: String?
) {
_ = try checkCapability(\.resources?.list, "Resource listing")
_ = try checkCapability(\.resources, "Resources")
let request = ListResources.request(.init(cursor: cursor))
let result = try await send(request)
return (resources: result.resources, nextCursor: result.nextCursor)

View file

@ -44,23 +44,15 @@ public actor Server {
public struct Capabilities: Hashable, Codable, Sendable {
/// Resources capabilities
public struct Resources: Hashable, Codable, Sendable {
/// Whether the list of resources has changed
public var list: Bool?
/// Whether the resource can be read
public var read: Bool?
/// Whether the resource can be subscribed to
public var subscribe: Bool?
/// Whether the list of resources has changed
public var listChanged: Bool?
public init(
list: Bool? = nil,
read: Bool? = nil,
subscribe: Bool? = nil,
listChanged: Bool? = nil
) {
self.list = list
self.read = read
self.subscribe = subscribe
self.listChanged = listChanged
}