Skip to content

Commit d033e65

Browse files
committed
clean...
1 parent 00a00cd commit d033e65

File tree

18 files changed

+48
-109
lines changed

18 files changed

+48
-109
lines changed

mcp-reactor/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Java MCP SDK
22

3-
Java SDK implementation of the Model Context Protocol, enabling seamless integration with language models and AI tools.
3+
Java SDK Reactor implementation of the Model Context Protocol, enabling seamless integration with language models and AI tools.
44
For comprehensive guides and API documentation, visit the [MCP Java SDK Reference Documentation](https://modelcontextprotocol.io/sdk/java/mcp-overview).
55

mcp-reactor/pom.xml

+22-63
Original file line numberDiff line numberDiff line change
@@ -65,48 +65,53 @@
6565
</build>
6666

6767
<dependencies>
68+
<!--MCP-->
6869
<dependency>
6970
<groupId>io.modelcontextprotocol.sdk</groupId>
7071
<artifactId>mcp-spi</artifactId>
7172
<version>${project.version}</version>
7273
</dependency>
73-
7474
<dependency>
7575
<groupId>io.modelcontextprotocol.sdk</groupId>
7676
<artifactId>mcp-schema-jackson</artifactId>
7777
<version>${project.version}</version>
7878
</dependency>
79-
79+
<!--Reactor-->
8080
<dependency>
81-
<groupId>org.slf4j</groupId>
82-
<artifactId>slf4j-api</artifactId>
83-
<version>${slf4j-api.version}</version>
81+
<groupId>org.reactivestreams</groupId>
82+
<artifactId>reactive-streams</artifactId>
8483
</dependency>
85-
86-
<dependency>
87-
<groupId>com.fasterxml.jackson.core</groupId>
88-
<artifactId>jackson-databind</artifactId>
89-
<version>${jackson.version}</version>
90-
</dependency>
91-
9284
<dependency>
9385
<groupId>io.projectreactor</groupId>
9486
<artifactId>reactor-core</artifactId>
9587
</dependency>
9688

97-
89+
<!-- Used by the HttpServletSseServerTransport -->
9890
<dependency>
99-
<groupId>io.projectreactor.netty</groupId>
100-
<artifactId>reactor-netty-http</artifactId>
101-
<scope>test</scope>
91+
<groupId>jakarta.servlet</groupId>
92+
<artifactId>jakarta.servlet-api</artifactId>
93+
<version>${jakarta.servlet.version}</version>
94+
<scope>provided</scope>
10295
</dependency>
103-
96+
<!--Logs-->
97+
<dependency>
98+
<groupId>org.slf4j</groupId>
99+
<artifactId>slf4j-api</artifactId>
100+
<version>${slf4j-api.version}</version>
101+
</dependency>
102+
<!--For test-->
104103
<dependency>
105104
<groupId>org.assertj</groupId>
106105
<artifactId>assertj-core</artifactId>
107106
<version>${assert4j.version}</version>
108107
<scope>test</scope>
109108
</dependency>
109+
<dependency>
110+
<groupId>org.testcontainers</groupId>
111+
<artifactId>testcontainers</artifactId>
112+
<version>${testcontainers.version}</version>
113+
<scope>test</scope>
114+
</dependency>
110115
<dependency>
111116
<groupId>org.junit.jupiter</groupId>
112117
<artifactId>junit-jupiter-api</artifactId>
@@ -125,70 +130,24 @@
125130
<version>${mockito.version}</version>
126131
<scope>test</scope>
127132
</dependency>
128-
129-
<!-- Mockito cannot mock this class: class java.net.http.HttpClient. the bytebuddy helps. -->
130-
<dependency>
131-
<groupId>net.bytebuddy</groupId>
132-
<artifactId>byte-buddy</artifactId>
133-
<version>${byte-buddy.version}</version>
134-
<scope>test</scope>
135-
</dependency>
136133
<dependency>
137134
<groupId>io.projectreactor</groupId>
138135
<artifactId>reactor-test</artifactId>
139136
<scope>test</scope>
140137
</dependency>
141-
<dependency>
142-
<groupId>org.testcontainers</groupId>
143-
<artifactId>junit-jupiter</artifactId>
144-
<version>${testcontainers.version}</version>
145-
<scope>test</scope>
146-
</dependency>
147-
148138
<dependency>
149139
<groupId>org.awaitility</groupId>
150140
<artifactId>awaitility</artifactId>
151141
<version>${awaitility.version}</version>
152142
<scope>test</scope>
153143
</dependency>
154-
155-
<dependency>
156-
<groupId>ch.qos.logback</groupId>
157-
<artifactId>logback-classic</artifactId>
158-
<version>${logback.version}</version>
159-
<scope>test</scope>
160-
</dependency>
161-
162-
<dependency>
163-
<groupId>net.javacrumbs.json-unit</groupId>
164-
<artifactId>json-unit-assertj</artifactId>
165-
<version>${json-unit-assertj.version}</version>
166-
<scope>test</scope>
167-
</dependency>
168-
169-
170-
<!-- Used by the HttpServletSseServerTransport -->
171-
<dependency>
172-
<groupId>jakarta.servlet</groupId>
173-
<artifactId>jakarta.servlet-api</artifactId>
174-
<version>${jakarta.servlet.version}</version>
175-
<scope>provided</scope>
176-
</dependency>
177-
178144
<!-- Tomcat dependencies for testing -->
179145
<dependency>
180146
<groupId>org.apache.tomcat.embed</groupId>
181147
<artifactId>tomcat-embed-core</artifactId>
182148
<version>${tomcat.version}</version>
183149
<scope>test</scope>
184150
</dependency>
185-
<dependency>
186-
<groupId>org.apache.tomcat.embed</groupId>
187-
<artifactId>tomcat-embed-websocket</artifactId>
188-
<version>${tomcat.version}</version>
189-
<scope>test</scope>
190-
</dependency>
191-
192151
</dependencies>
193152

194153

mcp-reactor/src/main/java/io/modelcontextprotocol/server/McpAsyncServer.java

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import java.util.concurrent.CopyOnWriteArrayList;
1515
import java.util.function.BiFunction;
1616

17-
import com.fasterxml.jackson.core.type.TypeReference;
1817
import com.fasterxml.jackson.databind.ObjectMapper;
1918

2019
import io.modelcontextprotocol.schema.McpJacksonCodec;

mcp-reactor/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
package io.modelcontextprotocol.server;
66

7-
import com.fasterxml.jackson.core.type.TypeReference;
8-
97
import io.modelcontextprotocol.schema.McpType;
108
import io.modelcontextprotocol.spec.McpError;
119
import io.modelcontextprotocol.schema.McpSchema;

mcp-reactor/src/main/java/io/modelcontextprotocol/session/McpClientSession.java

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import java.util.concurrent.ConcurrentHashMap;
1111
import java.util.concurrent.atomic.AtomicLong;
1212

13-
import com.fasterxml.jackson.core.type.TypeReference;
14-
1513
import io.modelcontextprotocol.schema.McpType;
1614
import io.modelcontextprotocol.spec.McpClientTransport;
1715
import io.modelcontextprotocol.spec.McpError;

mcp-reactor/src/main/java/io/modelcontextprotocol/session/McpServerSession.java

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import java.util.concurrent.atomic.AtomicLong;
88
import java.util.concurrent.atomic.AtomicReference;
99

10-
import com.fasterxml.jackson.core.type.TypeReference;
11-
1210
import io.modelcontextprotocol.schema.McpType;
1311
import io.modelcontextprotocol.server.McpAsyncServerExchange;
1412

mcp-reactor/src/test/java/io/modelcontextprotocol/MockMcpClientTransport.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

1212
import org.reactivestreams.Publisher;
1313

14-
import com.fasterxml.jackson.core.type.TypeReference;
15-
import com.fasterxml.jackson.databind.ObjectMapper;
16-
1714
import io.modelcontextprotocol.schema.McpJacksonCodec;
1815
import io.modelcontextprotocol.schema.McpType;
1916
import io.modelcontextprotocol.spec.McpClientTransport;
@@ -34,7 +31,7 @@ public class MockMcpClientTransport implements McpClientTransport {
3431

3532
private final BiConsumer<MockMcpClientTransport, McpSchema.JSONRPCMessage> interceptor;
3633

37-
private final McpJacksonCodec jacksonCodec = new McpJacksonCodec(new ObjectMapper());
34+
private final McpJacksonCodec jacksonCodec = new McpJacksonCodec();
3835

3936
public MockMcpClientTransport() {
4037
this((t, msg) -> {

mcp-reactor/src/test/java/io/modelcontextprotocol/MockMcpServerTransport.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
import java.util.List;
99
import java.util.function.BiConsumer;
1010

11-
import com.fasterxml.jackson.core.type.TypeReference;
12-
import com.fasterxml.jackson.databind.ObjectMapper;
13-
1411
import io.modelcontextprotocol.schema.McpJacksonCodec;
1512
import io.modelcontextprotocol.schema.McpSchema;
1613
import io.modelcontextprotocol.schema.McpSchema.JSONRPCNotification;
@@ -28,7 +25,7 @@ public class MockMcpServerTransport implements McpServerTransport {
2825

2926
private final BiConsumer<MockMcpServerTransport, McpSchema.JSONRPCMessage> interceptor;
3027

31-
private final McpJacksonCodec jacksonCodec = new McpJacksonCodec(new ObjectMapper());
28+
private final McpJacksonCodec jacksonCodec = new McpJacksonCodec();
3229

3330
public MockMcpServerTransport() {
3431
this((t, msg) -> {

mcp-reactor/src/test/java/io/modelcontextprotocol/client/McpAsyncClientResponseHandlerTests.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
import java.util.Map;
1010
import java.util.function.Function;
1111

12-
import com.fasterxml.jackson.core.JsonProcessingException;
13-
import com.fasterxml.jackson.core.type.TypeReference;
14-
import com.fasterxml.jackson.databind.ObjectMapper;
1512
import io.modelcontextprotocol.MockMcpClientTransport;
1613
import io.modelcontextprotocol.schema.McpJacksonCodec;
1714
import io.modelcontextprotocol.schema.McpType;
@@ -29,7 +26,7 @@
2926

3027
class McpAsyncClientResponseHandlerTests {
3128

32-
private final McpJacksonCodec mcpJacksonCodec = new McpJacksonCodec(new ObjectMapper());
29+
private final McpJacksonCodec mcpJacksonCodec = new McpJacksonCodec();
3330

3431
private static final McpSchema.Implementation SERVER_INFO = new McpSchema.Implementation("test-server", "1.0.0");
3532

@@ -94,7 +91,7 @@ void testSuccessfulInitialization() {
9491
}
9592

9693
@Test
97-
void testToolsChangeNotificationHandling() throws JsonProcessingException {
94+
void testToolsChangeNotificationHandling() throws Exception {
9895
MockMcpClientTransport transport = initializationEnabledTransport();
9996

10097
// Create a list to store received tools for verification

mcp-reactor/src/test/java/io/modelcontextprotocol/client/transport/HttpClientSseClientTransportTests.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.util.concurrent.atomic.AtomicReference;
1717
import java.util.function.Function;
1818

19+
import io.modelcontextprotocol.schema.McpJacksonCodec;
1920
import io.modelcontextprotocol.schema.McpSchema;
2021
import io.modelcontextprotocol.schema.McpSchema.JSONRPCRequest;
2122
import org.junit.jupiter.api.AfterEach;
@@ -65,7 +66,7 @@ static class TestHttpClientSseClientTransport extends HttpClientSseClientTranspo
6566
private final Sinks.Many<ServerSentEvent> events = Sinks.many().unicast().onBackpressureBuffer();
6667

6768
public TestHttpClientSseClientTransport(final String baseUri) {
68-
super(HttpClient.newHttpClient(), HttpRequest.newBuilder(), baseUri, "/sse", new ObjectMapper());
69+
super(HttpClient.newHttpClient(), HttpRequest.newBuilder(), baseUri, "/sse", new McpJacksonCodec());
6970
}
7071

7172
public int getInboundMessageCount() {

mcp-reactor/src/test/java/io/modelcontextprotocol/server/AbstractMcpAsyncServerTests.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
import static org.assertj.core.api.Assertions.assertThatCode;
3030
import static org.assertj.core.api.Assertions.assertThatThrownBy;
3131

32-
import com.fasterxml.jackson.databind.ObjectMapper;
33-
3432
/**
3533
* Test suite for the {@link McpAsyncServer} that can be used with different
3634
* {@link McpServerTransportProvider} implementations.
@@ -45,7 +43,7 @@ public abstract class AbstractMcpAsyncServerTests {
4543

4644
private static final String TEST_PROMPT_NAME = "test-prompt";
4745

48-
private final McpJacksonCodec mcpJacksonCodec = new McpJacksonCodec(new ObjectMapper());
46+
private final McpJacksonCodec mcpJacksonCodec = new McpJacksonCodec();
4947

5048
abstract protected McpServerTransportProvider createMcpTransportProvider();
5149

mcp-reactor/src/test/java/io/modelcontextprotocol/server/AbstractMcpSyncServerTests.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
import static org.assertj.core.api.Assertions.assertThatCode;
2727
import static org.assertj.core.api.Assertions.assertThatThrownBy;
2828

29-
import com.fasterxml.jackson.databind.ObjectMapper;
30-
3129
/**
3230
* Test suite for the {@link McpSyncServer} that can be used with different
3331
* {@link McpServerTransportProvider} implementations.
@@ -42,7 +40,7 @@ public abstract class AbstractMcpSyncServerTests {
4240

4341
private static final String TEST_PROMPT_NAME = "test-prompt";
4442

45-
private final McpJacksonCodec mcpJacksonCodec = new McpJacksonCodec(new ObjectMapper());
43+
private final McpJacksonCodec mcpJacksonCodec = new McpJacksonCodec();
4644

4745
abstract protected McpServerTransportProvider createMcpTransportProvider();
4846

mcp-reactor/src/test/java/io/modelcontextprotocol/server/transport/HttpServletSseServerTransportProviderIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class HttpServletSseServerTransportProviderIntegrationTests {
5858

5959
private static final String CUSTOM_MESSAGE_ENDPOINT = "/otherPath/mcp/message";
6060

61-
private final McpJacksonCodec mcpJacksonCodec = new McpJacksonCodec(new ObjectMapper());
61+
private final McpJacksonCodec mcpJacksonCodec = new McpJacksonCodec();
6262

6363
private HttpServletSseServerTransportProvider mcpServerTransportProvider;
6464

mcp-reactor/src/test/java/io/modelcontextprotocol/session/McpClientSessionTests.java

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import java.time.Duration;
88
import java.util.Map;
99

10-
import com.fasterxml.jackson.core.type.TypeReference;
1110
import io.modelcontextprotocol.MockMcpClientTransport;
1211
import org.junit.jupiter.api.AfterEach;
1312
import org.junit.jupiter.api.BeforeEach;

mcp-schema-jackson/pom.xml

+11-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
<name>Java SDK MCP Jackson Schema</name>
1616
<description>Java SDK Jackson Schema of the Model Context Protocol</description>
1717
<url>https://github.com/modelcontextprotocol/java-sdk</url>
18-
1918
<dependencies>
2019
<dependency>
2120
<groupId>io.modelcontextprotocol.sdk</groupId>
@@ -29,11 +28,22 @@
2928
<version>${slf4j-api.version}</version>
3029
</dependency>
3130

31+
<!--Jackson-->
3232
<dependency>
3333
<groupId>com.fasterxml.jackson.core</groupId>
3434
<artifactId>jackson-databind</artifactId>
3535
<version>${jackson.version}</version>
3636
</dependency>
37+
<dependency>
38+
<groupId>com.fasterxml.jackson.core</groupId>
39+
<artifactId>jackson-annotations</artifactId>
40+
<version>${jackson.version}</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>com.fasterxml.jackson.core</groupId>
44+
<artifactId>jackson-core</artifactId>
45+
<version>${jackson.version}</version>
46+
</dependency>
3747

3848
<!--test-->
3949
<dependency>
@@ -54,11 +64,5 @@
5464
<version>${json-unit-assertj.version}</version>
5565
<scope>test</scope>
5666
</dependency>
57-
<dependency>
58-
<groupId>io.modelcontextprotocol.sdk</groupId>
59-
<artifactId>mcp-spi</artifactId>
60-
<version>0.10.0-SNAPSHOT</version>
61-
<scope>compile</scope>
62-
</dependency>
6367
</dependencies>
6468
</project>

mcp-schema-jackson/src/main/java/io/modelcontextprotocol/schema/McpJacksonCodec.java

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ public class McpJacksonCodec implements McpSchemaCodec {
2323

2424
private final ObjectMapper mapper;
2525

26+
public McpJacksonCodec() {
27+
this(new ObjectMapper());
28+
}
29+
2630
public McpJacksonCodec(final ObjectMapper objectMapper) {
2731
Assert.notNull(objectMapper, "The ObjectMapper can not be null");
2832
this.mapper = objectMapper;

mcp-schema-jackson/src/test/java/io/modelcontextprotocol/schema/McpSchemaTests.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.junit.jupiter.api.Test;
1717

1818
import com.fasterxml.jackson.core.type.TypeReference;
19-
import com.fasterxml.jackson.databind.ObjectMapper;
2019
import com.fasterxml.jackson.databind.exc.InvalidTypeIdException;
2120

2221
import io.modelcontextprotocol.schema.McpSchema.TextResourceContents;
@@ -34,7 +33,7 @@ class McpSchemaTests {
3433

3534
@BeforeEach
3635
void setUp() {
37-
mcpJacksonCodec = new McpJacksonCodec(new ObjectMapper());
36+
mcpJacksonCodec = new McpJacksonCodec();
3837
}
3938

4039
@Test

0 commit comments

Comments
 (0)