Skip to content

Commit 14e9dc5

Browse files
authored
Merge pull request #22 from zxypro1/zxy/dev-java-sse-template
add java sse template
2 parents 06e232d + a676da8 commit 14e9dc5

19 files changed

Lines changed: 1260 additions & 0 deletions

File tree

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
2+
> 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验)
3+
4+
# start-mcp-java-hello-world-sse 帮助文档
5+
6+
<description>
7+
8+
基于 Java 的 FC MCP SSE Server 案例
9+
10+
</description>
11+
12+
13+
## 资源准备
14+
15+
使用该项目,您需要有开通以下服务并拥有对应权限:
16+
17+
<service>
18+
19+
20+
21+
| 服务/业务 | 权限 | 相关文档 |
22+
| --- | --- | --- |
23+
| 函数计算 | AliyunFCFullAccess | [帮助文档](https://help.aliyun.com/product/2508973.html) [计费文档](https://help.aliyun.com/document_detail/2512928.html) |
24+
25+
</service>
26+
27+
<remark>
28+
29+
30+
31+
</remark>
32+
33+
<disclaimers>
34+
35+
36+
37+
</disclaimers>
38+
39+
## 部署 & 体验
40+
41+
<appcenter>
42+
43+
- :fire: 通过 [云原生应用开发平台 CAP](https://cap.console.aliyun.com/template-detail?template=start-mcp-java-hello-world)[![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://cap.console.aliyun.com/template-detail?template=start-mcp-java-hello-world) 该应用。
44+
45+
</appcenter>
46+
<deploy>
47+
48+
49+
</deploy>
50+
51+
## 案例介绍
52+
53+
<appdetail id="flushContent">
54+
55+
这是一个部署到 FC 的 MCP Server 的 Java hello world 样例。您可以通过这个模版初始化一个简单的、开箱即用的、可进行二次开发的 MCP Server。
56+
57+
此样例包含一个名为 `helloWorld` 的 Tool,您可基于此样例 Tool 进行二次开发。
58+
59+
</appdetail>
60+
61+
62+
63+
64+
65+
66+
67+
## 使用流程
68+
69+
<usedetail id="flushContent">
70+
71+
部署完成拿到 URL 后,准备好支持 SSE 或 STDIO 的 MCP Client,通过 Transport 进行连接。
72+
73+
</usedetail>
74+
75+
## 二次开发指南
76+
77+
<development id="flushContent">
78+
79+
此样例包含一个名为 `helloWorld` 的 Tool,您可基于此样例 Tool 进行二次开发。
80+
```java
81+
@Service
82+
public class McpService {
83+
public McpService() {}
84+
/**
85+
* A sample tool. Return string 'Hello World!'
86+
* @return String
87+
*/
88+
@Tool(description = "Return string 'Hello World!'")
89+
public String helloWorld() {
90+
return "Hello World!";
91+
}
92+
93+
public static void main(String[] args) {
94+
McpService client = new McpService();
95+
System.out.println(client.helloWorld());
96+
}
97+
}
98+
```
99+
100+
</development>
101+
102+
103+
104+
105+
106+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Edition: 3.0.0
2+
Type: Project
3+
Name: start-mcp-java-hello-world-sse
4+
Version: 0.0.1
5+
Provider:
6+
- 阿里云 # 取值内容参考:https://api.devsapp.cn/v3/common/args.html
7+
Description: 基于 Java 的 FC MCP SSE Server 案例
8+
HomePage: https://github.com/devsapp/mcp-servers
9+
Tags: #标签详情
10+
- MCP
11+
- Develop
12+
Category: AI工具 # 取值内容参考:https://api.devsapp.cn/v3/common/args.html
13+
Service: # 使用的服务
14+
函数计算: # 取值内容参考:https://api.devsapp.cn/v3/common/args.html
15+
Authorities: #权限描述
16+
- AliyunFCFullAccess # 所需要的权限,例如AliyunFCFullAccess
17+
Organization: 阿里云函数计算(FC) # 所属组织
18+
Effective: Public # 是否公开,取值:Public,Private,Organization
19+
Parameters:
20+
type: object
21+
additionalProperties: false # 不允许增加其他属性
22+
required: # 必填项
23+
- region
24+
properties:
25+
region:
26+
title: 地域
27+
type: string
28+
default: cn-hangzhou
29+
description: 创建应用所在的地区
30+
required: true
31+
enum:
32+
- cn-beijing
33+
- cn-hangzhou
34+
- cn-shanghai
35+
- cn-shenzhen
36+
- ap-southeast-1
37+
functionName:
38+
title: 函数名
39+
type: string
40+
pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$"
41+
default: start-mcp-server-java-${default-suffix}
42+
description: 函数名,支持字母、数字、下划线、连字符,不能以数字或连字符开头,长度为1~64个字符。
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
./code/node_modules/
2+
./code/dist
3+
./code/target/
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
start-mcp-java-hello-world:
2+
default:
3+
languages:
4+
- java21
5+
steps:
6+
- run: chmod +x ./mvnw
7+
path: ./code
8+
- run: ./mvnw clean install -DskipTests
9+
path: ./code
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with 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,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
wrapperVersion=3.3.2
18+
distributionType=only-script
19+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip

0 commit comments

Comments
 (0)