agentscope-runtime 0.2.0b2__py3-none-any.whl → 1.0.0b1__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.
Files changed (183) hide show
  1. agentscope_runtime/adapters/__init__.py +0 -0
  2. agentscope_runtime/adapters/agentscope/__init__.py +0 -0
  3. agentscope_runtime/adapters/agentscope/long_term_memory/__init__.py +6 -0
  4. agentscope_runtime/adapters/agentscope/long_term_memory/_long_term_memory_adapter.py +258 -0
  5. agentscope_runtime/adapters/agentscope/memory/__init__.py +6 -0
  6. agentscope_runtime/adapters/agentscope/memory/_memory_adapter.py +152 -0
  7. agentscope_runtime/adapters/agentscope/message.py +535 -0
  8. agentscope_runtime/adapters/agentscope/stream.py +474 -0
  9. agentscope_runtime/adapters/agentscope/tool/__init__.py +9 -0
  10. agentscope_runtime/adapters/agentscope/tool/sandbox_tool.py +69 -0
  11. agentscope_runtime/adapters/agentscope/tool/tool.py +233 -0
  12. agentscope_runtime/adapters/autogen/__init__.py +0 -0
  13. agentscope_runtime/adapters/autogen/tool/__init__.py +7 -0
  14. agentscope_runtime/adapters/autogen/tool/tool.py +211 -0
  15. agentscope_runtime/adapters/text/__init__.py +0 -0
  16. agentscope_runtime/adapters/text/stream.py +29 -0
  17. agentscope_runtime/common/collections/redis_mapping.py +4 -1
  18. agentscope_runtime/common/container_clients/fc_client.py +855 -0
  19. agentscope_runtime/common/utils/__init__.py +0 -0
  20. agentscope_runtime/common/utils/lazy_loader.py +57 -0
  21. agentscope_runtime/engine/__init__.py +25 -18
  22. agentscope_runtime/engine/app/agent_app.py +161 -91
  23. agentscope_runtime/engine/app/base_app.py +4 -118
  24. agentscope_runtime/engine/constant.py +8 -0
  25. agentscope_runtime/engine/deployers/__init__.py +8 -0
  26. agentscope_runtime/engine/deployers/adapter/__init__.py +2 -0
  27. agentscope_runtime/engine/deployers/adapter/a2a/a2a_adapter_utils.py +0 -21
  28. agentscope_runtime/engine/deployers/adapter/a2a/a2a_protocol_adapter.py +28 -9
  29. agentscope_runtime/engine/deployers/adapter/responses/__init__.py +2 -0
  30. agentscope_runtime/engine/deployers/adapter/responses/response_api_adapter_utils.py +5 -2
  31. agentscope_runtime/engine/deployers/adapter/responses/response_api_protocol_adapter.py +1 -1
  32. agentscope_runtime/engine/deployers/agentrun_deployer.py +2541 -0
  33. agentscope_runtime/engine/deployers/cli_fc_deploy.py +1 -1
  34. agentscope_runtime/engine/deployers/kubernetes_deployer.py +9 -21
  35. agentscope_runtime/engine/deployers/local_deployer.py +47 -74
  36. agentscope_runtime/engine/deployers/modelstudio_deployer.py +216 -50
  37. agentscope_runtime/engine/deployers/utils/app_runner_utils.py +29 -0
  38. agentscope_runtime/engine/deployers/utils/detached_app.py +510 -0
  39. agentscope_runtime/engine/deployers/utils/docker_image_utils/__init__.py +1 -1
  40. agentscope_runtime/engine/deployers/utils/docker_image_utils/dockerfile_generator.py +1 -1
  41. agentscope_runtime/engine/deployers/utils/docker_image_utils/{runner_image_factory.py → image_factory.py} +121 -61
  42. agentscope_runtime/engine/deployers/utils/package.py +693 -0
  43. agentscope_runtime/engine/deployers/utils/service_utils/__init__.py +0 -5
  44. agentscope_runtime/engine/deployers/utils/service_utils/fastapi_factory.py +256 -282
  45. agentscope_runtime/engine/deployers/utils/service_utils/fastapi_templates.py +2 -4
  46. agentscope_runtime/engine/deployers/utils/service_utils/process_manager.py +23 -1
  47. agentscope_runtime/engine/deployers/utils/templates/app_main.py.j2 +84 -0
  48. agentscope_runtime/engine/deployers/utils/templates/runner_main.py.j2 +95 -0
  49. agentscope_runtime/engine/deployers/utils/{service_utils → templates}/standalone_main.py.j2 +0 -45
  50. agentscope_runtime/engine/deployers/utils/wheel_packager.py +119 -18
  51. agentscope_runtime/engine/helpers/runner.py +40 -0
  52. agentscope_runtime/engine/runner.py +170 -130
  53. agentscope_runtime/engine/schemas/agent_schemas.py +114 -3
  54. agentscope_runtime/engine/schemas/modelstudio_llm.py +4 -2
  55. agentscope_runtime/engine/schemas/oai_llm.py +23 -23
  56. agentscope_runtime/engine/schemas/response_api.py +65 -0
  57. agentscope_runtime/engine/schemas/session.py +24 -0
  58. agentscope_runtime/engine/services/__init__.py +0 -9
  59. agentscope_runtime/engine/services/agent_state/__init__.py +16 -0
  60. agentscope_runtime/engine/services/agent_state/redis_state_service.py +113 -0
  61. agentscope_runtime/engine/services/agent_state/state_service.py +179 -0
  62. agentscope_runtime/engine/services/memory/__init__.py +24 -0
  63. agentscope_runtime/engine/services/{mem0_memory_service.py → memory/mem0_memory_service.py} +17 -13
  64. agentscope_runtime/engine/services/{memory_service.py → memory/memory_service.py} +28 -7
  65. agentscope_runtime/engine/services/{redis_memory_service.py → memory/redis_memory_service.py} +1 -1
  66. agentscope_runtime/engine/services/{reme_personal_memory_service.py → memory/reme_personal_memory_service.py} +9 -6
  67. agentscope_runtime/engine/services/{reme_task_memory_service.py → memory/reme_task_memory_service.py} +2 -2
  68. agentscope_runtime/engine/services/{tablestore_memory_service.py → memory/tablestore_memory_service.py} +12 -18
  69. agentscope_runtime/engine/services/sandbox/__init__.py +13 -0
  70. agentscope_runtime/engine/services/{sandbox_service.py → sandbox/sandbox_service.py} +86 -71
  71. agentscope_runtime/engine/services/session_history/__init__.py +23 -0
  72. agentscope_runtime/engine/services/{redis_session_history_service.py → session_history/redis_session_history_service.py} +3 -2
  73. agentscope_runtime/engine/services/{session_history_service.py → session_history/session_history_service.py} +44 -34
  74. agentscope_runtime/engine/services/{tablestore_session_history_service.py → session_history/tablestore_session_history_service.py} +14 -19
  75. agentscope_runtime/engine/services/utils/tablestore_service_utils.py +2 -2
  76. agentscope_runtime/engine/tracing/base.py +10 -9
  77. agentscope_runtime/engine/tracing/message_util.py +1 -1
  78. agentscope_runtime/engine/tracing/tracing_util.py +7 -2
  79. agentscope_runtime/sandbox/__init__.py +10 -2
  80. agentscope_runtime/sandbox/box/agentbay/__init__.py +4 -0
  81. agentscope_runtime/sandbox/box/agentbay/agentbay_sandbox.py +559 -0
  82. agentscope_runtime/sandbox/box/base/base_sandbox.py +12 -0
  83. agentscope_runtime/sandbox/box/browser/browser_sandbox.py +115 -11
  84. agentscope_runtime/sandbox/box/cloud/__init__.py +4 -0
  85. agentscope_runtime/sandbox/box/cloud/cloud_sandbox.py +254 -0
  86. agentscope_runtime/sandbox/box/filesystem/filesystem_sandbox.py +66 -0
  87. agentscope_runtime/sandbox/box/gui/gui_sandbox.py +42 -0
  88. agentscope_runtime/sandbox/box/mobile/__init__.py +4 -0
  89. agentscope_runtime/sandbox/box/mobile/box/__init__.py +0 -0
  90. agentscope_runtime/sandbox/box/mobile/mobile_sandbox.py +216 -0
  91. agentscope_runtime/sandbox/box/training_box/training_box.py +2 -2
  92. agentscope_runtime/sandbox/client/http_client.py +1 -0
  93. agentscope_runtime/sandbox/enums.py +2 -0
  94. agentscope_runtime/sandbox/manager/sandbox_manager.py +18 -2
  95. agentscope_runtime/sandbox/manager/server/app.py +12 -0
  96. agentscope_runtime/sandbox/manager/server/config.py +19 -0
  97. agentscope_runtime/sandbox/model/manager_config.py +79 -2
  98. agentscope_runtime/sandbox/utils.py +0 -18
  99. agentscope_runtime/tools/RAGs/__init__.py +0 -0
  100. agentscope_runtime/tools/RAGs/modelstudio_rag.py +377 -0
  101. agentscope_runtime/tools/RAGs/modelstudio_rag_lite.py +219 -0
  102. agentscope_runtime/tools/__init__.py +119 -0
  103. agentscope_runtime/tools/_constants.py +18 -0
  104. agentscope_runtime/tools/alipay/__init__.py +4 -0
  105. agentscope_runtime/tools/alipay/base.py +334 -0
  106. agentscope_runtime/tools/alipay/payment.py +835 -0
  107. agentscope_runtime/tools/alipay/subscribe.py +551 -0
  108. agentscope_runtime/tools/base.py +264 -0
  109. agentscope_runtime/tools/cli/__init__.py +0 -0
  110. agentscope_runtime/tools/cli/modelstudio_mcp_server.py +78 -0
  111. agentscope_runtime/tools/generations/__init__.py +75 -0
  112. agentscope_runtime/tools/generations/async_image_to_video.py +350 -0
  113. agentscope_runtime/tools/generations/async_image_to_video_wan25.py +366 -0
  114. agentscope_runtime/tools/generations/async_speech_to_video.py +422 -0
  115. agentscope_runtime/tools/generations/async_text_to_video.py +320 -0
  116. agentscope_runtime/tools/generations/async_text_to_video_wan25.py +334 -0
  117. agentscope_runtime/tools/generations/image_edit.py +208 -0
  118. agentscope_runtime/tools/generations/image_edit_wan25.py +193 -0
  119. agentscope_runtime/tools/generations/image_generation.py +202 -0
  120. agentscope_runtime/tools/generations/image_generation_wan25.py +201 -0
  121. agentscope_runtime/tools/generations/image_style_repaint.py +208 -0
  122. agentscope_runtime/tools/generations/image_to_video.py +233 -0
  123. agentscope_runtime/tools/generations/qwen_image_edit.py +205 -0
  124. agentscope_runtime/tools/generations/qwen_image_generation.py +214 -0
  125. agentscope_runtime/tools/generations/qwen_text_to_speech.py +154 -0
  126. agentscope_runtime/tools/generations/speech_to_text.py +260 -0
  127. agentscope_runtime/tools/generations/speech_to_video.py +314 -0
  128. agentscope_runtime/tools/generations/text_to_video.py +221 -0
  129. agentscope_runtime/tools/mcp_wrapper.py +215 -0
  130. agentscope_runtime/tools/realtime_clients/__init__.py +13 -0
  131. agentscope_runtime/tools/realtime_clients/asr_client.py +27 -0
  132. agentscope_runtime/tools/realtime_clients/azure_asr_client.py +195 -0
  133. agentscope_runtime/tools/realtime_clients/azure_tts_client.py +383 -0
  134. agentscope_runtime/tools/realtime_clients/modelstudio_asr_client.py +151 -0
  135. agentscope_runtime/tools/realtime_clients/modelstudio_tts_client.py +199 -0
  136. agentscope_runtime/tools/realtime_clients/realtime_tool.py +55 -0
  137. agentscope_runtime/tools/realtime_clients/tts_client.py +33 -0
  138. agentscope_runtime/tools/searches/__init__.py +3 -0
  139. agentscope_runtime/tools/searches/modelstudio_search.py +877 -0
  140. agentscope_runtime/tools/searches/modelstudio_search_lite.py +310 -0
  141. agentscope_runtime/tools/utils/__init__.py +0 -0
  142. agentscope_runtime/tools/utils/api_key_util.py +45 -0
  143. agentscope_runtime/tools/utils/crypto_utils.py +99 -0
  144. agentscope_runtime/tools/utils/mcp_util.py +35 -0
  145. agentscope_runtime/version.py +1 -1
  146. {agentscope_runtime-0.2.0b2.dist-info → agentscope_runtime-1.0.0b1.dist-info}/METADATA +234 -165
  147. agentscope_runtime-1.0.0b1.dist-info/RECORD +240 -0
  148. {agentscope_runtime-0.2.0b2.dist-info → agentscope_runtime-1.0.0b1.dist-info}/entry_points.txt +1 -0
  149. agentscope_runtime/engine/agents/__init__.py +0 -2
  150. agentscope_runtime/engine/agents/agentscope_agent.py +0 -488
  151. agentscope_runtime/engine/agents/agno_agent.py +0 -220
  152. agentscope_runtime/engine/agents/autogen_agent.py +0 -250
  153. agentscope_runtime/engine/agents/base_agent.py +0 -29
  154. agentscope_runtime/engine/agents/langgraph_agent.py +0 -59
  155. agentscope_runtime/engine/agents/utils.py +0 -53
  156. agentscope_runtime/engine/deployers/utils/package_project_utils.py +0 -1163
  157. agentscope_runtime/engine/deployers/utils/service_utils/service_config.py +0 -75
  158. agentscope_runtime/engine/deployers/utils/service_utils/service_factory.py +0 -220
  159. agentscope_runtime/engine/helpers/helper.py +0 -179
  160. agentscope_runtime/engine/schemas/context.py +0 -54
  161. agentscope_runtime/engine/services/context_manager.py +0 -164
  162. agentscope_runtime/engine/services/environment_manager.py +0 -50
  163. agentscope_runtime/engine/services/manager.py +0 -174
  164. agentscope_runtime/engine/services/rag_service.py +0 -195
  165. agentscope_runtime/engine/services/tablestore_rag_service.py +0 -143
  166. agentscope_runtime/sandbox/tools/__init__.py +0 -12
  167. agentscope_runtime/sandbox/tools/base/__init__.py +0 -8
  168. agentscope_runtime/sandbox/tools/base/tool.py +0 -52
  169. agentscope_runtime/sandbox/tools/browser/__init__.py +0 -57
  170. agentscope_runtime/sandbox/tools/browser/tool.py +0 -597
  171. agentscope_runtime/sandbox/tools/filesystem/__init__.py +0 -32
  172. agentscope_runtime/sandbox/tools/filesystem/tool.py +0 -319
  173. agentscope_runtime/sandbox/tools/function_tool.py +0 -321
  174. agentscope_runtime/sandbox/tools/gui/__init__.py +0 -7
  175. agentscope_runtime/sandbox/tools/gui/tool.py +0 -77
  176. agentscope_runtime/sandbox/tools/mcp_tool.py +0 -195
  177. agentscope_runtime/sandbox/tools/sandbox_tool.py +0 -104
  178. agentscope_runtime/sandbox/tools/tool.py +0 -238
  179. agentscope_runtime/sandbox/tools/utils.py +0 -68
  180. agentscope_runtime-0.2.0b2.dist-info/RECORD +0 -183
  181. {agentscope_runtime-0.2.0b2.dist-info → agentscope_runtime-1.0.0b1.dist-info}/WHEEL +0 -0
  182. {agentscope_runtime-0.2.0b2.dist-info → agentscope_runtime-1.0.0b1.dist-info}/licenses/LICENSE +0 -0
  183. {agentscope_runtime-0.2.0b2.dist-info → agentscope_runtime-1.0.0b1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,264 @@
1
+ # -*- coding: utf-8 -*-
2
+ # pylint:disable=typevar-name-incorrect-variance, unused-argument
3
+
4
+ import json
5
+ from typing import (
6
+ Any,
7
+ Dict,
8
+ Generic,
9
+ List,
10
+ Optional,
11
+ Type,
12
+ TypeVar,
13
+ Union,
14
+ cast,
15
+ get_args,
16
+ )
17
+
18
+ import jsonref
19
+ from asgiref.sync import async_to_sync
20
+ from pydantic import BaseModel, ValidationError
21
+
22
+ from ..engine.schemas.agent_schemas import (
23
+ FunctionParameters,
24
+ FunctionTool,
25
+ )
26
+
27
+
28
+ # A type variable bounded by BaseModel, meaning it can represent BaseModel or
29
+ # any subclass of it.
30
+ ToolArgsT = TypeVar("ToolArgsT", bound=BaseModel, contravariant=True)
31
+ ToolReturnT = TypeVar("ToolReturnT", bound=BaseModel, covariant=True)
32
+
33
+
34
+ class Tool(Generic[ToolArgsT, ToolReturnT]):
35
+ """Base class for all zh, supporting both async and streaming
36
+ capabilities.
37
+ """
38
+
39
+ name: str
40
+ description: str
41
+
42
+ def __init__(
43
+ self,
44
+ name: Optional[str] = None,
45
+ description: Optional[str] = None,
46
+ **kwargs: Any,
47
+ ):
48
+ """Initialize the base component.
49
+
50
+ Args:
51
+ name: The name of the component.
52
+ description: The description of the component.
53
+ **kwargs: Other arguments if needed.
54
+
55
+ Raises:
56
+ ValueError: If component name and description are not provided.
57
+ """
58
+ self.name = name if name else self.__class__.name
59
+ self.description = (
60
+ description if description else self.__class__.description
61
+ )
62
+ if not self.name or not self.description:
63
+ raise ValueError(
64
+ "Tool name and description must be provided.",
65
+ )
66
+ self.input_type = self._input_type()
67
+ self.return_type = self._return_type()
68
+ self.parameters = self._parameters_parser()
69
+ self.function_schema = FunctionTool(
70
+ name=self.name,
71
+ description=self.description,
72
+ parameters=self.parameters,
73
+ )
74
+
75
+ async def _arun(
76
+ self,
77
+ args: ToolArgsT,
78
+ **kwargs: Any,
79
+ ) -> ToolReturnT:
80
+ """Actual component execution method
81
+
82
+ Args:
83
+ args: Input parameters adhering to the input schema.
84
+ **kwargs: Other arguments if needed.
85
+
86
+ Returns:
87
+ ToolReturnT: Output parameters adhering to the output schema.
88
+
89
+ Raises:
90
+ NotImplementedError: This method must be implemented by subclasses.
91
+ """
92
+ raise NotImplementedError
93
+
94
+ async def arun(
95
+ self,
96
+ args: ToolArgsT,
97
+ **kwargs: Any,
98
+ ) -> ToolReturnT:
99
+ """Run the component with the given arguments asynchronously.
100
+
101
+ Args:
102
+ args: Input parameters adhering to the input schema.
103
+ **kwargs: Other arguments if needed.
104
+
105
+ Returns:
106
+ ToolReturnT: Output parameters adhering to the output schema.
107
+
108
+ Raises:
109
+ TypeError: If input or return types don't match expected schemas.
110
+ """
111
+ if not isinstance(args, self.input_type):
112
+ raise TypeError(
113
+ f"The input must in the format of {self.input_type.__name__} "
114
+ f"or its subclass",
115
+ )
116
+
117
+ # make sure kwargs works
118
+ if not kwargs:
119
+ kwargs = {}
120
+
121
+ result = await self._arun(args, **kwargs)
122
+ if not isinstance(result, self.return_type):
123
+ raise TypeError(
124
+ f"The return must in the format of "
125
+ f"{self.return_type.__name__} or its subclass",
126
+ )
127
+ return result
128
+
129
+ def run(self, args: Any, **kwargs: Any) -> Any:
130
+ """Run the component synchronously.
131
+
132
+ Makes sure the async method could be called from sync context with or
133
+ without asyncio loop running.
134
+
135
+ Args:
136
+ args: Input arguments.
137
+ **kwargs: Additional keyword arguments.
138
+
139
+ Returns:
140
+ Any: Result of the component execution.
141
+ """
142
+ return async_to_sync(self.arun)(args, **kwargs)
143
+
144
+ def _input_type(self) -> Type[ToolArgsT]:
145
+ """Extract the generic input types.
146
+
147
+ Returns:
148
+ Type[ToolArgsT]: The input schema type,
149
+ used for validating input arguments.
150
+ """
151
+ return get_args(self.__orig_bases__[0])[0]
152
+
153
+ def _return_type(self) -> Type[ToolReturnT]:
154
+ """Extract the generic return types.
155
+
156
+ Returns:
157
+ Type[ToolReturnT]: The return schema type, used for
158
+ validating return values.
159
+ """
160
+ return get_args(self.__orig_bases__[0])[1]
161
+
162
+ def _parameters_parser(self) -> FunctionParameters:
163
+ """Parse the input type to generate the parameter schema.
164
+
165
+ Returns:
166
+ FunctionParameters: Schema representation of the input parameters.
167
+ """
168
+ try:
169
+ model_schema: Dict[str, Any] = self.input_type.model_json_schema()
170
+ except AttributeError:
171
+ # make sure user can use the component without valid input type
172
+ return FunctionParameters(
173
+ type="object",
174
+ properties={},
175
+ required=[],
176
+ )
177
+
178
+ if "$defs" in model_schema:
179
+ model_schema = cast(
180
+ Dict[str, Any],
181
+ jsonref.replace_refs(obj=model_schema, proxies=False),
182
+ ) # type: ignore
183
+ del model_schema["$defs"]
184
+
185
+ if "required" not in model_schema:
186
+ model_schema["required"] = []
187
+
188
+ parameters = FunctionParameters(
189
+ type="object",
190
+ properties=model_schema["properties"],
191
+ required=model_schema["required"],
192
+ )
193
+
194
+ return parameters
195
+
196
+ @classmethod
197
+ def verify_list_args(
198
+ cls,
199
+ args_list: List[Union[str, Dict, BaseModel]],
200
+ ) -> List[ToolArgsT]:
201
+ """Verify the list of stringify input arguments.
202
+
203
+ Args:
204
+ args_list: List of stringify input arguments.
205
+
206
+ Returns:
207
+ List[ToolArgsT]: The validated input arguments.
208
+ """
209
+ return_list = []
210
+ for args in args_list:
211
+ return_list.append(cls.verify_args(args))
212
+ return return_list
213
+
214
+ @classmethod
215
+ def verify_args(cls, args: Union[str, Dict, BaseModel]) -> BaseModel:
216
+ """Verify the stringify input arguments.
217
+
218
+ Args:
219
+ args: Stringify input arguments (string, dict, or BaseModel).
220
+
221
+ Returns:
222
+ BaseModel: The validated input arguments.
223
+
224
+ Raises:
225
+ ValueError: If JSON format is invalid or validation fails.
226
+ """
227
+ try:
228
+ if isinstance(args, str):
229
+ args_dict = json.loads(args)
230
+ elif isinstance(args, BaseModel):
231
+ args_dict = args.model_dump()
232
+ else:
233
+ args_dict = args
234
+ except json.JSONDecodeError as e:
235
+ raise ValueError(f"Invalid JSON format: {e}") from e
236
+
237
+ # Get the ArgsT type from the current class
238
+ args_type = get_args(cls.__orig_bases__[0])[0]
239
+
240
+ # Validate the arguments using the Pydantic model
241
+ try:
242
+ validated_args = args_type(**args_dict)
243
+ except ValidationError as e:
244
+ raise ValueError(f"Validation error: {e}") from e
245
+
246
+ return validated_args
247
+
248
+ @classmethod
249
+ def return_value_as_string(cls, value: ToolArgsT) -> str:
250
+ """Convert return value to string representation.
251
+
252
+ Args:
253
+ value: The value to convert to string.
254
+
255
+ Returns:
256
+ str: String representation of the value.
257
+ """
258
+ if isinstance(value, BaseModel):
259
+ dumped = value.model_dump()
260
+ if isinstance(dumped, dict):
261
+ return json.dumps(dumped)
262
+ return str(dumped)
263
+
264
+ return str(value)
File without changes
@@ -0,0 +1,78 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ import os
4
+ import sys
5
+ import logging
6
+
7
+ from mcp.server.fastmcp import FastMCP
8
+
9
+ from .. import mcp_server_metas
10
+ from ..mcp_wrapper import MCPWrapper
11
+
12
+ logger = logging.getLogger(__name__)
13
+
14
+
15
+ def main() -> None:
16
+ # get from args
17
+ server_name = None
18
+ for i, arg in enumerate(sys.argv):
19
+ logger.info(sys.argv[i])
20
+ logger.info(sys.argv)
21
+ if arg == "--server" and i + 1 < len(sys.argv):
22
+ server_name = sys.argv[i + 1]
23
+ break
24
+
25
+ # get from env
26
+ if not server_name:
27
+ server_name = os.getenv("SERVER_NAME", None)
28
+
29
+ all_server_names = set(mcp_server_metas.keys())
30
+ if not server_name:
31
+ logger.error(
32
+ f"Please specify the server name with --server <server_name>, "
33
+ f"support servers are {list(all_server_names)}",
34
+ )
35
+ sys.exit(1)
36
+
37
+ if server_name not in mcp_server_metas:
38
+ logger.error(
39
+ f"Invalid server name '{server_name}',"
40
+ f" Available servers: {list(all_server_names)}",
41
+ )
42
+ sys.exit(1)
43
+
44
+ port = int(os.getenv("PORT", "8080"))
45
+ host = os.getenv("HOST", "0.0.0.0")
46
+
47
+ # Get server metadata
48
+ server_meta = mcp_server_metas[server_name]
49
+
50
+ # Override server name and description if specified
51
+ mcp_server_name = os.getenv("OVERRIDE_NAME", server_name)
52
+ mcp_server_instructions = os.getenv(
53
+ "OVERRIDE_DESCRIPTION",
54
+ server_meta.instructions,
55
+ )
56
+
57
+ # Create an MCP server
58
+ mcp = FastMCP(
59
+ name=mcp_server_name,
60
+ instructions=mcp_server_instructions,
61
+ port=port,
62
+ host=host,
63
+ )
64
+
65
+ # Register each component as a tool
66
+ for component in server_meta.components:
67
+ MCPWrapper(mcp, component).wrap(component.name, component.description)
68
+ logger.info(f"Added tool: {component.name}")
69
+
70
+ logger.info("MCP server is running...")
71
+
72
+ # get mcp transport type
73
+ transport_type = os.getenv("TRANSPORT", "sse")
74
+ mcp.run(transport=transport_type)
75
+
76
+
77
+ if __name__ == "__main__":
78
+ main()
@@ -0,0 +1,75 @@
1
+ # -*- coding: utf-8 -*-
2
+ from .async_image_to_video import (
3
+ ImageToVideoSubmit,
4
+ ImageToVideoSubmitInput,
5
+ ImageToVideoFetch,
6
+ ImageToVideoFetchInput,
7
+ )
8
+ from .async_speech_to_video import (
9
+ SpeechToVideoSubmit,
10
+ SpeechToVideoSubmitInput,
11
+ SpeechToVideoFetch,
12
+ SpeechToVideoFetchInput,
13
+ )
14
+ from .async_text_to_video import (
15
+ TextToVideoSubmit,
16
+ TextToVideoSubmitInput,
17
+ TextToVideoFetch,
18
+ TextToVideoFetchInput,
19
+ )
20
+ from .image_edit import (
21
+ ImageEdit,
22
+ ImageGenInput as ImageEditInput,
23
+ )
24
+ from .image_generation import (
25
+ ImageGeneration,
26
+ ImageGenInput,
27
+ )
28
+ from .image_style_repaint import (
29
+ ImageStyleRepaint,
30
+ ImageStyleRepaintInput,
31
+ )
32
+ from .image_to_video import (
33
+ ImageToVideo,
34
+ ImageToVideoInput,
35
+ )
36
+ from .qwen_image_edit import (
37
+ QwenImageEdit,
38
+ QwenImageEditInput,
39
+ )
40
+ from .qwen_image_generation import (
41
+ QwenImageGen,
42
+ QwenImageGenInput,
43
+ )
44
+ from .qwen_text_to_speech import (
45
+ QwenTextToSpeech,
46
+ QwenTextToSpeechInput,
47
+ )
48
+ from .speech_to_text import (
49
+ SpeechToText,
50
+ SpeechToTextInput,
51
+ )
52
+ from .speech_to_video import (
53
+ SpeechToVideo,
54
+ SpeechToVideoInput,
55
+ )
56
+ from .async_image_to_video_wan25 import (
57
+ ImageToVideoWan25Submit,
58
+ ImageToVideoWan25SubmitInput,
59
+ ImageToVideoWan25Fetch,
60
+ ImageToVideoWan25FetchInput,
61
+ )
62
+ from .async_text_to_video_wan25 import (
63
+ TextToVideoWan25Submit,
64
+ TextToVideoWan25SubmitInput,
65
+ TextToVideoWan25Fetch,
66
+ TextToVideoWan25FetchInput,
67
+ )
68
+ from .image_edit_wan25 import (
69
+ ImageEditWan25,
70
+ ImageGenInput as ImageEditWan25Input,
71
+ )
72
+ from .image_generation_wan25 import (
73
+ ImageGenerationWan25,
74
+ ImageGenInput as ImageGenerationWan25Input,
75
+ )