agentkit-sdk-python 0.1.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agentkit/__init__.py +23 -0
- agentkit/apps/__init__.py +58 -0
- agentkit/apps/a2a_app/__init__.py +13 -0
- agentkit/apps/a2a_app/a2a_app.py +134 -0
- agentkit/apps/a2a_app/telemetry.py +119 -0
- agentkit/apps/agent_server_app/__init__.py +13 -0
- agentkit/apps/agent_server_app/agent_server_app.py +85 -0
- agentkit/apps/base_app.py +20 -0
- agentkit/apps/mcp_app/__init__.py +13 -0
- agentkit/apps/mcp_app/mcp_app.py +150 -0
- agentkit/apps/mcp_app/telemetry.py +115 -0
- agentkit/apps/simple_app/__init__.py +13 -0
- agentkit/apps/simple_app/simple_app.py +94 -0
- agentkit/apps/simple_app/simple_app_handlers.py +325 -0
- agentkit/apps/simple_app/telemetry.py +124 -0
- agentkit/apps/utils.py +45 -0
- agentkit/client/__init__.py +26 -0
- agentkit/client/base_client.py +219 -0
- agentkit/identity/__init__.py +13 -0
- agentkit/identity/auth.py +70 -0
- agentkit/knowledge/__init__.py +47 -0
- agentkit/knowledge/knowledge.py +203 -0
- agentkit/knowledge/knowledge_all_types.py +191 -0
- agentkit/mcp/__init__.py +79 -0
- agentkit/mcp/mcp.py +294 -0
- agentkit/mcp/mcp_all_types.py +1212 -0
- agentkit/memory/__init__.py +71 -0
- agentkit/memory/memory.py +236 -0
- agentkit/memory/memory_all_types.py +358 -0
- agentkit/runtime/__init__.py +13 -0
- agentkit/runtime/runtime.py +191 -0
- agentkit/runtime/runtime_all_types.py +624 -0
- agentkit/runtime/runtime_v1.py +178 -0
- agentkit/runtime/types.py +188 -0
- agentkit/toolkit/__init__.py +13 -0
- agentkit/toolkit/cli/__init__.py +13 -0
- agentkit/toolkit/cli/__main__.py +7 -0
- agentkit/toolkit/cli/cli.py +97 -0
- agentkit/toolkit/cli/cli_build.py +53 -0
- agentkit/toolkit/cli/cli_config.py +170 -0
- agentkit/toolkit/cli/cli_deploy.py +52 -0
- agentkit/toolkit/cli/cli_destroy.py +53 -0
- agentkit/toolkit/cli/cli_init.py +364 -0
- agentkit/toolkit/cli/cli_invoke.py +168 -0
- agentkit/toolkit/cli/cli_launch.py +34 -0
- agentkit/toolkit/cli/cli_status.py +53 -0
- agentkit/toolkit/cli/cli_version.py +87 -0
- agentkit/toolkit/cli/utils.py +47 -0
- agentkit/toolkit/config/__init__.py +52 -0
- agentkit/toolkit/config/auto_prompt.py +752 -0
- agentkit/toolkit/config/build_config.py +28 -0
- agentkit/toolkit/config/common_config.py +18 -0
- agentkit/toolkit/config/config.py +306 -0
- agentkit/toolkit/config/config_handler.py +331 -0
- agentkit/toolkit/config/config_manager.py +48 -0
- agentkit/toolkit/config/config_validator.py +121 -0
- agentkit/toolkit/config/constants.py +18 -0
- agentkit/toolkit/config/dataclass_utils.py +153 -0
- agentkit/toolkit/config/deploy_config.py +1 -0
- agentkit/toolkit/config/utils.py +57 -0
- agentkit/toolkit/config/workflow_configs.py +149 -0
- agentkit/toolkit/consts.py +1 -0
- agentkit/toolkit/core/__init__.py +13 -0
- agentkit/toolkit/core/build/__init__.py +13 -0
- agentkit/toolkit/core/build/base_builder.py +6 -0
- agentkit/toolkit/core/build/cloud_builder.py +0 -0
- agentkit/toolkit/core/build/local_builder.py +0 -0
- agentkit/toolkit/core/deploy/__init__.py +13 -0
- agentkit/toolkit/core/deploy/base_deployer.py +6 -0
- agentkit/toolkit/core/deploy/cloud_deployer.py +0 -0
- agentkit/toolkit/core/deploy/local_deployer.py +0 -0
- agentkit/toolkit/integrations/__init__.py +17 -0
- agentkit/toolkit/integrations/builder/__init__.py +23 -0
- agentkit/toolkit/integrations/builder/base.py +59 -0
- agentkit/toolkit/integrations/builder/local_docker_builder.py +163 -0
- agentkit/toolkit/integrations/builder/ve_core_pipeline_builder.py +853 -0
- agentkit/toolkit/integrations/container.py +843 -0
- agentkit/toolkit/integrations/runner/__init__.py +26 -0
- agentkit/toolkit/integrations/runner/base.py +222 -0
- agentkit/toolkit/integrations/runner/local_docker_runner.py +407 -0
- agentkit/toolkit/integrations/runner/ve_agentkit_runner.py +665 -0
- agentkit/toolkit/integrations/services/__init__.py +26 -0
- agentkit/toolkit/integrations/services/cr_service.py +449 -0
- agentkit/toolkit/integrations/services/tos_service.py +291 -0
- agentkit/toolkit/integrations/utils/__init__.py +21 -0
- agentkit/toolkit/integrations/utils/project_archiver.py +276 -0
- agentkit/toolkit/integrations/ve_code_pipeline.py +643 -0
- agentkit/toolkit/integrations/ve_cr.py +385 -0
- agentkit/toolkit/integrations/ve_iam.py +210 -0
- agentkit/toolkit/resources/samples/basic.py +79 -0
- agentkit/toolkit/resources/samples/basic_stream.py +100 -0
- agentkit/toolkit/resources/samples/customer_support_assistant.py +3 -0
- agentkit/toolkit/resources/samples/financial_analyst.py +140 -0
- agentkit/toolkit/resources/samples/simple_a2a_veadk.py +32 -0
- agentkit/toolkit/resources/samples/simple_app_veadk.py +55 -0
- agentkit/toolkit/resources/samples/simple_mcp_veadk.py +50 -0
- agentkit/toolkit/resources/templates/Dockerfile.j2 +27 -0
- agentkit/toolkit/resources/templates/code-pipeline-tos-cr-step.j2 +52 -0
- agentkit/toolkit/workflows/__init__.py +27 -0
- agentkit/toolkit/workflows/base.py +87 -0
- agentkit/toolkit/workflows/hybird_local_ve_workflow_v1.py +381 -0
- agentkit/toolkit/workflows/local_workflow_v1.py +262 -0
- agentkit/toolkit/workflows/ve_agentkit_workflow.py +369 -0
- agentkit/tools/__init__.py +17 -0
- agentkit/tools/tools.py +106 -0
- agentkit/tools/tools_all_types.py +337 -0
- agentkit/utils/__init__.py +41 -0
- agentkit/utils/credential.py +44 -0
- agentkit/utils/logging_config.py +366 -0
- agentkit/utils/misc.py +70 -0
- agentkit/utils/request.py +59 -0
- agentkit/utils/template_utils.py +256 -0
- agentkit/utils/ve_sign.py +247 -0
- agentkit/version.py +15 -0
- agentkit_sdk_python-0.1.5.dist-info/METADATA +262 -0
- agentkit_sdk_python-0.1.5.dist-info/RECORD +120 -0
- agentkit_sdk_python-0.1.5.dist-info/WHEEL +5 -0
- agentkit_sdk_python-0.1.5.dist-info/entry_points.txt +2 -0
- agentkit_sdk_python-0.1.5.dist-info/licenses/LICENSE +201 -0
- agentkit_sdk_python-0.1.5.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
# Auto-generated from API JSON definition
|
|
16
|
+
# Do not edit manually
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
from typing import Optional, List, Dict, Any
|
|
21
|
+
from pydantic import BaseModel, Field
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# Data Types
|
|
25
|
+
class KnowledgeBasesForListKnowledgeBases(BaseModel):
|
|
26
|
+
create_time: Optional[str] = Field(default=None, alias="CreateTime")
|
|
27
|
+
description: Optional[str] = Field(default=None, alias="Description")
|
|
28
|
+
knowledge_id: Optional[str] = Field(default=None, alias="KnowledgeId")
|
|
29
|
+
last_update_time: Optional[str] = Field(default=None, alias="LastUpdateTime")
|
|
30
|
+
name: Optional[str] = Field(default=None, alias="Name")
|
|
31
|
+
provider_knowledge_id: Optional[str] = Field(default=None, alias="ProviderKnowledgeId")
|
|
32
|
+
provider_type: Optional[str] = Field(default=None, alias="ProviderType")
|
|
33
|
+
status: Optional[str] = Field(default=None, alias="Status")
|
|
34
|
+
|
|
35
|
+
model_config = {
|
|
36
|
+
"populate_by_name": True,
|
|
37
|
+
"arbitrary_types_allowed": True
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class KnowledgeBasesForAddKnowledgeBase(BaseModel):
|
|
42
|
+
knowledge_id: Optional[str] = Field(default=None, alias="KnowledgeId")
|
|
43
|
+
provider_knowledge_id: Optional[str] = Field(default=None, alias="ProviderKnowledgeId")
|
|
44
|
+
provider_type: Optional[str] = Field(default=None, alias="ProviderType")
|
|
45
|
+
status: Optional[str] = Field(default=None, alias="Status")
|
|
46
|
+
|
|
47
|
+
model_config = {
|
|
48
|
+
"populate_by_name": True,
|
|
49
|
+
"arbitrary_types_allowed": True
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class ConnectionInfosForGetKnowledgeConnectionInfo(BaseModel):
|
|
54
|
+
auth_key: Optional[str] = Field(default=None, alias="AuthKey")
|
|
55
|
+
auth_type: Optional[str] = Field(default=None, alias="AuthType")
|
|
56
|
+
base_url: Optional[str] = Field(default=None, alias="BaseUrl")
|
|
57
|
+
expire_at: Optional[str] = Field(default=None, alias="ExpireAt")
|
|
58
|
+
extra_config: Optional[str] = Field(default=None, alias="ExtraConfig")
|
|
59
|
+
region: Optional[str] = Field(default=None, alias="Region")
|
|
60
|
+
vpc_id: Optional[str] = Field(default=None, alias="VpcId")
|
|
61
|
+
vpc_name: Optional[str] = Field(default=None, alias="VpcName")
|
|
62
|
+
|
|
63
|
+
model_config = {
|
|
64
|
+
"populate_by_name": True,
|
|
65
|
+
"arbitrary_types_allowed": True
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
# ListKnowledgeBases - Request
|
|
70
|
+
class FiltersItem(BaseModel):
|
|
71
|
+
name: Optional[str] = Field(default=None, alias="Name")
|
|
72
|
+
name_contains: Optional[str] = Field(default=None, alias="NameContains")
|
|
73
|
+
values: Optional[list[str]] = Field(default=None, alias="Values")
|
|
74
|
+
|
|
75
|
+
model_config = {
|
|
76
|
+
"populate_by_name": True,
|
|
77
|
+
"arbitrary_types_allowed": True
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class ListKnowledgeBasesRequest(BaseModel):
|
|
82
|
+
create_time_after: Optional[str] = Field(default=None, alias="CreateTimeAfter")
|
|
83
|
+
create_time_before: Optional[str] = Field(default=None, alias="CreateTimeBefore")
|
|
84
|
+
max_results: Optional[int] = Field(default=None, alias="MaxResults")
|
|
85
|
+
next_token: Optional[str] = Field(default=None, alias="NextToken")
|
|
86
|
+
page_number: Optional[int] = Field(default=None, alias="PageNumber")
|
|
87
|
+
page_size: Optional[int] = Field(default=None, alias="PageSize")
|
|
88
|
+
update_time_after: Optional[str] = Field(default=None, alias="UpdateTimeAfter")
|
|
89
|
+
update_time_before: Optional[str] = Field(default=None, alias="UpdateTimeBefore")
|
|
90
|
+
filters: Optional[list[FiltersItem]] = Field(default=None, alias="Filters")
|
|
91
|
+
|
|
92
|
+
model_config = {
|
|
93
|
+
"populate_by_name": True,
|
|
94
|
+
"arbitrary_types_allowed": True
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
# ListKnowledgeBases - Response
|
|
99
|
+
class ListKnowledgeBasesResponse(BaseModel):
|
|
100
|
+
knowledge_bases: Optional[list[KnowledgeBasesForListKnowledgeBases]] = Field(default=None, alias="KnowledgeBases")
|
|
101
|
+
page_number: Optional[int] = Field(default=None, alias="PageNumber")
|
|
102
|
+
page_size: Optional[int] = Field(default=None, alias="PageSize")
|
|
103
|
+
total_count: Optional[int] = Field(default=None, alias="TotalCount")
|
|
104
|
+
|
|
105
|
+
model_config = {
|
|
106
|
+
"populate_by_name": True,
|
|
107
|
+
"arbitrary_types_allowed": True
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
# AddKnowledgeBase - Request
|
|
112
|
+
class KnowledgeBasesItem(BaseModel):
|
|
113
|
+
name: str = Field(..., alias="Name")
|
|
114
|
+
provider_knowledge_id: str = Field(..., alias="ProviderKnowledgeId")
|
|
115
|
+
provider_type: str = Field(..., alias="ProviderType")
|
|
116
|
+
description: Optional[str] = Field(default=None, alias="Description")
|
|
117
|
+
|
|
118
|
+
model_config = {
|
|
119
|
+
"populate_by_name": True,
|
|
120
|
+
"arbitrary_types_allowed": True
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class AddKnowledgeBaseRequest(BaseModel):
|
|
125
|
+
client_token: Optional[str] = Field(default=None, alias="ClientToken")
|
|
126
|
+
project_name: Optional[str] = Field(default=None, alias="ProjectName")
|
|
127
|
+
knowledge_bases: Optional[list[KnowledgeBasesItem]] = Field(default=None, alias="KnowledgeBases")
|
|
128
|
+
|
|
129
|
+
model_config = {
|
|
130
|
+
"populate_by_name": True,
|
|
131
|
+
"arbitrary_types_allowed": True
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
# AddKnowledgeBase - Response
|
|
136
|
+
class AddKnowledgeBaseResponse(BaseModel):
|
|
137
|
+
knowledge_bases: Optional[list[KnowledgeBasesForAddKnowledgeBase]] = Field(default=None, alias="KnowledgeBases")
|
|
138
|
+
|
|
139
|
+
model_config = {
|
|
140
|
+
"populate_by_name": True,
|
|
141
|
+
"arbitrary_types_allowed": True
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
# GetKnowledgeConnectionInfo - Request
|
|
146
|
+
class GetKnowledgeConnectionInfoRequest(BaseModel):
|
|
147
|
+
knowledge_id: str = Field(..., alias="KnowledgeId")
|
|
148
|
+
|
|
149
|
+
model_config = {
|
|
150
|
+
"populate_by_name": True,
|
|
151
|
+
"arbitrary_types_allowed": True
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
# GetKnowledgeConnectionInfo - Response
|
|
156
|
+
class GetKnowledgeConnectionInfoResponse(BaseModel):
|
|
157
|
+
connection_infos: Optional[list[ConnectionInfosForGetKnowledgeConnectionInfo]] = Field(default=None, alias="ConnectionInfos")
|
|
158
|
+
error_message: Optional[str] = Field(default=None, alias="ErrorMessage")
|
|
159
|
+
knowledge_id: Optional[str] = Field(default=None, alias="KnowledgeId")
|
|
160
|
+
provider_knowledge_id: Optional[str] = Field(default=None, alias="ProviderKnowledgeId")
|
|
161
|
+
provider_type: Optional[str] = Field(default=None, alias="ProviderType")
|
|
162
|
+
status: Optional[str] = Field(default=None, alias="Status")
|
|
163
|
+
|
|
164
|
+
model_config = {
|
|
165
|
+
"populate_by_name": True,
|
|
166
|
+
"arbitrary_types_allowed": True
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
# DeleteKnowledgeBase - Request
|
|
171
|
+
class DeleteKnowledgeBaseRequest(BaseModel):
|
|
172
|
+
knowledge_id: str = Field(..., alias="KnowledgeId")
|
|
173
|
+
|
|
174
|
+
model_config = {
|
|
175
|
+
"populate_by_name": True,
|
|
176
|
+
"arbitrary_types_allowed": True
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
# DeleteKnowledgeBase - Response
|
|
181
|
+
class DeleteKnowledgeBaseResponse(BaseModel):
|
|
182
|
+
knowledge_id: Optional[str] = Field(default=None, alias="KnowledgeId")
|
|
183
|
+
provider_knowledge_id: Optional[str] = Field(default=None, alias="ProviderKnowledgeId")
|
|
184
|
+
provider_type: Optional[str] = Field(default=None, alias="ProviderType")
|
|
185
|
+
request_id: Optional[str] = Field(default=None, alias="RequestId")
|
|
186
|
+
|
|
187
|
+
model_config = {
|
|
188
|
+
"populate_by_name": True,
|
|
189
|
+
"arbitrary_types_allowed": True
|
|
190
|
+
}
|
|
191
|
+
|
agentkit/mcp/__init__.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from agentkit.mcp.mcp import AgentkitMCP
|
|
16
|
+
from agentkit.mcp.mcp_all_types import (
|
|
17
|
+
# MCP Service
|
|
18
|
+
CreateMCPServiceRequest,
|
|
19
|
+
CreateMCPServiceResponse,
|
|
20
|
+
UpdateMCPServiceRequest,
|
|
21
|
+
UpdateMCPServiceResponse,
|
|
22
|
+
DeleteMCPServiceRequest,
|
|
23
|
+
DeleteMCPServiceResponse,
|
|
24
|
+
GetMCPServiceRequest,
|
|
25
|
+
GetMCPServiceResponse,
|
|
26
|
+
ListMCPServicesRequest,
|
|
27
|
+
ListMCPServicesResponse,
|
|
28
|
+
# MCP Toolset
|
|
29
|
+
CreateMCPToolsetRequest,
|
|
30
|
+
CreateMCPToolsetResponse,
|
|
31
|
+
UpdateMCPToolsetRequest,
|
|
32
|
+
UpdateMCPToolsetResponse,
|
|
33
|
+
DeleteMCPToolsetRequest,
|
|
34
|
+
DeleteMCPToolsetResponse,
|
|
35
|
+
GetMCPToolsetRequest,
|
|
36
|
+
GetMCPToolsetResponse,
|
|
37
|
+
ListMCPToolsetsRequest,
|
|
38
|
+
ListMCPToolsetsResponse,
|
|
39
|
+
# MCP Tools
|
|
40
|
+
UpdateMCPToolsRequest,
|
|
41
|
+
UpdateMCPToolsResponse,
|
|
42
|
+
GetMCPToolsRequest,
|
|
43
|
+
GetMCPToolsResponse,
|
|
44
|
+
ListMCPToolsRequest,
|
|
45
|
+
ListMCPToolsResponse,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
__all__ = [
|
|
49
|
+
"AgentkitMCP",
|
|
50
|
+
# MCP Service
|
|
51
|
+
"CreateMCPServiceRequest",
|
|
52
|
+
"CreateMCPServiceResponse",
|
|
53
|
+
"UpdateMCPServiceRequest",
|
|
54
|
+
"UpdateMCPServiceResponse",
|
|
55
|
+
"DeleteMCPServiceRequest",
|
|
56
|
+
"DeleteMCPServiceResponse",
|
|
57
|
+
"GetMCPServiceRequest",
|
|
58
|
+
"GetMCPServiceResponse",
|
|
59
|
+
"ListMCPServicesRequest",
|
|
60
|
+
"ListMCPServicesResponse",
|
|
61
|
+
# MCP Toolset
|
|
62
|
+
"CreateMCPToolsetRequest",
|
|
63
|
+
"CreateMCPToolsetResponse",
|
|
64
|
+
"UpdateMCPToolsetRequest",
|
|
65
|
+
"UpdateMCPToolsetResponse",
|
|
66
|
+
"DeleteMCPToolsetRequest",
|
|
67
|
+
"DeleteMCPToolsetResponse",
|
|
68
|
+
"GetMCPToolsetRequest",
|
|
69
|
+
"GetMCPToolsetResponse",
|
|
70
|
+
"ListMCPToolsetsRequest",
|
|
71
|
+
"ListMCPToolsetsResponse",
|
|
72
|
+
# MCP Tools
|
|
73
|
+
"UpdateMCPToolsRequest",
|
|
74
|
+
"UpdateMCPToolsResponse",
|
|
75
|
+
"GetMCPToolsRequest",
|
|
76
|
+
"GetMCPToolsResponse",
|
|
77
|
+
"ListMCPToolsRequest",
|
|
78
|
+
"ListMCPToolsResponse",
|
|
79
|
+
]
|
agentkit/mcp/mcp.py
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from typing import Dict
|
|
16
|
+
|
|
17
|
+
from agentkit.client import BaseAgentkitClient
|
|
18
|
+
from agentkit.utils import get_logger
|
|
19
|
+
|
|
20
|
+
# 导入自动生成的类型
|
|
21
|
+
from agentkit.mcp.mcp_all_types import (
|
|
22
|
+
CreateMCPServiceRequest,
|
|
23
|
+
CreateMCPServiceResponse,
|
|
24
|
+
UpdateMCPServiceRequest,
|
|
25
|
+
UpdateMCPServiceResponse,
|
|
26
|
+
DeleteMCPServiceRequest,
|
|
27
|
+
DeleteMCPServiceResponse,
|
|
28
|
+
GetMCPServiceRequest,
|
|
29
|
+
GetMCPServiceResponse,
|
|
30
|
+
ListMCPServicesRequest,
|
|
31
|
+
ListMCPServicesResponse,
|
|
32
|
+
CreateMCPToolsetRequest,
|
|
33
|
+
CreateMCPToolsetResponse,
|
|
34
|
+
UpdateMCPToolsetRequest,
|
|
35
|
+
UpdateMCPToolsetResponse,
|
|
36
|
+
DeleteMCPToolsetRequest,
|
|
37
|
+
DeleteMCPToolsetResponse,
|
|
38
|
+
GetMCPToolsetRequest,
|
|
39
|
+
GetMCPToolsetResponse,
|
|
40
|
+
ListMCPToolsetsRequest,
|
|
41
|
+
ListMCPToolsetsResponse,
|
|
42
|
+
UpdateMCPToolsRequest,
|
|
43
|
+
UpdateMCPToolsResponse,
|
|
44
|
+
GetMCPToolsRequest,
|
|
45
|
+
GetMCPToolsResponse,
|
|
46
|
+
ListMCPToolsRequest,
|
|
47
|
+
ListMCPToolsResponse,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
logger = get_logger(__name__)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class AgentkitMCP(BaseAgentkitClient):
|
|
54
|
+
"""AgentKit MCP (Model Context Protocol) Management Service"""
|
|
55
|
+
|
|
56
|
+
# Define all API actions for this service
|
|
57
|
+
API_ACTIONS: Dict[str, str] = {
|
|
58
|
+
"CreateMCPService": "CreateMCPService",
|
|
59
|
+
"UpdateMCPService": "UpdateMCPService",
|
|
60
|
+
"DeleteMCPService": "DeleteMCPService",
|
|
61
|
+
"GetMCPService": "GetMCPService",
|
|
62
|
+
"ListMCPServices": "ListMCPServices",
|
|
63
|
+
"CreateMCPToolset": "CreateMCPToolset",
|
|
64
|
+
"UpdateMCPToolset": "UpdateMCPToolset",
|
|
65
|
+
"DeleteMCPToolset": "DeleteMCPToolset",
|
|
66
|
+
"GetMCPToolset": "GetMCPToolset",
|
|
67
|
+
"ListMCPToolsets": "ListMCPToolsets",
|
|
68
|
+
"UpdateMCPTools": "UpdateMCPTools",
|
|
69
|
+
"GetMCPTools": "GetMCPTools",
|
|
70
|
+
"ListMCPTools": "ListMCPTools",
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
def __init__(
|
|
74
|
+
self,
|
|
75
|
+
access_key: str = "",
|
|
76
|
+
secret_key: str = "",
|
|
77
|
+
region: str = "",
|
|
78
|
+
session_token: str = "",
|
|
79
|
+
) -> None:
|
|
80
|
+
super().__init__(
|
|
81
|
+
access_key=access_key,
|
|
82
|
+
secret_key=secret_key,
|
|
83
|
+
region=region,
|
|
84
|
+
session_token=session_token,
|
|
85
|
+
service_name="mcp",
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
# ==================== MCP Service APIs ====================
|
|
89
|
+
|
|
90
|
+
def create_mcp_service(
|
|
91
|
+
self, request: CreateMCPServiceRequest
|
|
92
|
+
) -> CreateMCPServiceResponse:
|
|
93
|
+
"""Create a new MCP service."""
|
|
94
|
+
return self._invoke_api(
|
|
95
|
+
api_action="CreateMCPService",
|
|
96
|
+
request=request,
|
|
97
|
+
response_type=CreateMCPServiceResponse,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
def update_mcp_service(
|
|
101
|
+
self, request: UpdateMCPServiceRequest
|
|
102
|
+
) -> UpdateMCPServiceResponse:
|
|
103
|
+
"""Update an existing MCP service."""
|
|
104
|
+
return self._invoke_api(
|
|
105
|
+
api_action="UpdateMCPService",
|
|
106
|
+
request=request,
|
|
107
|
+
response_type=UpdateMCPServiceResponse,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
def delete_mcp_service(
|
|
111
|
+
self, request: DeleteMCPServiceRequest
|
|
112
|
+
) -> DeleteMCPServiceResponse:
|
|
113
|
+
"""Delete an MCP service."""
|
|
114
|
+
return self._invoke_api(
|
|
115
|
+
api_action="DeleteMCPService",
|
|
116
|
+
request=request,
|
|
117
|
+
response_type=DeleteMCPServiceResponse,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
def get_mcp_service(
|
|
121
|
+
self, request: GetMCPServiceRequest
|
|
122
|
+
) -> GetMCPServiceResponse:
|
|
123
|
+
"""Get details of a specific MCP service."""
|
|
124
|
+
return self._invoke_api(
|
|
125
|
+
api_action="GetMCPService",
|
|
126
|
+
request=request,
|
|
127
|
+
response_type=GetMCPServiceResponse,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
def list_mcp_services(
|
|
131
|
+
self, request: ListMCPServicesRequest
|
|
132
|
+
) -> ListMCPServicesResponse:
|
|
133
|
+
"""List all MCP services."""
|
|
134
|
+
return self._invoke_api(
|
|
135
|
+
api_action="ListMCPServices",
|
|
136
|
+
request=request,
|
|
137
|
+
response_type=ListMCPServicesResponse,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
# ==================== MCP Toolset APIs ====================
|
|
141
|
+
|
|
142
|
+
def create_mcp_toolset(
|
|
143
|
+
self, request: CreateMCPToolsetRequest
|
|
144
|
+
) -> CreateMCPToolsetResponse:
|
|
145
|
+
"""Create a new MCP toolset."""
|
|
146
|
+
return self._invoke_api(
|
|
147
|
+
api_action="CreateMCPToolset",
|
|
148
|
+
request=request,
|
|
149
|
+
response_type=CreateMCPToolsetResponse,
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
def update_mcp_toolset(
|
|
153
|
+
self, request: UpdateMCPToolsetRequest
|
|
154
|
+
) -> UpdateMCPToolsetResponse:
|
|
155
|
+
"""Update an existing MCP toolset."""
|
|
156
|
+
return self._invoke_api(
|
|
157
|
+
api_action="UpdateMCPToolset",
|
|
158
|
+
request=request,
|
|
159
|
+
response_type=UpdateMCPToolsetResponse,
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
def delete_mcp_toolset(
|
|
163
|
+
self, request: DeleteMCPToolsetRequest
|
|
164
|
+
) -> DeleteMCPToolsetResponse:
|
|
165
|
+
"""Delete an MCP toolset."""
|
|
166
|
+
return self._invoke_api(
|
|
167
|
+
api_action="DeleteMCPToolset",
|
|
168
|
+
request=request,
|
|
169
|
+
response_type=DeleteMCPToolsetResponse,
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
def get_mcp_toolset(
|
|
173
|
+
self, request: GetMCPToolsetRequest
|
|
174
|
+
) -> GetMCPToolsetResponse:
|
|
175
|
+
"""Get details of a specific MCP toolset."""
|
|
176
|
+
return self._invoke_api(
|
|
177
|
+
api_action="GetMCPToolset",
|
|
178
|
+
request=request,
|
|
179
|
+
response_type=GetMCPToolsetResponse,
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
def list_mcp_toolsets(
|
|
183
|
+
self, request: ListMCPToolsetsRequest
|
|
184
|
+
) -> ListMCPToolsetsResponse:
|
|
185
|
+
"""List all MCP toolsets."""
|
|
186
|
+
return self._invoke_api(
|
|
187
|
+
api_action="ListMCPToolsets",
|
|
188
|
+
request=request,
|
|
189
|
+
response_type=ListMCPToolsetsResponse,
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
# ==================== MCP Tools APIs ====================
|
|
193
|
+
|
|
194
|
+
def update_mcp_tools(
|
|
195
|
+
self, request: UpdateMCPToolsRequest
|
|
196
|
+
) -> UpdateMCPToolsResponse:
|
|
197
|
+
"""Update tools for an MCP service."""
|
|
198
|
+
return self._invoke_api(
|
|
199
|
+
api_action="UpdateMCPTools",
|
|
200
|
+
request=request,
|
|
201
|
+
response_type=UpdateMCPToolsResponse,
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
def get_mcp_tools(
|
|
205
|
+
self, request: GetMCPToolsRequest
|
|
206
|
+
) -> GetMCPToolsResponse:
|
|
207
|
+
"""Get tools from an MCP toolset."""
|
|
208
|
+
return self._invoke_api(
|
|
209
|
+
api_action="GetMCPTools",
|
|
210
|
+
request=request,
|
|
211
|
+
response_type=GetMCPToolsResponse,
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
def list_mcp_tools(
|
|
215
|
+
self, request: ListMCPToolsRequest
|
|
216
|
+
) -> ListMCPToolsResponse:
|
|
217
|
+
"""List all MCP tools from specified toolsets."""
|
|
218
|
+
return self._invoke_api(
|
|
219
|
+
api_action="ListMCPTools",
|
|
220
|
+
request=request,
|
|
221
|
+
response_type=ListMCPToolsResponse,
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
if __name__ == "__main__":
|
|
226
|
+
# 配置日志用于测试
|
|
227
|
+
from agentkit.utils import setup_logging
|
|
228
|
+
setup_logging(level="INFO", format_type="simple")
|
|
229
|
+
|
|
230
|
+
logger.info("=" * 70)
|
|
231
|
+
logger.info("测试 AgentKit MCP API")
|
|
232
|
+
logger.info("=" * 70)
|
|
233
|
+
|
|
234
|
+
mcp = AgentkitMCP()
|
|
235
|
+
|
|
236
|
+
logger.info("\n【示例1】列出所有MCP服务")
|
|
237
|
+
try:
|
|
238
|
+
list_req = ListMCPServicesRequest(page_number=1, page_size=10)
|
|
239
|
+
list_res = mcp.list_mcp_services(list_req)
|
|
240
|
+
logger.info(" ✓ API调用成功")
|
|
241
|
+
logger.info(" 总数: %s", list_res.total_count)
|
|
242
|
+
logger.info(" 当前页: %s/%s", list_res.page_number, list_res.page_size)
|
|
243
|
+
|
|
244
|
+
if list_res.m_c_p_services:
|
|
245
|
+
logger.info("\n MCP服务列表:")
|
|
246
|
+
for service in list_res.m_c_p_services[:5]: # 只显示前5个
|
|
247
|
+
logger.info(" - 服务ID: %s", service.m_c_p_service_id)
|
|
248
|
+
logger.info(" 名称: %s", service.name)
|
|
249
|
+
logger.info(" 状态: %s", service.status)
|
|
250
|
+
except Exception as e:
|
|
251
|
+
logger.error(" ✗ API调用失败: %s", e, exc_info=True)
|
|
252
|
+
|
|
253
|
+
logger.info("\n【示例2】列出所有MCP工具集")
|
|
254
|
+
try:
|
|
255
|
+
list_req = ListMCPToolsetsRequest(page_number=1, page_size=10)
|
|
256
|
+
list_res = mcp.list_mcp_toolsets(list_req)
|
|
257
|
+
logger.info(" ✓ API调用成功")
|
|
258
|
+
logger.info(" 总数: %s", list_res.total_count)
|
|
259
|
+
logger.info(" 当前页: %s/%s", list_res.page_number, list_res.page_size)
|
|
260
|
+
|
|
261
|
+
if list_res.m_c_p_toolsets:
|
|
262
|
+
logger.info("\n MCP工具集列表:")
|
|
263
|
+
for toolset in list_res.m_c_p_toolsets[:5]: # 只显示前5个
|
|
264
|
+
logger.info(" - 工具集ID: %s", toolset.m_c_p_toolset_id)
|
|
265
|
+
logger.info(" 名称: %s", toolset.name)
|
|
266
|
+
logger.info(" 状态: %s", toolset.status)
|
|
267
|
+
except Exception as e:
|
|
268
|
+
logger.error(" ✗ API调用失败: %s", e, exc_info=True)
|
|
269
|
+
|
|
270
|
+
logger.info("\n" + "=" * 70)
|
|
271
|
+
logger.info("✓ AgentKit MCP API 实现完成!")
|
|
272
|
+
logger.info("=" * 70)
|
|
273
|
+
logger.info("支持的功能:")
|
|
274
|
+
logger.info(" MCP Service (服务管理):")
|
|
275
|
+
logger.info(" 1. ✓ 创建MCP服务 (create_mcp_service)")
|
|
276
|
+
logger.info(" 2. ✓ 更新MCP服务 (update_mcp_service)")
|
|
277
|
+
logger.info(" 3. ✓ 删除MCP服务 (delete_mcp_service)")
|
|
278
|
+
logger.info(" 4. ✓ 获取MCP服务 (get_mcp_service)")
|
|
279
|
+
logger.info(" 5. ✓ 列出MCP服务 (list_mcp_services)")
|
|
280
|
+
logger.info(" MCP Toolset (工具集管理):")
|
|
281
|
+
logger.info(" 6. ✓ 创建MCP工具集 (create_mcp_toolset)")
|
|
282
|
+
logger.info(" 7. ✓ 更新MCP工具集 (update_mcp_toolset)")
|
|
283
|
+
logger.info(" 8. ✓ 删除MCP工具集 (delete_mcp_toolset)")
|
|
284
|
+
logger.info(" 9. ✓ 获取MCP工具集 (get_mcp_toolset)")
|
|
285
|
+
logger.info(" 10. ✓ 列出MCP工具集 (list_mcp_toolsets)")
|
|
286
|
+
logger.info(" MCP Tools (工具管理):")
|
|
287
|
+
logger.info(" 11. ✓ 更新MCP工具 (update_mcp_tools)")
|
|
288
|
+
logger.info(" 12. ✓ 获取MCP工具 (get_mcp_tools)")
|
|
289
|
+
logger.info(" 13. ✓ 列出MCP工具 (list_mcp_tools)")
|
|
290
|
+
logger.info("\n特性:")
|
|
291
|
+
logger.info(" 1. ✓ 所有请求和响应都是强类型")
|
|
292
|
+
logger.info(" 2. ✓ 支持别名和Python字段名两种方式")
|
|
293
|
+
logger.info(" 3. ✓ 完整的错误处理")
|
|
294
|
+
logger.info(" 4. ✓ Pydantic自动验证")
|