Skip to content

Update notification schema #199

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 1 commit into from
Jul 28, 2025
Merged

Update notification schema #199

merged 1 commit into from
Jul 28, 2025

Conversation

devcrocod
Copy link
Contributor

  • add a params field to Notification

Motivation and Context

https://modelcontextprotocol.io/specification/2025-06-18/schema#notifications%2Fcancelled

How Has This Been Tested?

locally

Breaking Changes

yes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the notification schema to add a params field to all notifications, aligning with the Model Context Protocol specification. This represents a breaking change that restructures how notification data is organized.

Key changes:

  • Introduces a params field to the Notification interface and all implementing classes
  • Changes the progress type from Int to Double in progress-related classes
  • Updates serialization/deserialization logic for notifications to properly handle the new params structure

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types.kt Core notification schema changes adding params field and restructuring notification classes
src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/shared/Protocol.kt Updates protocol handling to use params field for progress and cancellation notifications
src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/server/Server.kt Updates server logging to access data through params field
api/kotlin-sdk.api API signature updates reflecting the breaking changes to notification structure
Test files Package name corrections and import cleanups

Comment on lines 172 to +174
return JSONRPCNotification(
method.value,
params = encoded
method = method.value,
params = McpJson.encodeToJsonElement(params),
Copy link
Preview

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The serialization logic for notifications doesn't handle null params correctly. When params is null, encoding it will create a JSON null value, but the protocol may expect the params field to be omitted entirely.

Copilot uses AI. Check for mistakes.

@@ -408,7 +423,7 @@ public sealed interface ServerResult : RequestResult
*/
@Serializable
public data class UnknownMethodRequestOrNotification(
override val method: Method,
override val method: Method, override val params: NotificationParams? = null,
Copy link
Preview

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making params nullable in UnknownMethodRequestOrNotification but required in other notification types creates inconsistency in the API. Consider whether params should be consistently required or nullable across all notification types.

Suggested change
override val method: Method, override val params: NotificationParams? = null,
override val method: Method, override val params: NotificationParams = DefaultNotificationParams,

Copilot uses AI. Check for mistakes.

@@ -411,8 +411,10 @@ class ClientTest {
}
server.sendLoggingMessage(
LoggingMessageNotification(
Copy link
Preview

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LoggingMessageNotification constructor call is incomplete - it's missing the closing parenthesis and appears to have syntax errors with the nested params structure.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@e5l e5l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. should we also bump the protocol version?

@devcrocod
Copy link
Contributor Author

 I think so
 although we still have some unresolved issues for the 2025-03-26 version

@devcrocod devcrocod merged commit cb79ea7 into main Jul 28, 2025
2 of 3 checks passed
@devcrocod devcrocod deleted the devcrocod/notification-schema branch July 28, 2025 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants