Skip to content
This repository was archived by the owner on May 29, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion MCPClient/Sources/MCPClientConnection.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Foundation
import JSONRPC
import MCPInterface
import MemberwiseInit

// MARK: - MCPClientConnection

Expand Down
10 changes: 8 additions & 2 deletions MCPClient/Sources/MCPClientInterface.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Foundation
import JSONRPC
import MCPInterface
import MemberwiseInit

// MARK: - MCPClientInterface

Expand Down Expand Up @@ -44,11 +43,18 @@ public protocol MCPClientInterface {
/// Describes the supported capabilities of an MCP client, and how to handle each of the supported ones.
///
/// Note: This is similar to `ClientCapabilities`, with the addition of the handler function.
@MemberwiseInit(.public, _optionalsDefaultNil: true)
public struct ClientCapabilityHandlers {
public let roots: CapabilityHandler<ListChangedCapability, ListRootsRequest.Handler>?
public let sampling: CapabilityHandler<EmptyObject, CreateSamplingMessageRequest.Handler>?
// TODO: add experimental

public init(
roots: CapabilityHandler<ListChangedCapability, ListRootsRequest.Handler>? = nil,
sampling: CapabilityHandler<EmptyObject, CreateSamplingMessageRequest.Handler>? = nil)
{
self.roots = roots
self.sampling = sampling
}
}

// MARK: - MCPClientError
Expand Down
7 changes: 5 additions & 2 deletions MCPInterface/Sources/Interfaces.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Foundation
import JSONRPC
import MemberwiseInit

public typealias Transport = DataChannel

Expand All @@ -15,10 +14,14 @@ public typealias AnyJRPCResponse = Swift.Result<Encodable & Sendable, AnyJSONRPC
// MARK: - CapabilityHandler

/// Describes a capability of a client/server (see `ClientCapabilities` and `ServerCapabilities`), as well as how it is handled.
@MemberwiseInit(.public, _optionalsDefaultNil: true)
public struct CapabilityHandler<Info, Handler> {
public let info: Info
public let handler: Handler

public init(info: Info, handler: Handler) {
self.info = info
self.handler = handler
}
}

extension CapabilityHandler where Info == EmptyObject {
Expand Down
Loading