From e2afccdcaa1a1fea1340288956a77ca366da8b2c Mon Sep 17 00:00:00 2001 From: Glacio <125524735+glaciotech@users.noreply.github.com> Date: Sun, 10 Aug 2025 07:52:28 -0500 Subject: [PATCH] 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 Co-authored-by: Mattt --- Sources/MCP/Server/Server.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Sources/MCP/Server/Server.swift b/Sources/MCP/Server/Server.swift index 868e010..6ba1e27 100644 --- a/Sources/MCP/Server/Server.swift +++ b/Sources/MCP/Server/Server.swift @@ -128,10 +128,18 @@ public actor Server { public nonisolated var name: String { serverInfo.name } /// The server 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 public var capabilities: Capabilities /// The server configuration public var configuration: Configuration + /// Request handlers private var methodHandlers: [String: RequestHandlerBox] = [:] @@ -154,12 +162,14 @@ public actor Server { public init( name: String, version: String, + instructions: String? = nil, capabilities: Server.Capabilities = .init(), configuration: Configuration = .default ) { self.serverInfo = Server.Info(name: name, version: version) self.capabilities = capabilities self.configuration = configuration + self.instructions = instructions } /// Start the server @@ -574,7 +584,7 @@ public actor Server { protocolVersion: negotiatedProtocolVersion, capabilities: await self.capabilities, serverInfo: self.serverInfo, - instructions: nil + instructions: self.instructions ) }