diff --git a/fc-node/start-mcp-server/publish.yaml b/fc-node/start-mcp-server/publish.yaml
index f19bfc7..d31a274 100644
--- a/fc-node/start-mcp-server/publish.yaml
+++ b/fc-node/start-mcp-server/publish.yaml
@@ -1,13 +1,14 @@
Edition: 3.0.0
Type: Project
Name: start-mcp-server-nodejs
-Version: dev
+Version: 0.0.3
Provider:
- 阿里云 # 取值内容参考:https://api.devsapp.cn/v3/common/args.html
-Description: FC MCP SSE Server案例
+Description: 基于 Node 的FC MCP SSE Server案例
HomePage: https://www.serverless-devs.com
Tags: #标签详情
- MCP
+ - Develop
Category: AI工具 # 取值内容参考:https://api.devsapp.cn/v3/common/args.html
Service: # 使用的服务
函数计算: # 取值内容参考:https://api.devsapp.cn/v3/common/args.html
@@ -20,7 +21,6 @@ Parameters:
additionalProperties: false # 不允许增加其他属性
required: # 必填项
- region
- - functionName
properties:
region:
title: 地域
@@ -37,6 +37,6 @@ Parameters:
functionName:
title: 函数名
type: string
- required: true
- default: mcp-fc-server-${default-suffix}
- description: 函数名称,只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-64 之间
+ pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$"
+ default: start-mcp-server-nodejs-${default-suffix}
+ description: 函数名,支持字母、数字、下划线、连字符,不能以数字或连字符开头,长度为1~64个字符。
diff --git a/fc-node/start-mcp-server/src/s.yaml b/fc-node/start-mcp-server/src/s.yaml
index d55521c..1d03c12 100644
--- a/fc-node/start-mcp-server/src/s.yaml
+++ b/fc-node/start-mcp-server/src/s.yaml
@@ -3,7 +3,6 @@ name: start-mcp-server-nodejs
access: '{{access}}'
vars:
region: '{{region}}'
- functionName: '{{functionName}}'
resources:
mcp_server:
component: fc3
@@ -26,7 +25,7 @@ resources:
- node
- ./dist/index.js
port: 3000
- functionName: ${vars.functionName}
+ functionName: '{{functionName}}'
code: ./code
instanceConcurrency: 10
triggers:
diff --git a/fc-python/start-mcp-server/hook/index.js b/fc-python/start-mcp-server/hook/index.js
new file mode 100644
index 0000000..099f7a5
--- /dev/null
+++ b/fc-python/start-mcp-server/hook/index.js
@@ -0,0 +1,12 @@
+async function preInit(inputObj) {
+
+}
+
+async function postInit(inputObj) {
+
+}
+
+module.exports = {
+ postInit,
+ preInit
+}
diff --git a/fc-python/start-mcp-server/publish.yaml b/fc-python/start-mcp-server/publish.yaml
new file mode 100644
index 0000000..dfcef51
--- /dev/null
+++ b/fc-python/start-mcp-server/publish.yaml
@@ -0,0 +1,41 @@
+Edition: 3.0.0
+Type: Project
+Name: start-mcp-server-python
+Version: dev
+Provider:
+ - 阿里云 # 取值内容参考:https://api.devsapp.cn/v3/common/args.html
+Description: 基于 Python 的FC MCP SSE Server案例
+HomePage: https://www.serverless-devs.com
+Tags: #标签详情
+ - MCP
+Category: AI工具 # 取值内容参考:https://api.devsapp.cn/v3/common/args.html
+Service: # 使用的服务
+ 函数计算: # 取值内容参考:https://api.devsapp.cn/v3/common/args.html
+ Authorities: #权限描述
+ - AliyunFCFullAccess # 所需要的权限,例如AliyunFCFullAccess
+Organization: 阿里云函数计算(FC) # 所属组织
+Effective: Public # 是否公开,取值:Public,Private,Organization
+Parameters:
+ type: object
+ additionalProperties: false # 不允许增加其他属性
+ required: # 必填项
+ - region
+ properties:
+ region:
+ title: 地域
+ type: string
+ default: cn-hangzhou
+ description: 创建应用所在的地区
+ required: true
+ enum:
+ - cn-beijing
+ - cn-hangzhou
+ - cn-shanghai
+ - cn-shenzhen
+ - ap-southeast-1
+ functionName:
+ title: 函数名
+ type: string
+ pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$"
+ default: start-mcp-server-python-${default-suffix}
+ description: 函数名,支持字母、数字、下划线、连字符,不能以数字或连字符开头,长度为1~64个字符。
diff --git a/fc-python/start-mcp-server/readme.md b/fc-python/start-mcp-server/readme.md
new file mode 100644
index 0000000..5ecfdb9
--- /dev/null
+++ b/fc-python/start-mcp-server/readme.md
@@ -0,0 +1,124 @@
+
+> 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验) 。
+
+# start-mcp-server-python 帮助文档
+
+
+
+基于 Python 的FC MCP SSE Server案例
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+## 前期准备
+
+使用该项目,您需要有开通以下服务并拥有对应权限:
+
+
+
+
+
+| 服务/业务 | 权限 | 相关文档 |
+| --- | --- | --- |
+| 函数计算 | AliyunFCFullAccess | [帮助文档](https://help.aliyun.com/product/2508973.html) [计费文档](https://help.aliyun.com/document_detail/2512928.html) |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+## 部署 & 体验
+
+
+
+- :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-mcp-server-python) ,
+ [](https://fcnext.console.aliyun.com/applications/create?template=start-mcp-server-python) 该应用。
+
+
+
+
+- 通过 [Serverless Devs Cli](https://docs.serverless-devs.com/user-guide/install) 进行部署:
+ - [安装 Serverless Devs Cli 开发者工具](https://docs.serverless-devs.com/user-guide/install) ,并进行[授权信息配置]( https://docs.serverless-devs.com/user-guide/config) ;
+ - 初始化项目:`s init start-mcp-server-python -d start-mcp-server-python`
+ - 进入项目,并进行项目部署:`cd start-mcp-server-python && s deploy -y`
+
+
+
+## 案例介绍
+
+
+
+基于 FastMCP 和 Starlette 构建的 Serverless 服务端事件(SSE)应用
+
+## 功能特性
+
+- 使用 FastMCP 框架实现 SSE 协议支持
+- 集成 Starlette 高性能 ASGI 服务器
+- 提供示例工具端点 `hello` 返回 "Hello World!"
+- 支持阿里云函数计算部署
+
+
+
+## 使用流程
+
+
+
+### 环境要求
+
+- Python ≥3.10
+- pip 包管理工具
+
+### 安装依赖
+
+```bash
+pip install -r requirements.txt
+```
+
+### 本地运行
+
+```bash
+uvicorn main:app --host 0.0.0.0 --port 9000
+```
+
+
+
+## 注意事项
+
+
+
+
+
+
+
+
+## 开发者社区
+
+您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行:
+
+
+
+|
|
|
+| --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
+|
微信公众号:`serverless` | 钉钉交流群:`33947367` |
+
+
diff --git a/fc-python/start-mcp-server/src/.signore b/fc-python/start-mcp-server/src/.signore
new file mode 100644
index 0000000..32f7757
--- /dev/null
+++ b/fc-python/start-mcp-server/src/.signore
@@ -0,0 +1,2 @@
+./code/.python-version
+./code/uv.lock
\ No newline at end of file
diff --git a/fc-python/start-mcp-server/src/code/.fcignore b/fc-python/start-mcp-server/src/code/.fcignore
new file mode 100644
index 0000000..020b0bf
--- /dev/null
+++ b/fc-python/start-mcp-server/src/code/.fcignore
@@ -0,0 +1,5 @@
+__pycache__
+.venv
+uv.lock
+.python-version
+build
\ No newline at end of file
diff --git a/fc-python/start-mcp-server/src/code/.gitignore b/fc-python/start-mcp-server/src/code/.gitignore
new file mode 100644
index 0000000..020b0bf
--- /dev/null
+++ b/fc-python/start-mcp-server/src/code/.gitignore
@@ -0,0 +1,5 @@
+__pycache__
+.venv
+uv.lock
+.python-version
+build
\ No newline at end of file
diff --git a/fc-python/start-mcp-server/src/code/README.md b/fc-python/start-mcp-server/src/code/README.md
new file mode 100644
index 0000000..eb6b89c
--- /dev/null
+++ b/fc-python/start-mcp-server/src/code/README.md
@@ -0,0 +1,38 @@
+# FC SSE Mcp Server
+
+基于 FastMCP 和 Starlette 构建的 Serverless 服务端事件(SSE)应用
+
+## 功能特性
+
+- 使用 FastMCP 框架实现 SSE 协议支持
+- 集成 Starlette 高性能 ASGI 服务器
+- 提供示例工具端点 `hello` 返回 "Hello World!"
+- 支持阿里云函数计算部署
+
+## 快速开始
+
+### 环境要求
+
+- Python ≥3.10
+- pip 包管理工具
+
+### 安装依赖
+
+```bash
+pip install -r requirements.txt
+```
+
+### 本地运行
+
+```bash
+uvicorn main:app --host 0.0.0.0 --port 9000
+```
+
+## 项目结构
+
+start-mcp-server/
+├── src/
+│ ├── code/
+│ │ ├── main.py # 主应用入口
+│ │ └── pyproject.toml # 依赖配置
+└── s.yaml # Serverless 部署配置
diff --git a/fc-python/start-mcp-server/src/code/main.py b/fc-python/start-mcp-server/src/code/main.py
new file mode 100644
index 0000000..0f4186a
--- /dev/null
+++ b/fc-python/start-mcp-server/src/code/main.py
@@ -0,0 +1,17 @@
+from mcp.server.fastmcp import FastMCP
+from starlette.applications import Starlette
+from starlette.applications import Starlette
+from starlette.routing import Mount
+
+mcp = FastMCP("My App")
+
+@mcp.tool()
+async def hello() -> str:
+ """Return string 'Hello World!'"""
+ return f"Hello World!"
+
+app = Starlette(
+ routes=[
+ Mount('/', app=mcp.sse_app()),
+ ]
+)
diff --git a/fc-python/start-mcp-server/src/code/requirements.txt b/fc-python/start-mcp-server/src/code/requirements.txt
new file mode 100644
index 0000000..1db9829
--- /dev/null
+++ b/fc-python/start-mcp-server/src/code/requirements.txt
@@ -0,0 +1,2 @@
+mcp==1.6.0
+starlette==0.46.1
diff --git a/fc-python/start-mcp-server/src/readme.md b/fc-python/start-mcp-server/src/readme.md
new file mode 100644
index 0000000..5ecfdb9
--- /dev/null
+++ b/fc-python/start-mcp-server/src/readme.md
@@ -0,0 +1,124 @@
+
+> 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验) 。
+
+# start-mcp-server-python 帮助文档
+
+
+
+基于 Python 的FC MCP SSE Server案例
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+## 前期准备
+
+使用该项目,您需要有开通以下服务并拥有对应权限:
+
+
+
+
+
+| 服务/业务 | 权限 | 相关文档 |
+| --- | --- | --- |
+| 函数计算 | AliyunFCFullAccess | [帮助文档](https://help.aliyun.com/product/2508973.html) [计费文档](https://help.aliyun.com/document_detail/2512928.html) |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+## 部署 & 体验
+
+
+
+- :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-mcp-server-python) ,
+ [](https://fcnext.console.aliyun.com/applications/create?template=start-mcp-server-python) 该应用。
+
+
+
+
+- 通过 [Serverless Devs Cli](https://docs.serverless-devs.com/user-guide/install) 进行部署:
+ - [安装 Serverless Devs Cli 开发者工具](https://docs.serverless-devs.com/user-guide/install) ,并进行[授权信息配置]( https://docs.serverless-devs.com/user-guide/config) ;
+ - 初始化项目:`s init start-mcp-server-python -d start-mcp-server-python`
+ - 进入项目,并进行项目部署:`cd start-mcp-server-python && s deploy -y`
+
+
+
+## 案例介绍
+
+
+
+基于 FastMCP 和 Starlette 构建的 Serverless 服务端事件(SSE)应用
+
+## 功能特性
+
+- 使用 FastMCP 框架实现 SSE 协议支持
+- 集成 Starlette 高性能 ASGI 服务器
+- 提供示例工具端点 `hello` 返回 "Hello World!"
+- 支持阿里云函数计算部署
+
+
+
+## 使用流程
+
+
+
+### 环境要求
+
+- Python ≥3.10
+- pip 包管理工具
+
+### 安装依赖
+
+```bash
+pip install -r requirements.txt
+```
+
+### 本地运行
+
+```bash
+uvicorn main:app --host 0.0.0.0 --port 9000
+```
+
+
+
+## 注意事项
+
+
+
+
+
+
+
+
+## 开发者社区
+
+您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行:
+
+
+
+|
|
|
+| --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
+|
微信公众号:`serverless` | 钉钉交流群:`33947367` |
+
+
diff --git a/fc-python/start-mcp-server/src/s.yaml b/fc-python/start-mcp-server/src/s.yaml
new file mode 100644
index 0000000..3997767
--- /dev/null
+++ b/fc-python/start-mcp-server/src/s.yaml
@@ -0,0 +1,46 @@
+edition: 3.0.0
+name: start-mcp-server-python
+access: '{{access}}'
+vars:
+ region: '{{region}}'
+ functionName: '{{functionName}}'
+resources:
+ mcp_server:
+ component: fc3
+ actions:
+ pre-${regex('deploy|local')}:
+ - component: fc3 build
+ props:
+ region: ${vars.region}
+ description: Serverless Devs Python MCP Server
+ runtime: custom.debian10
+ timeout: 60
+ memorySize: 512
+ logConfig: auto
+ environmentVariables:
+ PYTHONPATH: /code/python
+ PATH: /code/python/bin:/var/fc/lang/python3.10/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin
+ customRuntimeConfig:
+ port: 3000
+ command:
+ - uvicorn
+ - main:app
+ - --host
+ - '0.0.0.0'
+ - --port
+ - '3000'
+ functionName: ${vars.functionName}
+ code: ./code
+ instanceConcurrency: 10
+ triggers:
+ - triggerName: httpTrigger
+ triggerType: http
+ triggerConfig:
+ authType: anonymous
+ methods:
+ - GET
+ - POST
+ - PUT
+ - DELETE
+ - HEAD
+ - OPTIONS
diff --git a/fc-python/start-mcp-server/version.md b/fc-python/start-mcp-server/version.md
new file mode 100644
index 0000000..4ee89d2
--- /dev/null
+++ b/fc-python/start-mcp-server/version.md
@@ -0,0 +1,2 @@
+- 初始化项目
+- 测试项目模板
\ No newline at end of file