Add plumbing to set instructions on Server (#145)
* Add plumbing to set instructions on Server * Use instructions description from MCP schema --------- Co-authored-by: Peter Liddle <development.peter@liddle.network> Co-authored-by: Mattt <mattt@me.com>
This commit is contained in:
parent
63fd276dbd
commit
e2afccdcaa
1 changed files with 11 additions and 1 deletions
|
|
@ -128,10 +128,18 @@ public actor Server {
|
||||||
public nonisolated var name: String { serverInfo.name }
|
public nonisolated var name: String { serverInfo.name }
|
||||||
/// The server version
|
/// The server version
|
||||||
public nonisolated var version: String { serverInfo.version }
|
public nonisolated var version: String { serverInfo.version }
|
||||||
|
/// Instructions describing how to use the server and its features
|
||||||
|
///
|
||||||
|
/// This can be used by clients to improve the LLM's understanding of
|
||||||
|
/// available tools, resources, etc.
|
||||||
|
/// It can be thought of like a "hint" to the model.
|
||||||
|
/// For example, this information MAY be added to the system prompt.
|
||||||
|
public nonisolated let instructions: String?
|
||||||
/// The server capabilities
|
/// The server capabilities
|
||||||
public var capabilities: Capabilities
|
public var capabilities: Capabilities
|
||||||
/// The server configuration
|
/// The server configuration
|
||||||
public var configuration: Configuration
|
public var configuration: Configuration
|
||||||
|
|
||||||
|
|
||||||
/// Request handlers
|
/// Request handlers
|
||||||
private var methodHandlers: [String: RequestHandlerBox] = [:]
|
private var methodHandlers: [String: RequestHandlerBox] = [:]
|
||||||
|
|
@ -154,12 +162,14 @@ public actor Server {
|
||||||
public init(
|
public init(
|
||||||
name: String,
|
name: String,
|
||||||
version: String,
|
version: String,
|
||||||
|
instructions: String? = nil,
|
||||||
capabilities: Server.Capabilities = .init(),
|
capabilities: Server.Capabilities = .init(),
|
||||||
configuration: Configuration = .default
|
configuration: Configuration = .default
|
||||||
) {
|
) {
|
||||||
self.serverInfo = Server.Info(name: name, version: version)
|
self.serverInfo = Server.Info(name: name, version: version)
|
||||||
self.capabilities = capabilities
|
self.capabilities = capabilities
|
||||||
self.configuration = configuration
|
self.configuration = configuration
|
||||||
|
self.instructions = instructions
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Start the server
|
/// Start the server
|
||||||
|
|
@ -574,7 +584,7 @@ public actor Server {
|
||||||
protocolVersion: negotiatedProtocolVersion,
|
protocolVersion: negotiatedProtocolVersion,
|
||||||
capabilities: await self.capabilities,
|
capabilities: await self.capabilities,
|
||||||
serverInfo: self.serverInfo,
|
serverInfo: self.serverInfo,
|
||||||
instructions: nil
|
instructions: self.instructions
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue