fix compilation (#1)
This commit is contained in:
parent
62d2b2839d
commit
9e71ab0b21
3 changed files with 26 additions and 26 deletions
|
|
@ -179,7 +179,7 @@ abstract class GenerateLibVersionTask @Inject constructor(
|
||||||
"""
|
"""
|
||||||
package org.jetbrains.kotlinx.mcp
|
package org.jetbrains.kotlinx.mcp
|
||||||
|
|
||||||
const val LIB_VERSION = "$libVersion"
|
public const val LIB_VERSION: String = "$libVersion"
|
||||||
|
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -32,22 +32,22 @@ public class ServerOptions(
|
||||||
* @param options Configuration options for the server.
|
* @param options Configuration options for the server.
|
||||||
* @param onCloseCallback A callback invoked when the server connection closes.
|
* @param onCloseCallback A callback invoked when the server connection closes.
|
||||||
*/
|
*/
|
||||||
open class Server(
|
public open class Server(
|
||||||
private val serverInfo: Implementation,
|
private val serverInfo: Implementation,
|
||||||
options: ServerOptions,
|
options: ServerOptions,
|
||||||
var onCloseCallback: (() -> Unit)? = null
|
public var onCloseCallback: (() -> Unit)? = null
|
||||||
) : Protocol<ServerRequest, ServerNotification, ServerResult>(options) {
|
) : Protocol<ServerRequest, ServerNotification, ServerResult>(options) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The client's reported capabilities after initialization.
|
* The client's reported capabilities after initialization.
|
||||||
*/
|
*/
|
||||||
var clientCapabilities: ClientCapabilities? = null
|
public var clientCapabilities: ClientCapabilities? = null
|
||||||
private set
|
private set
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The client's version information after initialization.
|
* The client's version information after initialization.
|
||||||
*/
|
*/
|
||||||
var clientVersion: Implementation? = null
|
public var clientVersion: Implementation? = null
|
||||||
private set
|
private set
|
||||||
private val capabilities: ServerCapabilities = options.capabilities
|
private val capabilities: ServerCapabilities = options.capabilities
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ open class Server(
|
||||||
* A callback invoked when the server has completed the initialization sequence.
|
* A callback invoked when the server has completed the initialization sequence.
|
||||||
* After initialization, the server is ready to handle requests.
|
* After initialization, the server is ready to handle requests.
|
||||||
*/
|
*/
|
||||||
var onInitialized: (() -> Unit)? = null
|
public var onInitialized: (() -> Unit)? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
logger.debug { "Initializing MCP server with capabilities: $capabilities" }
|
logger.debug { "Initializing MCP server with capabilities: $capabilities" }
|
||||||
|
|
@ -125,7 +125,7 @@ open class Server(
|
||||||
* @param handler A suspend function that handles executing the tool when called by the client.
|
* @param handler A suspend function that handles executing the tool when called by the client.
|
||||||
* @throws IllegalStateException If the server does not support tools.
|
* @throws IllegalStateException If the server does not support tools.
|
||||||
*/
|
*/
|
||||||
fun addTool(
|
public fun addTool(
|
||||||
name: String,
|
name: String,
|
||||||
description: String,
|
description: String,
|
||||||
inputSchema: Tool.Input = Tool.Input(),
|
inputSchema: Tool.Input = Tool.Input(),
|
||||||
|
|
@ -145,7 +145,7 @@ open class Server(
|
||||||
* @param toolsToAdd A list of [RegisteredTool] objects representing the tools to register.
|
* @param toolsToAdd A list of [RegisteredTool] objects representing the tools to register.
|
||||||
* @throws IllegalStateException If the server does not support tools.
|
* @throws IllegalStateException If the server does not support tools.
|
||||||
*/
|
*/
|
||||||
fun addTools(toolsToAdd: List<RegisteredTool>) {
|
public fun addTools(toolsToAdd: List<RegisteredTool>) {
|
||||||
if (capabilities.tools == null) {
|
if (capabilities.tools == null) {
|
||||||
logger.error { "Failed to add tools: Server does not support tools capability" }
|
logger.error { "Failed to add tools: Server does not support tools capability" }
|
||||||
throw IllegalStateException("Server does not support tools capability.")
|
throw IllegalStateException("Server does not support tools capability.")
|
||||||
|
|
@ -164,7 +164,7 @@ open class Server(
|
||||||
* @param promptProvider A suspend function that returns the prompt content when requested by the client.
|
* @param promptProvider A suspend function that returns the prompt content when requested by the client.
|
||||||
* @throws IllegalStateException If the server does not support prompts.
|
* @throws IllegalStateException If the server does not support prompts.
|
||||||
*/
|
*/
|
||||||
fun addPrompt(prompt: Prompt, promptProvider: suspend (GetPromptRequest) -> GetPromptResult) {
|
public fun addPrompt(prompt: Prompt, promptProvider: suspend (GetPromptRequest) -> GetPromptResult) {
|
||||||
if (capabilities.prompts == null) {
|
if (capabilities.prompts == null) {
|
||||||
logger.error { "Failed to add prompt '${prompt.name}': Server does not support prompts capability" }
|
logger.error { "Failed to add prompt '${prompt.name}': Server does not support prompts capability" }
|
||||||
throw IllegalStateException("Server does not support prompts capability.")
|
throw IllegalStateException("Server does not support prompts capability.")
|
||||||
|
|
@ -182,7 +182,7 @@ open class Server(
|
||||||
* @param promptProvider A suspend function that returns the prompt content when requested.
|
* @param promptProvider A suspend function that returns the prompt content when requested.
|
||||||
* @throws IllegalStateException If the server does not support prompts.
|
* @throws IllegalStateException If the server does not support prompts.
|
||||||
*/
|
*/
|
||||||
fun addPrompt(
|
public fun addPrompt(
|
||||||
name: String,
|
name: String,
|
||||||
description: String? = null,
|
description: String? = null,
|
||||||
arguments: List<PromptArgument>? = null,
|
arguments: List<PromptArgument>? = null,
|
||||||
|
|
@ -198,7 +198,7 @@ open class Server(
|
||||||
* @param promptsToAdd A list of [RegisteredPrompt] objects representing the prompts to register.
|
* @param promptsToAdd A list of [RegisteredPrompt] objects representing the prompts to register.
|
||||||
* @throws IllegalStateException If the server does not support prompts.
|
* @throws IllegalStateException If the server does not support prompts.
|
||||||
*/
|
*/
|
||||||
fun addPrompts(promptsToAdd: List<RegisteredPrompt>) {
|
public fun addPrompts(promptsToAdd: List<RegisteredPrompt>) {
|
||||||
if (capabilities.prompts == null) {
|
if (capabilities.prompts == null) {
|
||||||
logger.error { "Failed to add prompts: Server does not support prompts capability" }
|
logger.error { "Failed to add prompts: Server does not support prompts capability" }
|
||||||
throw IllegalStateException("Server does not support prompts capability.")
|
throw IllegalStateException("Server does not support prompts capability.")
|
||||||
|
|
@ -220,7 +220,7 @@ open class Server(
|
||||||
* @param readHandler A suspend function that returns the resource content when read by the client.
|
* @param readHandler A suspend function that returns the resource content when read by the client.
|
||||||
* @throws IllegalStateException If the server does not support resources.
|
* @throws IllegalStateException If the server does not support resources.
|
||||||
*/
|
*/
|
||||||
fun addResource(
|
public fun addResource(
|
||||||
uri: String,
|
uri: String,
|
||||||
name: String,
|
name: String,
|
||||||
description: String,
|
description: String,
|
||||||
|
|
@ -241,7 +241,7 @@ open class Server(
|
||||||
* @param resourcesToAdd A list of [RegisteredResource] objects representing the resources to register.
|
* @param resourcesToAdd A list of [RegisteredResource] objects representing the resources to register.
|
||||||
* @throws IllegalStateException If the server does not support resources.
|
* @throws IllegalStateException If the server does not support resources.
|
||||||
*/
|
*/
|
||||||
fun addResources(resourcesToAdd: List<RegisteredResource>) {
|
public fun addResources(resourcesToAdd: List<RegisteredResource>) {
|
||||||
if (capabilities.resources == null) {
|
if (capabilities.resources == null) {
|
||||||
logger.error { "Failed to add resources: Server does not support resources capability" }
|
logger.error { "Failed to add resources: Server does not support resources capability" }
|
||||||
throw IllegalStateException("Server does not support resources capability.")
|
throw IllegalStateException("Server does not support resources capability.")
|
||||||
|
|
@ -259,7 +259,7 @@ open class Server(
|
||||||
* @return The result of the ping request.
|
* @return The result of the ping request.
|
||||||
* @throws IllegalStateException If for some reason the method is not supported or the connection is closed.
|
* @throws IllegalStateException If for some reason the method is not supported or the connection is closed.
|
||||||
*/
|
*/
|
||||||
suspend fun ping(): EmptyRequestResult {
|
public suspend fun ping(): EmptyRequestResult {
|
||||||
return request<EmptyRequestResult>(PingRequest())
|
return request<EmptyRequestResult>(PingRequest())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -271,7 +271,7 @@ open class Server(
|
||||||
* @return The created message result.
|
* @return The created message result.
|
||||||
* @throws IllegalStateException If the server does not support sampling or if the request fails.
|
* @throws IllegalStateException If the server does not support sampling or if the request fails.
|
||||||
*/
|
*/
|
||||||
suspend fun createMessage(
|
public suspend fun createMessage(
|
||||||
params: CreateMessageRequest,
|
params: CreateMessageRequest,
|
||||||
options: RequestOptions? = null
|
options: RequestOptions? = null
|
||||||
): CreateMessageResult {
|
): CreateMessageResult {
|
||||||
|
|
@ -287,7 +287,7 @@ open class Server(
|
||||||
* @return The list of roots.
|
* @return The list of roots.
|
||||||
* @throws IllegalStateException If the server or client does not support roots.
|
* @throws IllegalStateException If the server or client does not support roots.
|
||||||
*/
|
*/
|
||||||
suspend fun listRoots(
|
public suspend fun listRoots(
|
||||||
params: JsonObject = EmptyJsonObject,
|
params: JsonObject = EmptyJsonObject,
|
||||||
options: RequestOptions? = null
|
options: RequestOptions? = null
|
||||||
): ListRootsResult {
|
): ListRootsResult {
|
||||||
|
|
@ -300,7 +300,7 @@ open class Server(
|
||||||
*
|
*
|
||||||
* @param params The logging message notification parameters.
|
* @param params The logging message notification parameters.
|
||||||
*/
|
*/
|
||||||
suspend fun sendLoggingMessage(params: LoggingMessageNotification) {
|
public suspend fun sendLoggingMessage(params: LoggingMessageNotification) {
|
||||||
logger.trace { "Sending logging message: ${params.data}" }
|
logger.trace { "Sending logging message: ${params.data}" }
|
||||||
notification(params)
|
notification(params)
|
||||||
}
|
}
|
||||||
|
|
@ -310,7 +310,7 @@ open class Server(
|
||||||
*
|
*
|
||||||
* @param params Details of the updated resource.
|
* @param params Details of the updated resource.
|
||||||
*/
|
*/
|
||||||
suspend fun sendResourceUpdated(params: ResourceUpdatedNotification) {
|
public suspend fun sendResourceUpdated(params: ResourceUpdatedNotification) {
|
||||||
logger.debug { "Sending resource updated notification for: ${params.uri}" }
|
logger.debug { "Sending resource updated notification for: ${params.uri}" }
|
||||||
notification(params)
|
notification(params)
|
||||||
}
|
}
|
||||||
|
|
@ -318,7 +318,7 @@ open class Server(
|
||||||
/**
|
/**
|
||||||
* Sends a notification to the client indicating that the list of resources has changed.
|
* Sends a notification to the client indicating that the list of resources has changed.
|
||||||
*/
|
*/
|
||||||
suspend fun sendResourceListChanged() {
|
public suspend fun sendResourceListChanged() {
|
||||||
logger.debug { "Sending resource list changed notification" }
|
logger.debug { "Sending resource list changed notification" }
|
||||||
notification(ResourceListChangedNotification())
|
notification(ResourceListChangedNotification())
|
||||||
}
|
}
|
||||||
|
|
@ -326,7 +326,7 @@ open class Server(
|
||||||
/**
|
/**
|
||||||
* Sends a notification to the client indicating that the list of tools has changed.
|
* Sends a notification to the client indicating that the list of tools has changed.
|
||||||
*/
|
*/
|
||||||
suspend fun sendToolListChanged() {
|
public suspend fun sendToolListChanged() {
|
||||||
logger.debug { "Sending tool list changed notification" }
|
logger.debug { "Sending tool list changed notification" }
|
||||||
notification(ToolListChangedNotification())
|
notification(ToolListChangedNotification())
|
||||||
}
|
}
|
||||||
|
|
@ -334,7 +334,7 @@ open class Server(
|
||||||
/**
|
/**
|
||||||
* Sends a notification to the client indicating that the list of prompts has changed.
|
* Sends a notification to the client indicating that the list of prompts has changed.
|
||||||
*/
|
*/
|
||||||
suspend fun sendPromptListChanged() {
|
public suspend fun sendPromptListChanged() {
|
||||||
logger.debug { "Sending prompt list changed notification" }
|
logger.debug { "Sending prompt list changed notification" }
|
||||||
notification(PromptListChangedNotification())
|
notification(PromptListChangedNotification())
|
||||||
}
|
}
|
||||||
|
|
@ -543,7 +543,7 @@ open class Server(
|
||||||
* @property tool The tool definition.
|
* @property tool The tool definition.
|
||||||
* @property handler A suspend function to handle the tool call requests.
|
* @property handler A suspend function to handle the tool call requests.
|
||||||
*/
|
*/
|
||||||
data class RegisteredTool(
|
public data class RegisteredTool(
|
||||||
val tool: Tool,
|
val tool: Tool,
|
||||||
val handler: suspend (CallToolRequest) -> CallToolResult
|
val handler: suspend (CallToolRequest) -> CallToolResult
|
||||||
)
|
)
|
||||||
|
|
@ -554,7 +554,7 @@ data class RegisteredTool(
|
||||||
* @property prompt The prompt definition.
|
* @property prompt The prompt definition.
|
||||||
* @property messageProvider A suspend function that returns the prompt content when requested by the client.
|
* @property messageProvider A suspend function that returns the prompt content when requested by the client.
|
||||||
*/
|
*/
|
||||||
data class RegisteredPrompt(
|
public data class RegisteredPrompt(
|
||||||
val prompt: Prompt,
|
val prompt: Prompt,
|
||||||
val messageProvider: suspend (GetPromptRequest) -> GetPromptResult
|
val messageProvider: suspend (GetPromptRequest) -> GetPromptResult
|
||||||
)
|
)
|
||||||
|
|
@ -565,7 +565,7 @@ data class RegisteredPrompt(
|
||||||
* @property resource The resource definition.
|
* @property resource The resource definition.
|
||||||
* @property readHandler A suspend function to handle read requests for this resource.
|
* @property readHandler A suspend function to handle read requests for this resource.
|
||||||
*/
|
*/
|
||||||
data class RegisteredResource(
|
public data class RegisteredResource(
|
||||||
val resource: Resource,
|
val resource: Resource,
|
||||||
val readHandler: suspend (ReadResourceRequest) -> ReadResourceResult
|
val readHandler: suspend (ReadResourceRequest) -> ReadResourceResult
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -527,14 +527,14 @@ public open class Progress(
|
||||||
* An out-of-band notification used to inform the receiver of a progress update for a long-running request.
|
* An out-of-band notification used to inform the receiver of a progress update for a long-running request.
|
||||||
*/
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
data class ProgressNotification(
|
public data class ProgressNotification(
|
||||||
override val progress: Int,
|
override val progress: Int,
|
||||||
/**
|
/**
|
||||||
* The progress token,
|
* The progress token,
|
||||||
* which was given in the initial request,
|
* which was given in the initial request,
|
||||||
* used to associate this notification with the request that is proceeding.
|
* used to associate this notification with the request that is proceeding.
|
||||||
*/
|
*/
|
||||||
val progressToken: ProgressToken,
|
public val progressToken: ProgressToken,
|
||||||
@Suppress("PropertyName") val _meta: JsonObject = EmptyJsonObject,
|
@Suppress("PropertyName") val _meta: JsonObject = EmptyJsonObject,
|
||||||
override val total: Double?,
|
override val total: Double?,
|
||||||
) : ClientNotification, ServerNotification, ProgressBase {
|
) : ClientNotification, ServerNotification, ProgressBase {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue