media-agent-mcp 0.3.10__py3-none-any.whl → 0.3.11__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.
- media_agent_mcp/async_server.py +30 -20
- {media_agent_mcp-0.3.10.dist-info → media_agent_mcp-0.3.11.dist-info}/METADATA +1 -2
- {media_agent_mcp-0.3.10.dist-info → media_agent_mcp-0.3.11.dist-info}/RECORD +6 -6
- {media_agent_mcp-0.3.10.dist-info → media_agent_mcp-0.3.11.dist-info}/WHEEL +0 -0
- {media_agent_mcp-0.3.10.dist-info → media_agent_mcp-0.3.11.dist-info}/entry_points.txt +0 -0
- {media_agent_mcp-0.3.10.dist-info → media_agent_mcp-0.3.11.dist-info}/top_level.txt +0 -0
media_agent_mcp/async_server.py
CHANGED
@@ -22,17 +22,27 @@ from typing import List, Optional
|
|
22
22
|
import json
|
23
23
|
from dotenv import load_dotenv
|
24
24
|
import uvicorn
|
25
|
-
from
|
26
|
-
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
25
|
+
from functools import wraps
|
26
|
+
|
27
|
+
def async_retry(max_retries=3, delay=2):
|
28
|
+
def decorator(func):
|
29
|
+
@wraps(func)
|
30
|
+
async def wrapper(*args, **kwargs):
|
31
|
+
for attempt in range(max_retries):
|
32
|
+
try:
|
33
|
+
result = await func(*args, **kwargs)
|
34
|
+
if isinstance(result, dict) and result.get('status') == 'error':
|
35
|
+
logger.warning(f"Attempt {attempt + 1} of {max_retries} failed for {func.__name__}. Error: {result.get('message')}. Retrying in {delay}s...")
|
36
|
+
await asyncio.sleep(delay)
|
37
|
+
continue
|
38
|
+
return result
|
39
|
+
except Exception as e:
|
40
|
+
logger.error(f"Attempt {attempt + 1} of {max_retries} failed for {func.__name__} with exception: {e}. Retrying in {delay}s...")
|
41
|
+
await asyncio.sleep(delay)
|
42
|
+
logger.error(f"Function {func.__name__} failed after {max_retries} retries.")
|
43
|
+
return {"status": "error", "data": None, "message": f"Function {func.__name__} failed after {max_retries} retries."}
|
44
|
+
return wrapper
|
45
|
+
return decorator
|
36
46
|
|
37
47
|
from mcp.server.fastmcp import FastMCP
|
38
48
|
|
@@ -60,7 +70,7 @@ mcp = FastMCP("Media-Agent-MCP-Async")
|
|
60
70
|
|
61
71
|
|
62
72
|
@mcp.tool()
|
63
|
-
@
|
73
|
+
@async_retry()
|
64
74
|
async def video_concat_tool(video_urls: List[str]) -> dict:
|
65
75
|
"""
|
66
76
|
Asynchronously concatenate multiple videos from URLs and upload to TOS.
|
@@ -75,7 +85,7 @@ async def video_concat_tool(video_urls: List[str]) -> dict:
|
|
75
85
|
|
76
86
|
|
77
87
|
@mcp.tool()
|
78
|
-
@
|
88
|
+
@async_retry()
|
79
89
|
async def video_last_frame_tool(video_url: str) -> dict:
|
80
90
|
"""
|
81
91
|
Asynchronously extract the last frame from a video file and upload to TOS.
|
@@ -90,7 +100,7 @@ async def video_last_frame_tool(video_url: str) -> dict:
|
|
90
100
|
|
91
101
|
|
92
102
|
@mcp.tool()
|
93
|
-
@
|
103
|
+
@async_retry()
|
94
104
|
async def seedream_generate_image_tool(prompt: str, size: str = "1024x1024") -> dict:
|
95
105
|
"""
|
96
106
|
Asynchronously generate an image using Seedream AI model.
|
@@ -106,7 +116,7 @@ async def seedream_generate_image_tool(prompt: str, size: str = "1024x1024") ->
|
|
106
116
|
|
107
117
|
|
108
118
|
@mcp.tool()
|
109
|
-
@
|
119
|
+
@async_retry()
|
110
120
|
async def seedance_generate_video_tool(prompt: str, first_frame_image: str,
|
111
121
|
last_frame_image: str = None, duration: int = 5,
|
112
122
|
resolution: str = "720p") -> dict:
|
@@ -127,7 +137,7 @@ async def seedance_generate_video_tool(prompt: str, first_frame_image: str,
|
|
127
137
|
|
128
138
|
|
129
139
|
@mcp.tool()
|
130
|
-
@
|
140
|
+
@async_retry()
|
131
141
|
async def seededit_tool(image_url: str, prompt: str, seed: int = -1,
|
132
142
|
scale: float = 0.5, charactor_keep: bool = False) -> dict:
|
133
143
|
"""
|
@@ -147,7 +157,7 @@ async def seededit_tool(image_url: str, prompt: str, seed: int = -1,
|
|
147
157
|
|
148
158
|
|
149
159
|
@mcp.tool()
|
150
|
-
@
|
160
|
+
@async_retry()
|
151
161
|
async def vlm_vision_task_tool(messages: List) -> dict:
|
152
162
|
"""
|
153
163
|
Asynchronously perform vision-language tasks using VLM model.
|
@@ -162,7 +172,7 @@ async def vlm_vision_task_tool(messages: List) -> dict:
|
|
162
172
|
|
163
173
|
|
164
174
|
@mcp.tool()
|
165
|
-
@
|
175
|
+
@async_retry()
|
166
176
|
async def image_selector_tool(image_paths: List[str], prompt: str) -> dict:
|
167
177
|
"""
|
168
178
|
Asynchronously select the best image from multiple options using VLM model.
|
@@ -178,7 +188,7 @@ async def image_selector_tool(image_paths: List[str], prompt: str) -> dict:
|
|
178
188
|
|
179
189
|
|
180
190
|
@mcp.tool()
|
181
|
-
@
|
191
|
+
@async_retry()
|
182
192
|
async def video_selector_tool(video_paths: List[str], prompt: str) -> dict:
|
183
193
|
"""
|
184
194
|
Asynchronously select the best video from multiple options using VLM model.
|
@@ -194,7 +204,7 @@ async def video_selector_tool(video_paths: List[str], prompt: str) -> dict:
|
|
194
204
|
|
195
205
|
|
196
206
|
@mcp.tool()
|
197
|
-
@
|
207
|
+
@async_retry()
|
198
208
|
async def tos_save_content_tool(content: str, file_extension: str = "txt",
|
199
209
|
object_key: Optional[str] = None) -> dict:
|
200
210
|
"""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: media-agent-mcp
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.11
|
4
4
|
Summary: A Model Context Protocol server for media processing with AI tools
|
5
5
|
Author-email: Media Agent Team <team@mediaagent.com>
|
6
6
|
Keywords: mcp,ai,media,video,image,processing
|
@@ -22,7 +22,6 @@ Requires-Dist: numpy>=1.24.0
|
|
22
22
|
Requires-Dist: python-dotenv>=1.0.0
|
23
23
|
Requires-Dist: volcengine-python-sdk>=1.0.0
|
24
24
|
Requires-Dist: volcengine>=1.0.194
|
25
|
-
Requires-Dist: tenacity>=8.2.3
|
26
25
|
|
27
26
|
# Media Agent MCP
|
28
27
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
media_agent_mcp/__init__.py,sha256=4kV5u8kHrsdjpMHDNUhc8h4U6AwOyw1mNptFPd2snrQ,365
|
2
|
-
media_agent_mcp/async_server.py,sha256=
|
2
|
+
media_agent_mcp/async_server.py,sha256=IpXezeefilGukutgBqOU7RvCDp-t9_j11A2OOqiu2z0,10524
|
3
3
|
media_agent_mcp/async_wrapper.py,sha256=bHi0cCKxv6R9oHcNcNq8tV0AyKrTDV47s8BuWetqlIg,8992
|
4
4
|
media_agent_mcp/server.py,sha256=-mTeNcJXIlgByCG2HhaqV6zSbhjrQIEv_ssLN47KAzM,13759
|
5
5
|
media_agent_mcp/ai_models/__init__.py,sha256=WN8JDSJbj2-sNwaQg3MDwmm9mvJTC1mqpWliac3sHoc,427
|
@@ -14,8 +14,8 @@ media_agent_mcp/storage/__init__.py,sha256=eio7ZiSeLjCxICSZwZisiR7wKJfXlT2PV7aDE
|
|
14
14
|
media_agent_mcp/storage/tos_client.py,sha256=9c3GPmQe2stvxgZzsWYjVqKzVyvluZqYneCXYj-FQ3M,3174
|
15
15
|
media_agent_mcp/video/__init__.py,sha256=4ILnqYaUaYKI4GWOSg2SNZqt10UM1Y-8Q2SVvjoijqY,277
|
16
16
|
media_agent_mcp/video/processor.py,sha256=5ABPyj1IoD2xyIiB8dkEx4ZssPTXKHtuoFjy-dmnFks,11866
|
17
|
-
media_agent_mcp-0.3.
|
18
|
-
media_agent_mcp-0.3.
|
19
|
-
media_agent_mcp-0.3.
|
20
|
-
media_agent_mcp-0.3.
|
21
|
-
media_agent_mcp-0.3.
|
17
|
+
media_agent_mcp-0.3.11.dist-info/METADATA,sha256=92jf-Ti8koiMfQqYbpcFNwNVQ4sntuCz0XrRTnBe0rI,10976
|
18
|
+
media_agent_mcp-0.3.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
19
|
+
media_agent_mcp-0.3.11.dist-info/entry_points.txt,sha256=qhOUwR-ORVf9GO7emhhl7Lgd6MISgqbZr8bEuSH_VdA,70
|
20
|
+
media_agent_mcp-0.3.11.dist-info/top_level.txt,sha256=WEa0YfchpTxZgiKn8gdxYgs-dir5HepJaTOrxAGx9nY,16
|
21
|
+
media_agent_mcp-0.3.11.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|