Skip to content

Add plumbing to set instructions on Server #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 10, 2025
Merged
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
12 changes: 11 additions & 1 deletion Sources/MCP/Server/Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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] = [:]
Expand All @@ -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
Expand Down Expand Up @@ -574,7 +584,7 @@ public actor Server {
protocolVersion: negotiatedProtocolVersion,
capabilities: await self.capabilities,
serverInfo: self.serverInfo,
instructions: nil
instructions: self.instructions
)
}

Expand Down
Loading