Skip to content
Draft
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
451 changes: 451 additions & 0 deletions MCP_OAUTH_README.md

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion bazel/java.MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ maven.install(
"com.fasterxml.jackson.datatype:jackson-datatype-jsr310",
"com.fasterxml.jackson.module:jackson-module-scala_2.13",
"com.google.guava:guava:33.5.0-jre",
"com.nimbusds:nimbus-jose-jwt:9.47",
"com.nimbusds:oauth2-oidc-sdk:11.21",
"io.micronaut:micronaut-inject",
"io.modelcontextprotocol.sdk:mcp:0.12.1",
"io.micronaut:micronaut-inject-java",
"io.micronaut.validation:micronaut-validation",
"io.micronaut.validation:micronaut-validation-processor",
Expand All @@ -34,10 +37,11 @@ maven.install(
"io.netty:netty-codec",
"io.netty:netty-handler",
"io.netty:netty-transport",
"io.sentry:sentry-logback:8.26.0",
"io.sentry:sentry-logback:8.30.0",
"jakarta.annotation:jakarta.annotation-api:3.0.0",
"junit:junit:4.13.2",
"org.assertj:assertj-core:3.27.6",
"org.bouncycastle:bcprov-jdk18on:1.83",
"org.eclipse.jetty:jetty-server:%s" % JETTY_VERSION,
"org.eclipse.jetty.websocket:websocket-jetty-server:%s" % JETTY_VERSION,
"org.jspecify:jspecify:1.0.0",
Expand Down
22 changes: 22 additions & 0 deletions jvm/src/main/java/com/muchq/mcpclient/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
load("@rules_java//java:java_library.bzl", "java_library")

java_library(
name = "config",
srcs = ["McpClientConfig.java"],
visibility = [
"//jvm/src/main/java/com/muchq/mcpclient:__subpackages__",
"//jvm/src/test/java/com/muchq/mcpclient:__subpackages__",
],
)

java_library(
name = "mcpclient",
srcs = ["McpClientWrapper.java"],
visibility = ["//visibility:public"],
deps = [
":config",
"//jvm/src/main/java/com/muchq/mcpclient/oauth",
"@maven//:io_modelcontextprotocol_sdk_mcp",
"@maven//:org_slf4j_slf4j_api",
],
)
125 changes: 125 additions & 0 deletions jvm/src/main/java/com/muchq/mcpclient/McpClientConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package com.muchq.mcpclient;

/**
* Configuration for the MCP OAuth client.
*
* This configuration is used to:
* - Connect to the MCP server
* - Identify the client during OAuth registration
* - Configure the local OAuth callback server
* - Select transport type (HTTP or SSE)
*/
public class McpClientConfig {

/**
* Transport type for MCP communication.
*/
public enum TransportType {
/** Streamable HTTP transport (request/response). */
HTTP,
/** Server-Sent Events transport (streaming). */
SSE
}

private final String serverUrl;
private final String clientName;
private final String clientVersion;
private final int callbackPort;
private final String clientId;
private final String clientSecret;
private final TransportType transportType;

private McpClientConfig(Builder builder) {
this.serverUrl = builder.serverUrl;
this.clientName = builder.clientName;
this.clientVersion = builder.clientVersion;
this.callbackPort = builder.callbackPort;
this.clientId = builder.clientId;
this.clientSecret = builder.clientSecret;
this.transportType = builder.transportType;
}

public String getServerUrl() {
return serverUrl;
}

public String getClientName() {
return clientName;
}

public String getClientVersion() {
return clientVersion;
}

public int getCallbackPort() {
return callbackPort;
}

public String getClientId() {
return clientId;
}

public String getClientSecret() {
return clientSecret;
}

public TransportType getTransportType() {
return transportType;
}

public static Builder builder() {
return new Builder();
}

public static class Builder {
private String serverUrl;
private String clientName = "MCP Java Client";
private String clientVersion = "1.0.0";
private int callbackPort = 8888;
private String clientId;
private String clientSecret;
private TransportType transportType = TransportType.HTTP;

public Builder serverUrl(String serverUrl) {
this.serverUrl = serverUrl;
return this;
}

public Builder clientName(String clientName) {
this.clientName = clientName;
return this;
}

public Builder clientVersion(String clientVersion) {
this.clientVersion = clientVersion;
return this;
}

public Builder callbackPort(int callbackPort) {
this.callbackPort = callbackPort;
return this;
}

public Builder clientId(String clientId) {
this.clientId = clientId;
return this;
}

public Builder clientSecret(String clientSecret) {
this.clientSecret = clientSecret;
return this;
}

public Builder transportType(TransportType transportType) {
this.transportType = transportType;
return this;
}

public McpClientConfig build() {
if (serverUrl == null || serverUrl.isEmpty()) {
throw new IllegalArgumentException("serverUrl is required");
}
return new McpClientConfig(this);
}
}
}
Loading
Loading