Skip to content

pub: 0.0.3 #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions fc-node/start-mcp-server/publish.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,7 +21,6 @@ Parameters:
additionalProperties: false # 不允许增加其他属性
required: # 必填项
- region
- functionName
properties:
region:
title: 地域
Expand All @@ -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个字符。
3 changes: 1 addition & 2 deletions fc-node/start-mcp-server/src/s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: start-mcp-server-nodejs
access: '{{access}}'
vars:
region: '{{region}}'
functionName: '{{functionName}}'
resources:
mcp_server:
component: fc3
Expand All @@ -26,7 +25,7 @@ resources:
- node
- ./dist/index.js
port: 3000
functionName: ${vars.functionName}
functionName: '{{functionName}}'
code: ./code
instanceConcurrency: 10
triggers:
Expand Down
12 changes: 12 additions & 0 deletions fc-python/start-mcp-server/hook/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
async function preInit(inputObj) {

}

async function postInit(inputObj) {

}

module.exports = {
postInit,
preInit
}
41 changes: 41 additions & 0 deletions fc-python/start-mcp-server/publish.yaml
Original file line number Diff line number Diff line change
@@ -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个字符。
124 changes: 124 additions & 0 deletions fc-python/start-mcp-server/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@

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

# start-mcp-server-python 帮助文档

<description>

基于 Python 的FC MCP SSE Server案例

</description>

<codeUrl>



</codeUrl>
<preview>



</preview>


## 前期准备

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

<service>



| 服务/业务 | 权限 | 相关文档 |
| --- | --- | --- |
| 函数计算 | AliyunFCFullAccess | [帮助文档](https://help.aliyun.com/product/2508973.html) [计费文档](https://help.aliyun.com/document_detail/2512928.html) |

</service>

<remark>



</remark>

<disclaimers>



</disclaimers>

## 部署 & 体验

<appcenter>

- :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-mcp-server-python) ,
[![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-mcp-server-python) 该应用。

</appcenter>
<deploy>

- 通过 [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`

</deploy>

## 案例介绍

<appdetail id="flushContent">

基于 FastMCP 和 Starlette 构建的 Serverless 服务端事件(SSE)应用

## 功能特性

- 使用 FastMCP 框架实现 SSE 协议支持
- 集成 Starlette 高性能 ASGI 服务器
- 提供示例工具端点 `hello` 返回 "Hello World!"
- 支持阿里云函数计算部署

</appdetail>

## 使用流程

<usedetail id="flushContent">

### 环境要求

- Python ≥3.10
- pip 包管理工具

### 安装依赖

```bash
pip install -r requirements.txt
```

### 本地运行

```bash
uvicorn main:app --host 0.0.0.0 --port 9000
```

</usedetail>

## 注意事项

<matters id="flushContent">
</matters>


<devgroup>


## 开发者社区

您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行:

<p align="center">

| <img src="https://img.alicdn.com/imgextra/i2/O1CN010Sk7sv1Xl6WuOb6uU_!!6000000002963-0-tps-666-662.jpg" width="130px" > | <img src="https://img.alicdn.com/imgextra/i4/O1CN010Vt5aw27VN5rJIguB_!!6000000007802-0-tps-668-630.jpg" width="130px" > |
| --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| <center>微信公众号:`serverless`</center> | <center>钉钉交流群:`33947367`</center> |
</p>
</devgroup>
2 changes: 2 additions & 0 deletions fc-python/start-mcp-server/src/.signore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
./code/.python-version
./code/uv.lock
5 changes: 5 additions & 0 deletions fc-python/start-mcp-server/src/code/.fcignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__pycache__
.venv
uv.lock
.python-version
build
5 changes: 5 additions & 0 deletions fc-python/start-mcp-server/src/code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__pycache__
.venv
uv.lock
.python-version
build
38 changes: 38 additions & 0 deletions fc-python/start-mcp-server/src/code/README.md
Original file line number Diff line number Diff line change
@@ -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 部署配置
17 changes: 17 additions & 0 deletions fc-python/start-mcp-server/src/code/main.py
Original file line number Diff line number Diff line change
@@ -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()),
]
)
2 changes: 2 additions & 0 deletions fc-python/start-mcp-server/src/code/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mcp==1.6.0
starlette==0.46.1
Loading