docs: add missing KDoc comments for public functions, properties, and classes (#621)

This commit is contained in:
Konstantin Pavlov 2026-03-26 18:25:13 +02:00 • committed by GitHub
commit bd4cf0c948
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 21 additions and 0 deletions

View file

@ -16,6 +16,7 @@ public class ReadBuffer {
private val buffer: Buffer = Buffer()
/** Appends raw bytes to the internal buffer for subsequent message parsing. */
public fun append(chunk: ByteArray) {
buffer.write(chunk)
}
@ -86,6 +87,7 @@ public class ReadBuffer {
}
}
/** Clears all buffered data, discarding any partially received messages. */
public fun clear() {
buffer.clear()
}
@ -93,4 +95,5 @@ public class ReadBuffer {
internal fun deserializeMessage(line: String): JSONRPCMessage = McpJson.decodeFromString<JSONRPCMessage>(line)
/** Serializes a [JSONRPCMessage] to its JSON string representation with a trailing newline. */
public fun serializeMessage(message: JSONRPCMessage): String = McpJson.encodeToString(message) + "\n"

View file

@ -171,6 +171,7 @@ public class ClientCapabilitiesBuilder @PublishedApi internal constructor() {
*/
public fun experimental(block: JsonObjectBuilder.() -> Unit): Unit = experimental(buildJsonObject(block))
/** Constructs the [ClientCapabilities] instance from the current builder state. */
@PublishedApi
internal fun build(): ClientCapabilities = ClientCapabilities(
sampling = sampling,

View file

@ -41,8 +41,10 @@ public sealed interface WithMeta {
*/
public typealias ProgressToken = RequestId
/** Creates a [ProgressToken] from a string value. */
public fun ProgressToken(value: String): ProgressToken = RequestId(value)
/** Creates a [ProgressToken] from a numeric value. */
public fun ProgressToken(value: Long): ProgressToken = RequestId(value)
// ============================================================================
@ -127,6 +129,7 @@ public sealed interface Reference {
public val type: ReferenceType
}
/** Discriminator for [Reference] subtypes used in completion and other operations. */
@Serializable
public enum class ReferenceType(public val value: String) {
@SerialName("ref/prompt")

View file

@ -88,6 +88,7 @@ public abstract class MediaContentBuilder {
meta = buildJsonObject(block)
}
/** Constructs the [MediaContent] instance from the current builder state. */
@PublishedApi
internal abstract fun build(): MediaContent
}

View file

@ -8,6 +8,7 @@ import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonObject
/** Discriminator values for the polymorphic [ContentBlock] hierarchy. */
@Serializable
public enum class ContentTypes(public val value: String) {
@SerialName("text")

View file

@ -40,10 +40,12 @@ public fun RequestId(value: Long): RequestId = RequestId.NumberId(value)
@Serializable(with = RequestIdPolymorphicSerializer::class)
public sealed interface RequestId {
/** A string-based request identifier. */
@JvmInline
@Serializable
public value class StringId(public val value: String) : RequestId
/** A numeric request identifier. */
@JvmInline
@Serializable
public value class NumberId(public val value: Long) : RequestId

View file

@ -243,6 +243,7 @@ public data class CreateMessageResult(
override val meta: JsonObject? = null,
) : ClientResult
/** The reason why the LLM stopped generating tokens. */
@JvmInline
@Serializable
public value class StopReason(public val value: String) {