Adds 'instructions' string to the Server and propagates to the InitializeResult (#290)

<!-- Provide a brief summary of your changes -->

## Motivation and Context
The
[schema](cca15204f6/schema/2025-03-26/schema.ts (L192))
for the InitializeResult contains an optional 'instructions' string

## Additional context
The instructions string is included in the schema for for version
"2025-03-26"

The instructions in the Server class are given as a provider function
with the result of the provider propagated to the underlying
ServerSession. As the ServerSession change is meant to allow for a
'Singleton scoped' server class, this provides the ability to
dynamically modify the instructions at the server level but have them be
immutable per session.
 
This also refactors the `serverInfo` and `instructions` properties to be
protected. This `Server` class is open and meant to be overridden, there
is no harm in having these immutable properties available to subclasses.

This adds the serverInstructions to the client as returned from the
InitializeResult. This is used to verify the response in the Server
tests.
This commit is contained in:
Jeff Clyne 2025-10-03 11:12:37 -05:00 • committed by GitHub
commit 2f1b659efd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -91,6 +91,14 @@ public open class Client(private val clientInfo: Implementation, options: Client
public var serverCapabilities: ServerCapabilities? = null
private set
/**
* Optional human-readable instructions or description from the server.
*
* @return Instructions provided by the server, or `null` if none were given or initialization is not yet complete.
*/
public var serverInstructions: String? = null
private set
/**
* Retrieves the server's reported version information after initialization.
*
@ -154,6 +162,7 @@ public open class Client(private val clientInfo: Implementation, options: Client
serverCapabilities = result.capabilities
serverVersion = result.serverInfo
serverInstructions = result.instructions
notification(InitializedNotification())
} catch (error: Throwable) {