From 5a971ccd103f14caef0ec2898e177e87a4b141a5 Mon Sep 17 00:00:00 2001 From: wgm7512 Date: Wed, 29 Apr 2026 17:28:07 +0800 Subject: [PATCH] fix: user manual revision --- .../sdk_user_guide/mcp_gateway_user_guide.md | 25 ++++++++++--------- docs/cn/toolkit_user_guide/mcp_gateway_cli.md | 14 ++++------- .../sdk/mcpgateway/mcp_gateway_client.py | 2 +- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/docs/cn/sdk_user_guide/mcp_gateway_user_guide.md b/docs/cn/sdk_user_guide/mcp_gateway_user_guide.md index 570f1bf..429c6d4 100644 --- a/docs/cn/sdk_user_guide/mcp_gateway_user_guide.md +++ b/docs/cn/sdk_user_guide/mcp_gateway_user_guide.md @@ -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}") @@ -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 参考 @@ -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 ``` @@ -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"} | 出站网络配置 | @@ -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 ``` @@ -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` 对象 diff --git a/docs/cn/toolkit_user_guide/mcp_gateway_cli.md b/docs/cn/toolkit_user_guide/mcp_gateway_cli.md index 557b302..191847a 100644 --- a/docs/cn/toolkit_user_guide/mcp_gateway_cli.md +++ b/docs/cn/toolkit_user_guide/mcp_gateway_cli.md @@ -44,9 +44,9 @@ 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) | @@ -54,7 +54,6 @@ agentarts mcp-gateway create-mcp-gateway [options] | --authorizer-configuration | 无 | 否 | None | 授权器配置(JSON 格式) | | --log-delivery-configuration | 无 | 否 | None | 日志投递配置(JSON 格式) | | --outbound-network-configuration | 无 | 否 | None | 出站网络配置(JSON 格式) | -| --tags | 无 | 否 | None | 网关标签 | **使用示例**: ```bash # 基本创建 @@ -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 网关。 @@ -78,7 +76,6 @@ agentarts mcp-gateway update-mcp-gateway [options] | --description | -d | 否 | None | 网关描述 | | --authorizer-configuration | 无 | 否 | None | 授权器配置(JSON 格式) | | --log-delivery-configuration | 无 | 否 | None | 日志投递配置(JSON 格式) | -| --tags | 无 | 否 | None | 网关标签 | **使用示例**: ```bash # 更新描述 @@ -86,7 +83,7 @@ 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 网关。 @@ -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 | 分页偏移量 | **使用示例**: @@ -147,7 +143,7 @@ agentarts mcp-gateway create-mcp-gateway-target [options] | 参数 | 简写 | 必填 | 默认值 | 说明 | |------|------|------|--------|------| | gateway_id | 无 | 是 | - | 网关 ID(位置参数) | -| --name | -n | 否 | TestGatewayTarget-{random} | 目标名称 | +| --name | -n | 否 | target-{random} | 目标名称 | | --description | -d | 否 | None | 目标描述 | | --target-configuration | 无 | 否 | None | 目标配置(JSON 格式) | | --credential-provider-configuration | 无 | 否 | None | 凭证提供者配置(JSON 格式) | diff --git a/src/agentarts/sdk/mcpgateway/mcp_gateway_client.py b/src/agentarts/sdk/mcpgateway/mcp_gateway_client.py index c569a9d..4cdb452 100644 --- a/src/agentarts/sdk/mcpgateway/mcp_gateway_client.py +++ b/src/agentarts/sdk/mcpgateway/mcp_gateway_client.py @@ -78,7 +78,7 @@ def create_mcp_gateway( "Statement": [ { "Action": [ - "csms:secret:getVersion" + "csms:secret:getVersion", "agentIdentity::getResourceApiKey", "agentIdentity::getResourceOauth2Token", "agentIdentity::getResourceStsToken",