Remove nonstandard read and list capabilities for resources (#15)
* Remove nonstandard read and list capabilities for server * Update README
This commit is contained in:
parent
dccaa3a411
commit
a2a0044abb
2 changed files with 74 additions and 14 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue