Skip to content

Commit 05c99ae

Browse files
committed
chore: refine prompt and update README
1 parent 4d1f7cd commit 05c99ae

File tree

2 files changed

+55
-82
lines changed

2 files changed

+55
-82
lines changed
Lines changed: 30 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,10 @@
11
# veFaaS MCP Server
22

3-
veFaaS MCP Server 提供创建、更新、发布函数和添加触发器的能力
3+
veFaaS MCP Server 提供创建、更新、发布 veFaaS 函数以及管理应用的自动化能力,帮助在 MCP 体系内快速对接 veFaaS 服务
44

5-
| | |
6-
|------|------|
7-
| 描述 | veFaaS MCP Server 助你轻松管理函数和触发器生命周期|
8-
| 分类 | 容器与中间件 |
9-
| 标签 | FaaS,函数服务,函数,生命周期 |
5+
## 安装与快速开始
106

11-
## 能力概览
12-
13-
- 创建/更新/发布 veFaaS 函数,并管理依赖安装与触发器配置。
14-
- 支持上传本地代码或通过已有制品(TOS、镜像)更新函数。
15-
- 覆盖 API 网关触发器和函数列表/存在性查询等补充能力。
16-
17-
最新的参数、调用约束和注意事项都写在 `src/mcp_server_vefaas_function/vefaas_server.py` 的工具描述中,优先以代码为准。
18-
19-
## 推荐流程
20-
21-
1. `create_function` 创建函数(或确认已有函数 ID)。
22-
2. `upload_code` 推送代码,必要时排除 `.venv``node_modules` 等本地依赖。
23-
3. 如果触发了依赖安装任务,使用 `get_dependency_install_task_status` 轮询直至 `Succeeded/Failed`
24-
4. 重新发布:`release_function`,随后持续调用 `get_function_release_status` 直到成功或失败。
25-
5. 发布成功后,再创建 API 网关触发器或其它下游资源。
26-
27-
## 支持的运行时
28-
29-
- `native-python3.12/v1`
30-
- `native-node20/v1`
31-
- `native/v1`
32-
33-
以上运行时均为原生环境,仅提供解释器/运行时,不包含任何 Web 框架或额外工具。请把依赖声明在 `requirements.txt` / `package.json` 中,由 veFaaS 自动安装。
34-
35-
## 常见注意事项
36-
37-
- 本地修改完成后务必重新执行 `upload_code`;直接调用 `release_function` 只会复用旧制品。
38-
- 依赖安装长时间 `InProgress` 时,遵循工具描述中的退避策略并及时上报。
39-
- API 网关相关操作在创建触发器前应复用现有关联服务,避免重复创建。
40-
41-
## 可适配平台
42-
43-
streamable-http: 方舟,Python
44-
stdio: Python, Cursor, Claude macOS App, Cline
45-
46-
## 服务开通链接 (整体产品)
47-
48-
<https://console.volcengine.com/vefaas>
49-
50-
## 鉴权方式
51-
52-
OAuth 2.0
53-
54-
## 在不同平台的配置
55-
56-
### 方舟
57-
58-
#### 体验中心
59-
60-
1. 查看 MCP Server 详情
61-
在大模型生态广场,选择合适的 veFaaS MCP Server,并查看详情
62-
2. 选择 MCP Server 即将运行的平台
63-
检查当前 MCP Server 已适配的平台,并选择合适的平台
64-
3. 查看并对比可用的 Tools
65-
仔细查看可用的 Tools 的功能描述与所需的输入参数,并尝试运行对应的功能。
66-
4. 获取专属的URL或代码示例
67-
检查账号登录状态与服务开通情况,生成唯一URL
68-
5. 去对应的Client的平台进行使用
69-
点击快捷跳转按钮,前往方舟平台的体验中心进行对应MCP Server的体验
70-
71-
### UVX
72-
73-
请预先获取环境变量 VOLCENGINE_ACCESS_KEY 和 VOLCENGINE_SECRET_KEY。
7+
推荐使用 `uvx` 在本地快速拉起服务,请将 VOLCENGINE_ACCESS_KEY 和 VOLCENGINE_SECRET_KEY 内容替换为您账号的 AK/SK。
748

759
```json
7610
{
@@ -91,6 +25,33 @@ OAuth 2.0
9125
}
9226
```
9327

28+
## 前置条件与注意事项
29+
30+
- 凭证管理:AK/SK 为账号敏感信息,请妥善保管,避免泄露。
31+
- 服务开通:生成公网访问链接依赖 API 网关等前置资源,使用前请确认账号已在控制台开通相关服务。
32+
- 代码包与运行时:编译型语言需先在本地生成 Linux 可执行文件;解释型语言需提供启动脚本和依赖声明文件(`requirements.txt` / `package.json`)以便平台自动安装依赖。
33+
- 模型与 Agent 效果:MCP 的执行效果受所选模型和 Agent 策略影响,若结果不理想,可补充上下文、调整提示词或切换模型/Agent。
34+
35+
## 能力概览
36+
37+
- 函数生命周期:创建、更新、发布、删除 veFaaS 函数,支持本地代码包、TOS 制品或镜像等多种来源。
38+
- 代码与依赖:上传代码、触发依赖安装任务、轮询安装状态,并可下载线上代码。
39+
- 运行时与配置:管理命令、环境变量、VPC 配置等基础属性。
40+
- 应用与访问:查询可用的 API 网关资源,创建并发布 veFaaS 应用,检索模板信息。
41+
42+
## 支持的运行时
43+
44+
- `native-python3.12/v1`
45+
- `native-node20/v1`
46+
- `native/v1`
47+
48+
以上运行时均为原生环境,仅提供解释器/运行时,不包含额外框架或工具。
49+
50+
## 官方资源
51+
52+
- veFaaS 控制台:<https://console.volcengine.com/vefaas>
53+
- veFaaS MCP 操作文档:<https://www.volcengine.com/docs/6662/1852853#VCm9Uhw2>
54+
9455
## License
9556

9657
volcengine/mcp-server is licensed under the MIT License.

server/mcp_server_vefaas_function/src/mcp_server_vefaas_function/vefaas_server.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ def validate_and_set_region(region: str = None) -> str:
7777
7878
Note:
7979
- veFaaS Application is the top-level collection that contains veFaaS function, api-gateway and other production.
80-
- After all steps done, provide veFaaS Application infos like application_id, name, region and platform link if these info can get from context directly.
81-
- veFaaS platform link template: https://console.volcengine.com/vefaas/region:vefaas+`region`/application/detail/`application_id`?tab=detail
8280
8381
Error Handle Tips:
8482
- If there is **any authentication** error about vefaas application(create/release/get), let user apply auth by link: https://console.volcengine.com/iam/service/attach_custom_role?ServiceName=vefaas&policy1_1=APIGFullAccess&policy1_2=VeFaaSFullAccess&role1=ServerlessApplicationRole, then retry.
@@ -234,6 +232,7 @@ def get_vefaas_application(application_id: Required[str], region: Optional[str]
234232
Note:
235233
- veFaaS Application status **NOT** related to veFaaS function release status.
236234
- Usually use this tool to check application deployment status after application release.
235+
- **MUST** provide some important info for user after application deployment finished: application_id, region, deployment status, access_url and app_platform_url. (can get these info from tool return value)
237236
238237
""")
239238
def poll_vefaas_application_status(application_id: Required[str], region: Optional[str] = None):
@@ -291,13 +290,23 @@ def poll_vefaas_application_status(application_id: Required[str], region: Option
291290
errLogs.append("Failed to release application due to an authentication error. Please visit https://console.volcengine.com/iam/service/attach_custom_role?ServiceName=vefaas&policy1_1=APIGFullAccess&policy1_2=VeFaaSFullAccess&role1=ServerlessApplicationRole to grant the required permissions and then try again.")
292291
except Exception as e:
293292
logger.error(f"Failed to get application log: {str(e)}")
294-
293+
294+
# get system_url
295+
system_url = ""
296+
try:
297+
cloud_resource = json.loads(result["CloudResource"])
298+
system_url = cloud_resource['framework']['url']['system_url']
299+
except Exception as e:
300+
logger.error(f"Failed to get system_url: {str(e)}")
301+
295302
responseInfo = {
296303
"Id": result["Id"],
297304
"Name": result["Name"],
298305
"Status": result["Status"],
299306
"Config": result["Config"],
300307
"Region": result["Region"],
308+
"AccessUrl": system_url,
309+
"AppPlatformUrl": f"https://console.volcengine.com/vefaas/region:vefaas+{region}/application/detail/{application_id}?tab=detail",
301310
"NewRevisionNumber": result.get("NewRevisionNumber"),
302311
}
303312
if len(errLogs) > 0:
@@ -319,10 +328,6 @@ def poll_vefaas_application_status(application_id: Required[str], region: Option
319328
- command **MUST** be a runnable script, e.g., `./run.sh`.
320329
- region **MUST** be `cn-beijing`, `cn-shanghai`, `cn-guangzhou`, or `ap-southeast-1`.
321330
- Supplying `enable_vpc=true` requires `vpc_id`, `subnet_ids`, and `security_group_ids`.
322-
- Declare every framework/server dependency in `requirements.txt` / `package.json`; do not bundle virtualenvs.
323-
- Module CLIs are not on PATH. Invoke them with `python -m module_name ...` or start the server in code—running `gunicorn ...` or `uvicorn ...` directly will fail.
324-
- Keep startup scripts focused on launching the app; skip extra installs/build once `upload_code` has run.
325-
- Store templates/static assets as files and sanity-check imports before uploading.
326331
- After all steps done, provide veFaaS function infos like function_id, name, region, runtime and platfrom link if these infos can get from context directly.
327332
- veFaaS platform link template: https://console.volcengine.com/vefaas/region:vefaas+`region`/function/detail/`function_id`?tab=config
328333
@@ -614,6 +619,8 @@ def get_function_release_status(function_id: str, region: str = None):
614619
615620
**CRITICAL REQUIREMENT**:
616621
- Can **only** use this tool to check vefaas function release status, **NEVER** try to get release status by other ways.
622+
- After function release finished, provide some important info for user: function_id, region, release status, and vefaas function platform url.
623+
- `vefaas function platform url` is `https://console.volcengine.com/vefaas/function/detail?functionId={function_id}&region={region}`
617624
""")
618625
def poll_function_release_status(function_id: str, region: str = None):
619626
region = validate_and_set_region(region)
@@ -630,7 +637,8 @@ def poll_function_release_status(function_id: str, region: str = None):
630637
if response.status == "inprogress":
631638
time.sleep(interval)
632639
else:
633-
return response
640+
break
641+
634642
return response
635643

636644
def generate_random_name(prefix="mcp", length=8):
@@ -691,7 +699,7 @@ def list_existing_api_gateways(region: str = None):
691699
if gateway.get("Region") == region and gateway.get("Status") in ["Running", "Creating"]:
692700
result.append({
693701
"Name": gateway.get("Name", ""),
694-
"ID": gateway.get("ID", ""),
702+
"ID": gateway.get("Id", ""),
695703
"Region": gateway.get("Region", ""),
696704
"Type": gateway.get("Type", ""),
697705
"Status": gateway.get("Status", ""),
@@ -746,7 +754,7 @@ def create_api_gateway(name: str = None, region: str = "cn-beijing"):
746754
Note:
747755
- Use this tool to select one running api gateway for create veFaaS Application.
748756
- If no running gateway exists, will create a new one and wait for it to be running.
749-
- If can this tool can not fetch a running gateway after timeout, please retry and at most try 3 times.
757+
- If can this tool returned error, should retry and at most retry 3 times.
750758
""")
751759

752760
def fetch_running_api_gateway(region: str = None):
@@ -784,9 +792,9 @@ def fetch_running_api_gateway(region: str = None):
784792
raise Exception(f"Failed to create API Gateway after {create_api_gateway_failed_times} times")
785793
time.sleep(interval)
786794
except Exception as e:
787-
return f"Failed to fetch an running API Gateway: {str(e)}"
795+
raise Exception(f"Failed to fetch an running API Gateway: {str(e)}")
788796

789-
return f"Failed to fetch an running API Gateway after {timeout} seconds"
797+
raise Exception(f"Failed to fetch an running API Gateway after {timeout} seconds")
790798

791799
def ensure_executable_permissions(folder_path: str):
792800
for root, _, files in os.walk(folder_path):
@@ -922,7 +930,11 @@ def _get_upload_code_description() -> str:
922930
" - Rule 4: Python/Node deps: put them in 'requirements.txt'/'package.json'; veFaaS installs them as needed.\n"
923931
" - Rule 5: HTTP server **MUST** listen on IP: 0.0.0.0, PORT: 8000.\n"
924932
" - Rule 6: Store templates/static assets as files and sanity-check imports before uploading.\n"
925-
" - Rule 7: When uploading code, exclude local deps and noise (e.g., `.venv`, `site-packages`, `node_modules`, `.git`, build artifacts) via `local_folder_exclude`.\n\n"
933+
" - Rule 7: Declare every framework/server dependency in `requirements.txt` / `package.json`; do not bundle virtualenvs.\n"
934+
" - Rule 8: Module CLIs are not on PATH. Invoke them with `python -m module_name ...` or start the server in code—running `gunicorn ...` or `uvicorn ...` directly will fail.\n"
935+
" - Rule 9: Keep startup scripts focused on launching the app; skip extra installs/build once `upload_code` has run.\n"
936+
" - Rule 10: Store templates/static assets as files and sanity-check imports before uploading.\n"
937+
" - Rule 11: When uploading code, exclude local deps and noise (e.g., `.venv`, `site-packages`, `node_modules`, `.git`, build artifacts) via `local_folder_exclude`.\n\n"
926938
)
927939

928940
# Detect run mode via FASTMCP_* environment variables.

0 commit comments

Comments
 (0)