Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.1"
version = "1.0.2"
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.1"
path = "../native/build/libs/mcp-native-1.0.1.jar"
version = "1.0.2"
path = "../native/build/libs/mcp-native-1.0.2-SNAPSHOT.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.1.jar"
path = "../compiler-plugin/build/libs/mcp-compiler-plugin-1.0.2-SNAPSHOT.jar"

[[dependency]]
path = "../compiler-plugin/build/libs/ballerina-to-openapi-2.3.0.jar"
14 changes: 7 additions & 7 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "crypto"
version = "2.9.0"
version = "2.9.1"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "time"}
Expand All @@ -50,7 +50,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "data.jsondata"
version = "1.1.0"
version = "1.1.3"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.object"}
Expand All @@ -70,7 +70,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "http"
version = "2.14.1"
version = "2.14.6"
dependencies = [
{org = "ballerina", name = "auth"},
{org = "ballerina", name = "cache"},
Expand Down Expand Up @@ -120,7 +120,7 @@ modules = [
[[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 @@ -229,7 +229,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "mcp"
version = "1.0.1"
version = "1.0.2"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "jballerina.java"},
Expand All @@ -254,7 +254,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "oauth2"
version = "2.14.0"
version = "2.14.1"
dependencies = [
{org = "ballerina", name = "cache"},
{org = "ballerina", name = "crypto"},
Expand All @@ -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
4 changes: 3 additions & 1 deletion ballerina/dispatcher_service.bal
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ isolated function getDispatcherService(http:HttpServiceConfig httpServiceConfig)
private ServiceConfiguration? cachedServiceConfig = ();

isolated resource function delete .(http:Headers headers) returns http:BadRequest|http:Ok|Error {
http:authenticateResource(self, "delete", []);
ServiceConfiguration config = check self.getCachedServiceConfiguration();
SessionMode sessionMode = config.sessionMode;

Expand Down Expand Up @@ -66,7 +67,8 @@ isolated function getDispatcherService(http:HttpServiceConfig httpServiceConfig)
}

isolated resource function post .(@http:Payload JsonRpcMessage request, http:Headers headers)
returns http:BadRequest|http:NotAcceptable|http:UnsupportedMediaType|http:Accepted|http:Ok|Error {
returns http:BadRequest|http:NotAcceptable|http:UnsupportedMediaType|http:Accepted|http:Ok|Error {
http:authenticateResource(self, "post", []);
http:NotAcceptable|http:UnsupportedMediaType? headerValidationError = validateRequiredHeaders(headers);
if headerValidationError !is () {
return headerValidationError;
Expand Down
32 changes: 18 additions & 14 deletions ballerina/streamable_http.bal
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,31 @@ isolated class StreamableHttpClientTransport {
}
}

if response.statusCode < 200 || response.statusCode >= 300 {
return error HttpClientError(
string `Server returned error status ${response.statusCode}: ${response.reasonPhrase}`
);
}

// If response is 202 Accepted, there is no content to process.
if response.statusCode == http:STATUS_ACCEPTED {
return;
}

boolean hasRequest = message is JsonRpcRequest;

if hasRequest {
string contentType = response.getContentType();
if contentType.includes(CONTENT_TYPE_SSE) {
return self.processServerSentEvents(response);
} else if contentType.includes(CONTENT_TYPE_JSON) {
return self.processJsonResponse(response);
} else {
return error UnsupportedContentTypeError(
string `Server returned unsupported content type '${contentType}'.`
);
}
} else {
if message !is JsonRpcRequest {
return;
}

string contentType = response.getContentType();
if contentType.includes(CONTENT_TYPE_SSE) {
return self.processServerSentEvents(response);
}
if contentType.includes(CONTENT_TYPE_JSON) {
return self.processJsonResponse(response);
}
return error UnsupportedContentTypeError(
string `Server returned unsupported content type '${contentType}'.`
);
} on fail error e {
return error HttpClientError(string `Failed to send message to server: ${e.message()}`);
}
Expand Down
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.1"
version = "1.0.2"
repository = "local"
2 changes: 1 addition & 1 deletion examples/clients/mcp-crypto-client/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ modules = [
[[package]]
org = "ballerina"
name = "mcp"
version = "1.0.1"
version = "1.0.2"
dependencies = [
{org = "ballerina", name = "http"},
{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.1"
version = "1.0.2"
repository = "local"
2 changes: 1 addition & 1 deletion examples/clients/mcp-shopping-client/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ modules = [
[[package]]
org = "ballerina"
name = "mcp"
version = "1.0.1"
version = "1.0.2"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "jballerina.java"},
Expand Down
17 changes: 16 additions & 1 deletion examples/clients/mcp-shopping-client/main.bal
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,22 @@ function runClientSession(string customerName, record {|string name; decimal pri
log:printInfo(string `\n=== ${customerName}'s Shopping Session ===`);

// Create a new client (each client gets its own session)
mcp:StreamableHttpClient mcpClient = check new ("http://localhost:9092/mcp");
mcp:StreamableHttpClientTransportConfig config = {
auth: {
username: "ballerina",
issuer: "wso2",
audience: ["ballerina", "ballerina.org", "ballerina.io"],
keyId: "5a0b754-895f-4279-8843-b745e11a57e9",
jwtId: "JlbmMiOiJBMTI4Q0JDLUhTMjU2In",
expTime: 3600,
signatureConfig: {
config: {
keyFile: "./resource/private.key"
}
}
}
};
mcp:StreamableHttpClient mcpClient = check new ("http://localhost:9092/mcp", config);

// Initialize client
check mcpClient->initialize({
Expand Down
28 changes: 28 additions & 0 deletions examples/clients/mcp-shopping-client/resource/private.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC9WqVDjRRlhsgX
FkraAiMnXuG7K7bDPMh19VvFPPjMAHr39f49peGEo/OYtP/Jm6B+loqL56iha895
3yodaDS40EuD0Tzruq/Y9l6A9eC8W/gZhNX5rFfdVIOMTqylOot3Zc/0ejFjbHjk
31VL/pJTkSma830kPxrDg5fC/O9DUCr35XSBwZMZYHLdsV49poWWPOP5+kP2NSSQ
6CHPFJLbT8uscGzEUbwtuzhekAxU7PcjV2uEBQJLWXUgDDrXB6j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nf0Pm7HMHLnxpo2AJC2HHOKxg5kwtlntsV9ysGLxOeSK62fUapHJfSH7
hS0EnfYFbCoxCKCcTUas2EmDzBitwgDGLE3fPzgBAoGBAJH0KHoBV+8X4IVY/Lr5
1LOFryw71dro+gvHAdcGWvmkXRkKl4oSWP4op/QPluGxDPwah3OdCNlawXfI5EwF
kTxMvFe7z66oWHuS5Ac+mb64ZffAX5hwqcIou+L6lgf7adCxrc/NsKd7HhNLuQXY
2mBHfTtII7g0zm9O+RTCT0JL
-----END PRIVATE KEY-----
28 changes: 0 additions & 28 deletions examples/clients/mcp-shopping-client/resources/private.key

This file was deleted.

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.1"
version = "1.0.2"
repository = "local"
2 changes: 1 addition & 1 deletion examples/clients/mcp-weather-client/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ modules = [
[[package]]
org = "ballerina"
name = "mcp"
version = "1.0.1"
version = "1.0.2"
dependencies = [
{org = "ballerina", name = "http"},
{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.1"
version = "1.0.2"
repository = "local"
2 changes: 1 addition & 1 deletion examples/servers/mcp-crypto-server/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ modules = [
[[package]]
org = "ballerina"
name = "mcp"
version = "1.0.1"
version = "1.0.2"
dependencies = [
{org = "ballerina", name = "http"},
{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.1"
version = "1.0.2"
repository = "local"
2 changes: 1 addition & 1 deletion examples/servers/mcp-shopping-server/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ modules = [
[[package]]
org = "ballerina"
name = "mcp"
version = "1.0.1"
version = "1.0.2"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "jballerina.java"},
Expand Down
5 changes: 2 additions & 3 deletions examples/servers/mcp-shopping-server/main.bal
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ listener mcp:Listener mcpListener = check new (9092);
{
jwtValidatorConfig: {
issuer: "wso2",
audience: "vEwzbcasJVQm1jVYHUHCjhxZ4tYa",
clockSkew: 60,
audience: "ballerina",
signatureConfig: {
certFile: "./resources/public.crt"
certFile: "./resource/public.crt"
}
}
}
Expand Down
21 changes: 21 additions & 0 deletions examples/servers/mcp-shopping-server/resource/public.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-----BEGIN CERTIFICATE-----
MIIDgTCCAmmgAwIBAgIUOJIU9KL50Axj2bTXv8fsttQHCwgwDQYJKoZIhvcNAQEL
BQAwUDELMAkGA1UEBhMCVVMxDjAMBgNVBAgMBVN0YXRlMQ0wCwYDVQQHDARDaXR5
MQwwCgYDVQQKDANPcmcxFDASBgNVBAMMC2V4YW1wbGUuY29tMB4XDTI1MTAxNTEy
MDgwMFoXDTI2MTAxNTEyMDgwMFowUDELMAkGA1UEBhMCVVMxDjAMBgNVBAgMBVN0
YXRlMQ0wCwYDVQQHDARDaXR5MQwwCgYDVQQKDANPcmcxFDASBgNVBAMMC2V4YW1w
bGUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvVqlQ40UZYbI
FxZK2gIjJ17huyu2wzzIdfVbxTz4zAB69/X+PaXhhKPzmLT/yZugfpaKi+eooWvP
ed8qHWg0uNBLg9E867qv2PZegPXgvFv4GYTV+axX3VSDjE6spTqLd2XP9HoxY2x4
5N9VS/6SU5EpmvN9JD8aw4OXwvzvQ1Aq9+V0gcGTGWBy3bFePaaFljzj+fpD9jUk
kOghzxSS20/LrHBsxFG8Lbs4XpAMVOz3I1drhAUCS1l1IAw61weo2a4tFb7/WOkz
ilsGWAa317is1bfT0a97k/ML+5m0/dheWyAnr6ImqoMk2ZxK84+GAV1Gin66drQD
sc72GOh1cwIDAQABo1MwUTAdBgNVHQ4EFgQUxhd4X7hrLYh0Hz5qfZHN5kWUKPYw
HwYDVR0jBBgwFoAUxhd4X7hrLYh0Hz5qfZHN5kWUKPYwDwYDVR0TAQH/BAUwAwEB
/zANBgkqhkiG9w0BAQsFAAOCAQEAR1LdF7qkAXsadJ6Lu0C7tPK1U+X6ZONLboyJ
RTFAxHw85bXx1DEKVpBDIr5EqzrLzSQoL+bEsZY/SzfQZQzeyEPHL5GkIqU9+gKA
pMOZp/Fzf/oQRDQLP5eTo2S/zz0lHgtq/FsFtmSf1IPqWTNYGRxEYrAtdkkU464g
Zza6JhJpTB9TFiNY2uB/vUIH1gJVO+ywjz4lyxTZIrlxa8kYrXGXG7lXAYF09aQu
iyB8HUAQxrrOP00uR6lGfJfUjVQmG7IC1sZRJPBaNuu57TiC0mpYe1CHqjeX1LO3
uehktNb60f5i9wA2eyBr0MR0XGThsAj9cqR1U/VWP2LdcmFtVA==
-----END CERTIFICATE-----
24 changes: 0 additions & 24 deletions examples/servers/mcp-shopping-server/resources/public.cert

This file was deleted.

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.1"
version = "1.0.2"
repository = "local"
2 changes: 1 addition & 1 deletion examples/servers/mcp-weather-server/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ modules = [
[[package]]
org = "ballerina"
name = "mcp"
version = "1.0.1"
version = "1.0.2"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "jballerina.java"},
Expand Down