* Support 2025-06-18 Spec (#167) * Support OpenAI _meta for Tool * Update init * Add title and outputSchema * Concurreny issue * General fields * Add Generate Fields to Server elements * 4 tab spacing * Update Version * Elicitation * Format * More tests and inits * Elicitation in README * Fix orphaned test * Add title to more structs * Public init * Fix meta validation and make tests more generic * Format and make Result properties public again * Revert more visibility changes * feat: 2025-11-25 phase 1, includes Version, Icon, Progress (#181) * chore: fixed unit tests * feat: added icon and progess base structs * feat: added progress notification and meta to callTool * feat: added tests * feat: simplified RequestMeta encoding/decoding * tests: added unit test to track progress * chore: rebased v0.11.x * feat: implemented cancellation * feat: added overloaded callTool method * fix: encoding Response _meta fix * chore: added old version to the versions list * feat: 2025-11-25 phase 2; added Logging and Completions (#196) * feat: added Logging and Completions * feat: updated EmbeddedResource for the latest spec * chore: changed encoding of meta in Prompts to encodeIfPresent * feat: compliance tests + http server transport (#197) * feat: http server transport * feat: added http server transport * feat: removed unused files * feat: added conformance tests * feat: improved conformace testing * chore: removed redundant files * feat/2025-11-25: sampling, elicitation, roots (#198) * feat: Roots implementation * feat: added unit testing * feat: improved unit tests and fixed NetworkTransport crash * feat: implemented sampling and elicitation * feat: improved sampling tests * feat: improved elicitation tests * feat: improved confirmance tests * feat: improved Prompts unit tests * feat: removed test code * feat: updated conformance tests * chore: removed redundant commas * chore: removed 6.0.3 swift version from ci * chore: improved unit tests a little bit * chore: update README.md * chore: add server progress tracking example to README.md * chore: updated README.md * chore: updated transports table formatting * chore: updated MockNetworkConnection --------- Co-authored-by: Austin Evans <austinjevans@me.com> Co-authored-by: yehorsobko <yehorsobko@macpaw.com>
72 lines
2.3 KiB
Swift
72 lines
2.3 KiB
Swift
import Foundation
|
|
|
|
/// The Model Context Protocol (MCP) provides a standardized way for servers to send
|
|
/// structured log messages to clients. Clients can control logging verbosity by setting
|
|
/// minimum log levels, with servers sending notifications containing severity levels,
|
|
/// optional logger names, and arbitrary JSON-serializable data.
|
|
///
|
|
/// - SeeAlso: https://modelcontextprotocol.io/specification/2025-11-25/server/utilities/logging/
|
|
public enum LogLevel: String, Hashable, Codable, Sendable, CaseIterable {
|
|
/// Detailed debugging information
|
|
case debug
|
|
/// General informational messages
|
|
case info
|
|
/// Normal but significant events
|
|
case notice
|
|
/// Warning conditions
|
|
case warning
|
|
/// Error conditions
|
|
case error
|
|
/// Critical conditions
|
|
case critical
|
|
/// Action must be taken immediately
|
|
case alert
|
|
/// System is unusable
|
|
case emergency
|
|
}
|
|
|
|
// MARK: - Set Log Level
|
|
|
|
/// To configure the minimum log level, clients MAY send a `logging/setLevel` request.
|
|
/// - SeeAlso: https://modelcontextprotocol.io/specification/2025-11-25/server/utilities/logging/
|
|
public enum SetLoggingLevel: Method {
|
|
public static let name = "logging/setLevel"
|
|
|
|
public struct Parameters: Hashable, Codable, Sendable {
|
|
/// The minimum log level to set
|
|
public let level: LogLevel
|
|
|
|
public init(level: LogLevel) {
|
|
self.level = level
|
|
}
|
|
}
|
|
|
|
public typealias Result = Empty
|
|
}
|
|
|
|
// MARK: - Log Message Notification
|
|
|
|
/// Servers send log messages using `notifications/message` notifications.
|
|
/// - SeeAlso: https://modelcontextprotocol.io/specification/2025-11-25/server/utilities/logging/
|
|
public struct LogMessageNotification: Notification {
|
|
public static let name = "notifications/message"
|
|
|
|
public struct Parameters: Hashable, Codable, Sendable {
|
|
/// The severity level of the log message
|
|
public let level: LogLevel
|
|
/// Optional logger name to identify the source
|
|
public let logger: String?
|
|
/// Arbitrary JSON-serializable data for the log message
|
|
public let data: Value
|
|
|
|
public init(
|
|
level: LogLevel,
|
|
logger: String? = nil,
|
|
data: Value
|
|
) {
|
|
self.level = level
|
|
self.logger = logger
|
|
self.data = data
|
|
}
|
|
}
|
|
}
|