Skip to content
6 changes: 3 additions & 3 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerina"
name = "mcp"
version = "1.0.0"
version = "1.0.1"
authors = ["Ballerina"]
keywords = ["mcp"]
repository = "https://github.com/ballerina-platform/module-ballerina-mcp"
Expand All @@ -15,5 +15,5 @@ graalvmCompatible = true
[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib."
artifactId = "mcp-native"
version = "1.0.0"
path = "../native/build/libs/mcp-native-1.0.0.jar"
version = "1.0.1"
path = "../native/build/libs/mcp-native-1.0.1.jar"
2 changes: 1 addition & 1 deletion ballerina/CompilerPlugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id = "mcp-compiler-plugin"
class = "io.ballerina.stdlib.mcp.plugin.McpCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/mcp-compiler-plugin-1.0.0.jar"
path = "../compiler-plugin/build/libs/mcp-compiler-plugin-1.0.1.jar"

[[dependency]]
path = "../compiler-plugin/build/libs/ballerina-to-openapi-2.3.0.jar"
2 changes: 1 addition & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "mcp"
version = "1.0.0"
version = "1.0.1"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "jballerina.java"},
Expand Down
9 changes: 7 additions & 2 deletions ballerina/dispatcher_service.bal
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,18 @@ isolated function getDispatcherService(http:HttpServiceConfig httpServiceConfig)
return error DispatcherError("MCP Service is not attached");
}

private isolated function executeOnCallTool(CallToolParams params, Session? session) returns CallToolResult|Error {
private isolated function executeOnCallTool(CallToolParams params, Session? session)
returns CallToolResult|Error {
Service|AdvancedService mcpService = check getMcpServiceFromDispatcher(self);
if mcpService is AdvancedService {
return invokeOnCallTool(mcpService, params.cloneReadOnly(), session);
}
if mcpService is Service {
return callToolForRemoteFunctions(mcpService, params.cloneReadOnly(), session);
CallToolResult|error result = callToolForRemoteFunctions(mcpService, params.cloneReadOnly(), session);
if result is error {
return error DispatcherError(result.message());
}
return result;
}
return error DispatcherError("MCP Service is not attached");
}
Expand Down
2 changes: 1 addition & 1 deletion ballerina/native_listener_helper.bal
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ isolated function listToolsForRemoteFunctions(Service 'service, typedesc<ListToo
} external;

isolated function callToolForRemoteFunctions(Service 'service, CallToolParams params, Session? session,
typedesc<CallToolResult> t = <>) returns t|Error = @java:Method {
typedesc<CallToolResult> t = <>) returns t|error = @java:Method {
'class: "io.ballerina.stdlib.mcp.McpServiceMethodHelper"
} external;

Expand Down
8 changes: 7 additions & 1 deletion ballerina/streamable_http.bal
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,13 @@ isolated class StreamableHttpClientTransport {
returns JsonRpcMessage|StreamableHttpTransportError {
do {
json payload = check response.getJsonPayload();
return check payload.cloneWithType();
JsonRpcMessage|http:ErrorPayload result = check payload.cloneWithType();
if result is JsonRpcMessage {
return result;
}
return error HttpClientError(
string `Received error response from server: ${result.toJsonString()}`
);
} on fail error e {
return error ResponseParsingError(
string `Unable to parse JSON response: ${e.message()}`
Expand Down
6 changes: 3 additions & 3 deletions ballerina/types.bal
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import ballerina/http;

# Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent.
public type JsonRpcMessage JsonRpcRequest|JsonRpcNotification|JsonRpcResponse;
public type JsonRpcMessage JsonRpcRequest|JsonRpcNotification|JsonRpcError|JsonRpcResponse;

public const LATEST_PROTOCOL_VERSION = "2025-03-26";
public const SUPPORTED_PROTOCOL_VERSIONS = [
Expand Down Expand Up @@ -143,7 +143,7 @@ public const NOT_ACCEPTABLE = -32001;
public const UNSUPPORTED_MEDIA_TYPE = -32002;

# A response to a request that indicates an error occurred.
public type JsonRpcError record {
public type JsonRpcError record {|
# The JSON-RPC protocol version
JSONRPC_VERSION jsonrpc;
# Identifier of the request
Expand All @@ -157,7 +157,7 @@ public type JsonRpcError record {
# Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
anydata data?;
} 'error;
};
|};

# This request is sent from the client to the server when it first connects, asking it to begin initialization.
type InitializeRequest record {|
Expand Down
3 changes: 3 additions & 0 deletions ballerina/utils.bal
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,8 @@ isolated function extractResultFromMessage(JsonRpcMessage message) returns Serve
if message is JsonRpcResponse {
return message.result;
}
if message is JsonRpcError {
return error ServerResponseError(string `Received JSON-RPC error from server: ${message.toJsonString()}`);
}
return error InvalidMessageTypeError("Received message from server is not a valid JsonRpcResponse.");
}
2 changes: 1 addition & 1 deletion examples/clients/mcp-crypto-client/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ observabilityIncluded = true
[[dependency]]
org = "ballerina"
name = "mcp"
version = "1.0.0"
version = "1.0.1"
repository = "local"
10 changes: 5 additions & 5 deletions examples/clients/mcp-crypto-client/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "data.jsondata"
version = "1.1.2"
version = "1.1.3"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.object"}
Expand Down Expand Up @@ -116,7 +116,7 @@ version = "0.0.0"
[[package]]
org = "ballerina"
name = "jwt"
version = "2.15.0"
version = "2.15.1"
dependencies = [
{org = "ballerina", name = "cache"},
{org = "ballerina", name = "crypto"},
Expand Down Expand Up @@ -205,7 +205,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "log"
version = "2.13.0"
version = "2.14.0"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
Expand All @@ -219,7 +219,7 @@ modules = [
[[package]]
org = "ballerina"
name = "mcp"
version = "1.0.0"
version = "1.0.1"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "jballerina.java"},
Expand Down Expand Up @@ -278,7 +278,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "os"
version = "1.10.0"
version = "1.10.1"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"}
Expand Down
2 changes: 1 addition & 1 deletion examples/clients/mcp-shopping-client/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ observabilityIncluded = true
[[dependency]]
org = "ballerina"
name = "mcp"
version = "1.0.0"
version = "1.0.1"
repository = "local"
10 changes: 5 additions & 5 deletions examples/clients/mcp-shopping-client/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "data.jsondata"
version = "1.1.2"
version = "1.1.3"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.object"}
Expand Down Expand Up @@ -116,7 +116,7 @@ version = "0.0.0"
[[package]]
org = "ballerina"
name = "jwt"
version = "2.15.0"
version = "2.15.1"
dependencies = [
{org = "ballerina", name = "cache"},
{org = "ballerina", name = "crypto"},
Expand Down Expand Up @@ -205,7 +205,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "log"
version = "2.13.0"
version = "2.14.0"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
Expand All @@ -219,7 +219,7 @@ modules = [
[[package]]
org = "ballerina"
name = "mcp"
version = "1.0.0"
version = "1.0.1"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "jballerina.java"},
Expand Down Expand Up @@ -278,7 +278,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "os"
version = "1.10.0"
version = "1.10.1"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"}
Expand Down
2 changes: 1 addition & 1 deletion examples/clients/mcp-weather-client/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ observabilityIncluded = true
[[dependency]]
org = "ballerina"
name = "mcp"
version = "1.0.0"
version = "1.0.1"
repository = "local"
10 changes: 5 additions & 5 deletions examples/clients/mcp-weather-client/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "data.jsondata"
version = "1.1.2"
version = "1.1.3"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.object"}
Expand Down Expand Up @@ -116,7 +116,7 @@ version = "0.0.0"
[[package]]
org = "ballerina"
name = "jwt"
version = "2.15.0"
version = "2.15.1"
dependencies = [
{org = "ballerina", name = "cache"},
{org = "ballerina", name = "crypto"},
Expand Down Expand Up @@ -205,7 +205,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "log"
version = "2.13.0"
version = "2.14.0"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
Expand All @@ -219,7 +219,7 @@ modules = [
[[package]]
org = "ballerina"
name = "mcp"
version = "1.0.0"
version = "1.0.1"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "jballerina.java"},
Expand Down Expand Up @@ -278,7 +278,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "os"
version = "1.10.0"
version = "1.10.1"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"}
Expand Down
2 changes: 1 addition & 1 deletion examples/servers/mcp-crypto-server/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ observabilityIncluded = true
[[dependency]]
org = "ballerina"
name = "mcp"
version = "1.0.0"
version = "1.0.1"
repository = "local"
10 changes: 5 additions & 5 deletions examples/servers/mcp-crypto-server/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ modules = [
[[package]]
org = "ballerina"
name = "data.jsondata"
version = "1.1.2"
version = "1.1.3"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.object"}
Expand Down Expand Up @@ -116,7 +116,7 @@ version = "0.0.0"
[[package]]
org = "ballerina"
name = "jwt"
version = "2.15.0"
version = "2.15.1"
dependencies = [
{org = "ballerina", name = "cache"},
{org = "ballerina", name = "crypto"},
Expand Down Expand Up @@ -208,7 +208,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "log"
version = "2.13.0"
version = "2.14.0"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
Expand All @@ -222,7 +222,7 @@ modules = [
[[package]]
org = "ballerina"
name = "mcp"
version = "1.0.0"
version = "1.0.1"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "jballerina.java"},
Expand Down Expand Up @@ -282,7 +282,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "os"
version = "1.10.0"
version = "1.10.1"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"}
Expand Down
2 changes: 1 addition & 1 deletion examples/servers/mcp-shopping-server/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ observabilityIncluded = true
[[dependency]]
org = "ballerina"
name = "mcp"
version = "1.0.0"
version = "1.0.1"
repository = "local"
10 changes: 5 additions & 5 deletions examples/servers/mcp-shopping-server/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "data.jsondata"
version = "1.1.2"
version = "1.1.3"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.object"}
Expand Down Expand Up @@ -113,7 +113,7 @@ version = "0.0.0"
[[package]]
org = "ballerina"
name = "jwt"
version = "2.15.0"
version = "2.15.1"
dependencies = [
{org = "ballerina", name = "cache"},
{org = "ballerina", name = "crypto"},
Expand Down Expand Up @@ -202,7 +202,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "log"
version = "2.13.0"
version = "2.14.0"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
Expand All @@ -216,7 +216,7 @@ modules = [
[[package]]
org = "ballerina"
name = "mcp"
version = "1.0.0"
version = "1.0.1"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "jballerina.java"},
Expand Down Expand Up @@ -275,7 +275,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "os"
version = "1.10.0"
version = "1.10.1"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"}
Expand Down
2 changes: 1 addition & 1 deletion examples/servers/mcp-weather-server/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ observabilityIncluded = true
[[dependency]]
org = "ballerina"
name = "mcp"
version = "1.0.0"
version = "1.0.1"
repository = "local"
Loading