启用 沙箱 MCP 服务,用于客户端通过MCP协议进行访问沙箱。
接口说明
启动后,会自动部署沙箱模板对应的 MCP 服务函数,MCP 服务保证 mcp-session-id 和 SandboxID 的唯一映射。MCP client 执行工具调用时,MCP 服务会自动创建 Sandbox
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
请求语法
PATCH /2025-09-10/templates/{templateName}/mcp/activate HTTP/1.1
路径参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| templateName |
string |
否 |
模板名称 |
demo-template |
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| body |
object |
否 |
请求 Body。 |
|
| enabledTools |
array |
否 |
启用的工具列表 |
|
|
string |
否 |
enabledTools |
["health","run_code","list_contexts","create_context","get_context","delete_context","read_file","write_file","file_system_list","file_system_stat","file_system_download","file_system_mkdir","file_system_move","file_system_remove","file_system_upload","process_exec_cmd","process_tty","process_list","process_stat","process_kill"] |
|
| transport |
string |
否 |
传输协议 |
streamable-http |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
| TemplateResult |
沙箱模板详情 |
示例
正常返回示例
JSON格式
{
"code": "SUCCESS",
"requestId": "F8A0F5F3-0C3E-4C82-9D4F-5E4B6A7C8D9E",
"data": {
"templateId": "996ffd5e-003f-4700-9f24-9e2a1c19019b.schema",
"templateName": "browser-1767874121726",
"templateVersion": "预留",
"cpu": 4,
"memory": 4096,
"templateArn": "acs:agentrun:cn-hangzhou:12345678:templates/efb6de2f-1814-42a2-b7f3-474a0e0b3a48",
"createdAt": "2026-01-15T17:12:59.375168+08:00",
"lastUpdatedAt": "2026-01-15T17:12:59.375168+08:00",
"status": "READY",
"statusReason": "SDK Error",
"executionRoleArn": "acs:agentrun:cn-hangzhou:12345678:templates/efb6de2f-1814-42a2-b7f3-474a0e0b3a48",
"templateType": "Browser",
"containerConfiguration": {
"image": "registry.cn-hangzhou.aliyuncs.com/my-namespace/agent-runtime:latest",
"imageRegistryType": "ACR",
"acrInstanceId": "cri-xxxxx",
"command": [
"/usr/local/bin/entrypoint.sh"
],
"registryConfig": {
"authConfig": {
"userName": "admin",
"password": "abc***"
},
"certConfig": {
"insecure": false,
"rootCaCertBase64": "cm9vdF9jYV9jZXJ0X2Jhc2U2NA=="
},
"networkConfig": {
"vpcId": "vpc-xxxxxxxxxxxxx",
"vSwitchId": "vsw-xxxxxxxxxxxxx",
"securityGroupId": "sg-xxxxxxxxxxxxx"
}
},
"port": 5000
},
"networkConfiguration": {
"networkMode": "PRIVATE",
"vpcId": "vpc-1234567890abcdef0",
"securityGroupId": "sg-1234567890abcdef0",
"vswitchIds": [
"vsw-sg-1234567890abcdef0"
]
},
"credentialConfiguration": {
"credentialName": "deepagent-key"
},
"logConfiguration": {
"project": "agent-runtime-logs",
"logstore": "agent-runtime-logs"
},
"sandboxIdleTimeoutInSeconds": "1800",
"sandboxTTLInSeconds": "已弃用",
"resourceName": "agentrun-f2570dd4-c8a2-452c-8bd5-4ef74b0a69b5",
"mcpOptions": {
"transport": "streamable-http",
"enabledTools": [
"execute_code"
]
},
"mcpState": {
"status": "CREATING",
"statusReason": "SDK Error",
"accessEndpoint": "/mcp"
},
"diskSize": 10240,
"description": "template描述",
"allowAnonymousManage": true,
"nasConfig": {
"groupId": 100,
"mountPoints": [
{
"enableTLS": true,
"mountDir": "/home/test",
"serverAddr": "***-uni85.cn-hangzhou.nas.com:/"
}
],
"userId": 100
},
"enableAgent": true,
"workspaceId": "",
"scalingStatus": {
"minInstances": 1,
"targetInstances": 2,
"currentInstances": 2,
"scheduledPolicies": [
{
"name": "scale-up-morning",
"startTime": "2024-01-01T08:00:00",
"endTime": "2024-01-01T08:00:00",
"scheduleExpression": "cron(0 8 * * ? *)",
"timeZone": "Asia/Shanghai",
"target": 20
}
],
"currentError": "error"
},
"environmentVariables": {
"key": "{'FCTEST_IDE_ENV': 'IDE'}"
},
"templateConfiguration": {
"key": "{\"example\":\"test\"}"
},
"ossConfiguration": [
{
"bucketName": "a-test-oss",
"prefix": "/",
"mountPoint": "/mnt/oss1",
"permission": "READ_WRITE",
"region": "ch-hangzhou"
}
],
"enablePreStop": true,
"preStopTimeoutInSeconds": 0
}
}
错误码
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。