Skip to content

Commit 4739e28

Browse files
committed
move dubbo-mcp-sdk to dubbo plugin
1 parent 379fa90 commit 4739e28

File tree

17 files changed

+1248
-0
lines changed

17 files changed

+1248
-0
lines changed

.artifacts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ dubbo-filter-cache
4141
dubbo-filter-validation
4242
dubbo-kubernetes
4343
dubbo-maven-plugin
44+
dubbo-mcp
4445
dubbo-metadata
4546
dubbo-metadata-api
4647
dubbo-metadata-definition-protobuf

dubbo-distribution/dubbo-all-shaded/pom.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@
495495
<include>org.apache.dubbo:dubbo-configcenter-zookeeper</include>
496496
<include>org.apache.dubbo:dubbo-filter-cache</include>
497497
<include>org.apache.dubbo:dubbo-filter-validation</include>
498+
<include>org.apache.dubbo:dubbo-mcp</include>
498499
<include>org.apache.dubbo:dubbo-metadata-api</include>
499500
<include>org.apache.dubbo:dubbo-metadata-definition-protobuf</include>
500501
<include>org.apache.dubbo:dubbo-metadata-report-nacos</include>
@@ -989,6 +990,21 @@
989990
</build>
990991

991992
<profiles>
993+
<profile>
994+
<id>mcp</id>
995+
<activation>
996+
<jdk>[17,)</jdk>
997+
</activation>
998+
<dependencies>
999+
<dependency>
1000+
<groupId>org.apache.dubbo</groupId>
1001+
<artifactId>dubbo-mcp</artifactId>
1002+
<version>${project.version}</version>
1003+
<scope>compile</scope>
1004+
<optional>true</optional>
1005+
</dependency>
1006+
</dependencies>
1007+
</profile>
9921008
<profile>
9931009
<id>loom</id>
9941010
<activation>
@@ -1014,6 +1030,13 @@
10141030
<scope>compile</scope>
10151031
<optional>true</optional>
10161032
</dependency>
1033+
<dependency>
1034+
<groupId>org.apache.dubbo</groupId>
1035+
<artifactId>dubbo-mcp</artifactId>
1036+
<version>${project.version}</version>
1037+
<scope>compile</scope>
1038+
<optional>true</optional>
1039+
</dependency>
10171040
</dependencies>
10181041
<build>
10191042
<plugins>

dubbo-distribution/dubbo-all/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@
494494
<include>org.apache.dubbo:dubbo-configcenter-zookeeper</include>
495495
<include>org.apache.dubbo:dubbo-filter-cache</include>
496496
<include>org.apache.dubbo:dubbo-filter-validation</include>
497+
<include>org.apache.dubbo:dubbo-mcp</include>
497498
<include>org.apache.dubbo:dubbo-metadata-api</include>
498499
<include>org.apache.dubbo:dubbo-metadata-definition-protobuf</include>
499500
<include>org.apache.dubbo:dubbo-metadata-report-nacos</include>
@@ -999,6 +1000,13 @@
9991000
<scope>compile</scope>
10001001
<optional>true</optional>
10011002
</dependency>
1003+
<dependency>
1004+
<groupId>org.apache.dubbo</groupId>
1005+
<artifactId>dubbo-mcp</artifactId>
1006+
<version>${project.version}</version>
1007+
<scope>compile</scope>
1008+
<optional>true</optional>
1009+
</dependency>
10021010
</dependencies>
10031011
<build>
10041012
<plugins>

dubbo-distribution/dubbo-bom/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@
264264
<artifactId>dubbo-auth</artifactId>
265265
<version>${project.version}</version>
266266
</dependency>
267+
<dependency>
268+
<groupId>org.apache.dubbo</groupId>
269+
<artifactId>dubbo-mcp</artifactId>
270+
<version>${project.version}</version>
271+
</dependency>
267272
<dependency>
268273
<groupId>org.apache.dubbo</groupId>
269274
<artifactId>dubbo-security</artifactId>

dubbo-plugin/dubbo-mcp/pom.xml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
19+
<modelVersion>4.0.0</modelVersion>
20+
<parent>
21+
<groupId>org.apache.dubbo</groupId>
22+
<artifactId>dubbo-parent</artifactId>
23+
<version>${revision}</version>
24+
<relativePath>../../pom.xml</relativePath>
25+
</parent>
26+
27+
<artifactId>dubbo-mcp</artifactId>
28+
<properties>
29+
<mcp.version>0.9.0</mcp.version>
30+
<skip_maven_deploy>false</skip_maven_deploy>
31+
</properties>
32+
33+
<dependencies>
34+
<dependency>
35+
<groupId>org.apache.dubbo</groupId>
36+
<artifactId>dubbo-rest-openapi</artifactId>
37+
<version>${project.version}</version>
38+
</dependency>
39+
<dependency>
40+
<groupId>io.modelcontextprotocol.sdk</groupId>
41+
<artifactId>mcp</artifactId>
42+
<version>${mcp.version}</version>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.apache.dubbo</groupId>
46+
<artifactId>dubbo-config-api</artifactId>
47+
<version>${project.version}</version>
48+
</dependency>
49+
<dependency>
50+
<groupId>org.apache.dubbo</groupId>
51+
<artifactId>dubbo-common</artifactId>
52+
<version>${project.version}</version>
53+
</dependency>
54+
</dependencies>
55+
56+
<build>
57+
<plugins>
58+
<plugin>
59+
<groupId>org.apache.maven.plugins</groupId>
60+
<artifactId>maven-compiler-plugin</artifactId>
61+
<configuration>
62+
<compilerArgs>
63+
<arg>-parameters</arg>
64+
</compilerArgs>
65+
<source>17</source>
66+
<target>17</target>
67+
<release>17</release>
68+
</configuration>
69+
</plugin>
70+
</plugins>
71+
</build>
72+
</project>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.dubbo.mcp.server.sdk;
18+
19+
import org.apache.dubbo.common.resource.Disposable;
20+
import org.apache.dubbo.common.stream.StreamObserver;
21+
import org.apache.dubbo.mcp.server.sdk.registry.McpApplicationDeployListener;
22+
import org.apache.dubbo.mcp.server.sdk.transport.DubboMcpSseTransportProvider;
23+
import org.apache.dubbo.remoting.http12.message.ServerSentEvent;
24+
25+
public class MCPSseService implements McpService, Disposable {
26+
27+
private DubboMcpSseTransportProvider transportProvider = getTransportProvider();
28+
29+
@Override
30+
public void get(StreamObserver<ServerSentEvent<String>> responseObserver) {
31+
if (transportProvider == null) {
32+
transportProvider = getTransportProvider();
33+
}
34+
transportProvider.handleRequest(responseObserver);
35+
}
36+
37+
@Override
38+
public void post() {
39+
if (transportProvider == null) {
40+
transportProvider = getTransportProvider();
41+
}
42+
transportProvider.handleRequest(null);
43+
}
44+
45+
private DubboMcpSseTransportProvider getTransportProvider() {
46+
return McpApplicationDeployListener.getDubboMcpSseTransportProvider();
47+
}
48+
49+
@Override
50+
public void destroy() {}
51+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.dubbo.mcp.server.sdk;
18+
19+
import java.io.Serializable;
20+
21+
public class McpConfig implements Serializable {
22+
23+
private Boolean enabled;
24+
25+
public Boolean getEnabled() {
26+
return enabled;
27+
}
28+
29+
public void setEnabled(Boolean enabled) {
30+
this.enabled = enabled;
31+
}
32+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.dubbo.mcp.server.sdk;
18+
19+
public interface McpConstant {
20+
21+
String SETTINGS_MCP_PREFIX = "dubbo.protocol.triple.rest.mcp";
22+
String SETTINGS_MCP_ENABLE = "dubbo.protocol.triple.rest.mcp.enable";
23+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.dubbo.mcp.server.sdk;
18+
19+
import org.apache.dubbo.common.stream.StreamObserver;
20+
import org.apache.dubbo.remoting.http12.HttpMethods;
21+
import org.apache.dubbo.remoting.http12.message.ServerSentEvent;
22+
import org.apache.dubbo.remoting.http12.rest.Mapping;
23+
24+
@Mapping("")
25+
public interface McpService {
26+
27+
@Mapping(value = "/mcp/sse", method = HttpMethods.GET)
28+
void get(StreamObserver<ServerSentEvent<String>> responseObserver);
29+
30+
@Mapping(value = "/mcp/message", method = HttpMethods.POST)
31+
void post();
32+
}

0 commit comments

Comments
 (0)