Implement initial version of MCP client#3
Merged
AzeemMuzammil merged 15 commits intoballerina-platform:mainfrom Jun 6, 2025
Merged
Implement initial version of MCP client#3AzeemMuzammil merged 15 commits intoballerina-platform:mainfrom
AzeemMuzammil merged 15 commits intoballerina-platform:mainfrom
Conversation
d5146b9 to
d381be7
Compare
native/src/main/java/io/ballerina/stdlib/mcp/SseEventStreamHelper.java
Outdated
Show resolved
Hide resolved
added 2 commits
June 6, 2025 10:41
MohamedSabthar
approved these changes
Jun 6, 2025
MaryamZi
reviewed
Jun 6, 2025
Comment on lines
99
to
110
| json jsonData; | ||
| do { | ||
| jsonData = check eventData.fromJsonString(); | ||
| } on fail error e { | ||
| return error JsonParsingError(string `Failed to parse SSE event data as JSON: ${e.message()}`); | ||
| } | ||
|
|
||
| do { | ||
| return check jsonData.cloneWithType(); | ||
| } on fail error e { | ||
| return error TypeConversionError(string `Failed to convert JSON data to JsonRpcMessage: ${e.message()}`); | ||
| } |
Member
There was a problem hiding this comment.
Unless you want the different errors, can directly do eventData.fromJsonStringWithType()
|
|
||
| # Additional initialization options. | ||
| # | ||
| # + enforceStrictCapabilities - Whether to restrict emitted requests to only those that the remote |
Member
There was a problem hiding this comment.
Shall we move this to field-level. This is the old way of documenting record fields.
| # + params - The parameters for the progress notification | ||
| public type ProgressNotification record {| | ||
| *Notification; | ||
| "notifications/progress" method; |
Member
There was a problem hiding this comment.
Shall we introduce consts/an enum for these?
| # | ||
| # + serverResponse - The response from the server, which may be a single JsonRpcMessage, a stream, or a transport error. | ||
| # + return - Extracted ServerResult, ServerResponseError, or StreamError. | ||
| isolated function processServerResponse(JsonRpcMessage|stream<JsonRpcMessage, StreamError?>|StreamableHttpTransportError? serverResponse) |
| # Processes a server response and extracts the result. | ||
| # | ||
| # + serverResponse - The response from the server, which may be a single JsonRpcMessage, a stream, or a transport error. | ||
| # + return - Extracted ServerResult, ServerResponseError, or StreamError. |
Member
There was a problem hiding this comment.
If you prefix these with type, the references will be validated too.
type `ServerResult`
ballerina/client.bal
Outdated
| StreamableHttpClientTransport? currentTransport = self.transport; | ||
| if currentTransport is () { | ||
| return error UninitializedTransportError( | ||
| "Closure failed: client transport is not initialized. Call initialize() first." |
Member
There was a problem hiding this comment.
Is "Call initialize() first." really useful here?
Comment on lines
+76
to
+78
| } else if contentType.includes(CONTENT_TYPE_JSON) { | ||
| return self.processJsonResponse(response); | ||
| } else { |
Member
There was a problem hiding this comment.
else if can be an if
else is not needed, can just move the logic out
| # + resources - Present if the server offers any resources to read. | ||
| # + tools - Present if the server offers any tools to call. | ||
| public type ServerCapabilities record { | ||
| record {|record {}...;|} experimental?; |
Member
There was a problem hiding this comment.
record open by anydata or json?
can be map<map> or map<map>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
$title.
Examples
Checklist