Skip to content

Files

Latest commit

May 19, 2025
e6a6a4a · May 19, 2025

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
May 19, 2025
Apr 9, 2025
May 19, 2025
Apr 9, 2025
May 19, 2025

readme.md

注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以不推荐直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,强烈推荐通过 s init ${模版名称} 的方法或应用中心进行初始化,详情可参考部署 & 体验

start-mcp-java-hello-world 帮助文档

基于 Java 的 FC MCP STDIO Server 案例

资源准备

使用该项目,您需要有开通以下服务并拥有对应权限:

服务/业务 权限 相关文档
函数计算 AliyunFCFullAccess 帮助文档 计费文档

部署 & 体验

案例介绍

这是一个部署到 FC 的 MCP Server 的 Java hello world 样例。您可以通过这个模版初始化一个简单的、开箱即用的、可进行二次开发的 MCP Server。

此样例包含一个名为 helloWorld 的 Tool,您可基于此样例 Tool 进行二次开发。

使用流程

部署完成拿到 URL 后,准备好支持 SSE 或 STDIO 的 MCP Client,通过 Transport 进行连接。

二次开发指南

此样例包含一个名为 helloWorld 的 Tool,您可基于此样例 Tool 进行二次开发。

@Service
public class McpService {
	public McpService() {}
	/**
	 * A sample tool. Return string 'Hello World!'
	 * @return String
	 */
	@Tool(description = "Return string 'Hello World!'")
	public String helloWorld() {
		return "Hello World!";
	}

	public static void main(String[] args) {
		McpService client = new McpService();
		System.out.println(client.helloWorld());
	}
}