Skip to content
Merged
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
25 changes: 13 additions & 12 deletions docs/cn/sdk_user_guide/mcp_gateway_user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,30 @@ result = client.create_mcp_gateway(
authorizer_type="iam"
)

gateway_id = None
if result.success:
gateway_id = result.data.get("id")
gateway_id = result.data.get("gateway_id")
print(f"网关创建成功,ID: {gateway_id}")
else:
print(f"创建网关失败: {result.error}")

# 创建目标
if gateway_id:
if gateway_id is not None:
target_result = client.create_mcp_gateway_target(
gateway_id=gateway_id,
name="my-target",
description="我的 MCP 目标",
target_configuration={
"endpoint": "https://api.example.com",
"timeout": 30
"mcp_server": {
"endpoint": "https://example.com/mcp",
"server_type": "sse"
}
}
)

if target_result.success:
target_id = target_result.data.get("id")
target = target_result.data.get("target")
target_id = target.get("target_id")
print(f"目标创建成功,ID: {target_id}")
else:
print(f"创建目标失败: {target_result.error}")
Expand All @@ -76,7 +80,7 @@ list_result = client.list_mcp_gateways()
if list_result.success:
print(f"总网关数: {list_result.data.get('total', 0)}")
for gateway in list_result.data.get('gateways', []):
print(f"- {gateway.get('name')} (ID: {gateway.get('id')})")
print(f"- {gateway.get('name')} (ID: {gateway.get('gateway_id')})")
```

## API 参考
Expand Down Expand Up @@ -115,8 +119,7 @@ create_mcp_gateway(
agency_name: Optional[str] = None,
authorizer_configuration: Optional[Dict[str, Any]] = None,
log_delivery_configuration: Optional[Dict[str, Any]] = None,
outbound_network_configuration: Optional[Dict[str, Any]] = None,
tags: Optional[List[str]] = None
outbound_network_configuration: Optional[Dict[str, Any]] = None
) -> RequestResult
```

Expand All @@ -128,7 +131,7 @@ create_mcp_gateway(
| description | str | 否 | None | 网关描述 |
| protocol_type | str | 否 | mcp | 协议类型 |
| authorizer_type | str | 否 | iam | 授权器类型(custom_jwt/iam/api_key) |
| agency_name | str | 否 | None | 代理名称 |
| agency_name | str | 否 | None | 代理名称。未提供时自动创建名为 AgentArtsCoreGateway 的代理 |
| authorizer_configuration | Dict | 否 | None | 授权器配置 |
| log_delivery_configuration | Dict | 否 | {"enabled": False} | 日志投递配置 |
| outbound_network_configuration | Dict | 否 | {"network_mode": "public"} | 出站网络配置 |
Expand All @@ -146,8 +149,7 @@ update_mcp_gateway(
gateway_id: str,
description: Optional[str] = None,
authorizer_configuration: Optional[Dict[str, Any]] = None,
log_delivery_configuration: Optional[Dict[str, Any]] = None,
outbound_network_configuration: Optional[Dict[str, Any]] = None
log_delivery_configuration: Optional[Dict[str, Any]] = None
) -> RequestResult
```

Expand All @@ -159,7 +161,6 @@ update_mcp_gateway(
| description | str | 否 | None | 网关描述 |
| authorizer_configuration | Dict | 否 | None | 授权器配置 |
| log_delivery_configuration | Dict | 否 | None | 日志投递配置 |
| outbound_network_configuration | Dict | 否 | None | 出站网络配置 |

**返回值**:`RequestResult` 对象

Expand Down
14 changes: 5 additions & 9 deletions docs/cn/toolkit_user_guide/mcp_gateway_cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,16 @@ agentarts mcp-gateway [command] [options]
agentarts mcp-gateway create-mcp-gateway [options]
```
**参数说明**:
| 参数 | 結写 | 必填 | 默认值 | 说明 |
| 参数 | 简写 | 必填 | 默认值 | 说明 |
|------|------|------|--------|------|
| --name | -n | 否 | TestGateway-{random} | 网关名称 |
| --name | -n | 否 | gateway-{random} | 网关名称 |
| --description | -d | 否 | None | 网关描述 |
| --protocol-type | 无 | 否 | mcp | 协议类型 |
| --authorizer-type | 无 | 否 | iam | 授权器类型(custom_jwt/iam/api_key) |
| --agency-name | 无 | 否 | None | 代理名称 |
| --authorizer-configuration | 无 | 否 | None | 授权器配置(JSON 格式) |
| --log-delivery-configuration | 无 | 否 | None | 日志投递配置(JSON 格式) |
| --outbound-network-configuration | 无 | 否 | None | 出站网络配置(JSON 格式) |
| --tags | 无 | 否 | None | 网关标签 |
**使用示例**:
```bash
# 基本创建
Expand All @@ -63,8 +62,7 @@ agentarts mcp-gateway create-mcp-gateway --name my-gateway --description "我的
agentarts mcp-gateway create-mcp-gateway \
--name my-gateway \
--description "生产环境网关" \
--authorizer-type iam \
--tags "production,api"
--authorizer-type iam
```
### update-mcp-gateway
更新现有的 MCP 网关。
Expand All @@ -78,15 +76,14 @@ agentarts mcp-gateway update-mcp-gateway <gateway_id> [options]
| --description | -d | 否 | None | 网关描述 |
| --authorizer-configuration | 无 | 否 | None | 授权器配置(JSON 格式) |
| --log-delivery-configuration | 无 | 否 | None | 日志投递配置(JSON 格式) |
| --tags | 无 | 否 | None | 网关标签 |
**使用示例**:
```bash
# 更新描述
agentarts mcp-gateway update-mcp-gateway 123 --description "更新后的描述"
# 更新多个配置
agentarts mcp-gateway update-mcp-gateway 123 \
--description "新描述" \
--tags "production,updated"
--log-delivery-configuration '{"enabled": true}'
```
### delete-mcp-gateway
删除 MCP 网关。
Expand Down Expand Up @@ -125,7 +122,6 @@ agentarts mcp-gateway list-mcp-gateways [options]
| --name | 无 | 否 | None | 网关名称过滤器 |
| --status | 无 | 否 | None | 网关状态过滤器 |
| --gateway-id | 无 | 否 | None | 网关 ID 过滤器 |
| --tags | 无 | 否 | None | 网关标签过滤器 |
| --limit | 无 | 否 | 50 | 分页限制(1-50) |
| --offset | 无 | 否 | 0 | 分页偏移量 |
**使用示例**:
Expand All @@ -147,7 +143,7 @@ agentarts mcp-gateway create-mcp-gateway-target <gateway_id> [options]
| 参数 | 简写 | 必填 | 默认值 | 说明 |
|------|------|------|--------|------|
| gateway_id | 无 | 是 | - | 网关 ID(位置参数) |
| --name | -n | 否 | TestGatewayTarget-{random} | 目标名称 |
| --name | -n | 否 | target-{random} | 目标名称 |
| --description | -d | 否 | None | 目标描述 |
| --target-configuration | 无 | 否 | None | 目标配置(JSON 格式) |
| --credential-provider-configuration | 无 | 否 | None | 凭证提供者配置(JSON 格式) |
Expand Down
2 changes: 1 addition & 1 deletion src/agentarts/sdk/mcpgateway/mcp_gateway_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def create_mcp_gateway(
"Statement": [
{
"Action": [
"csms:secret:getVersion"
"csms:secret:getVersion",
"agentIdentity::getResourceApiKey",
"agentIdentity::getResourceOauth2Token",
"agentIdentity::getResourceStsToken",
Expand Down
Loading