@avclabs.ai/media-mcp 0.2.1 → 0.3.0

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.
package/README.md CHANGED
@@ -6,7 +6,9 @@ English | [中文](https://github.com/avclabs/media-mcp/blob/main/README_CN.md)
6
6
  [![Node.js >=18](https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg)](https://nodejs.org/)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
8
 
9
- A video enhancement and image segmentation service based on the MCP protocol, acting as an MCP Client-Server to interact with backend HTTP Servers.
9
+ A video enhancement, image enhancement/colorization/denoising, and image segmentation service based on the MCP protocol, acting as an MCP Client-Server to interact with backend HTTP Servers.
10
+
11
+ > **Release status:** the published npm package (`latest` = `0.2.1`) includes 3 video tools and 2 SAM3 tools. Image enhancement tools are in active development and will ship in an upcoming release — they are documented below for early adopters, but are not part of the published package yet.
10
12
 
11
13
  ## Features
12
14
 
@@ -15,10 +17,17 @@ Provides the following MCP Tools:
15
17
  **Video Enhancement**
16
18
  - `create_task` - Create a video enhancement task (supports URL or local file upload)
17
19
  - `get_task_status` - Query task status
18
- - `enhance_video_sync` - Synchronously enhance video (blocking wait, truncated at ~50s by default)
20
+ - `enhance_video_sync` - Synchronously enhance video (blocking wait, truncated at ~45s by default)
21
+
22
+ **Image Enhancement (coming soon — not in the published package yet)**
23
+ - `enhance_image_sync` - Enhance image quality and optimize faces (supports URL or local file upload)
24
+ - `colorize_image_sync` - Colorize black-and-white photos (supports URL or local file upload)
25
+ - `denoise_image_sync` - Remove noise from images (supports URL or local file upload)
26
+ - `get_image_task_status` - Query image task status (for polling after sync timeout)
19
27
 
20
28
  **Image Segmentation (SAM3)**
21
29
  - `sam3_predict` - SAM3 image segmentation (supports local path, URL, or Base64 image)
30
+ - `get_sam3_task_status` - Query SAM3 task status (for polling after sync timeout)
22
31
 
23
32
  ## Prerequisites
24
33
 
@@ -109,24 +118,28 @@ Or edit `~/.cursor/mcp.json`:
109
118
  After restarting your client, check if the tools are available:
110
119
 
111
120
  1. Or ask: "What tools do you have available?"
112
- 2. You should see: `create_task`, `get_task_status`, `enhance_video_sync`, `sam3_predict`
121
+ 2. With the current npm `latest=0.2.1`, you should see `create_task`, `get_task_status`, `enhance_video_sync`, `sam3_predict`, and `get_sam3_task_status`.
122
+ 3. Once the image tools ship in an upcoming release, you will additionally see `enhance_image_sync`, `colorize_image_sync`, `denoise_image_sync`, and `get_image_task_status`.
113
123
 
114
124
  ## Configuration Options
115
125
 
116
126
  | Variable | Required | Default | Description |
117
127
  |---|---|---|---|
118
- | `API_KEY` | **Yes** | - | API authentication key (shared by video enhancement and SAM3) |
119
- | `HTTP_API_BASE_URL` | No | `https://mcp.avc.ai/enhance` | Video enhancement service endpoint |
128
+ | `API_KEY` | **Yes** | - | API authentication key (shared by video, image, and SAM3 services) |
129
+ | `HTTP_API_BASE_URL` | No | `https://mcp.avc.ai/enhance` | Shared video and image HTTP service endpoint |
130
+ | `IMAGE_API_BASE_URL` | No | Same as `HTTP_API_BASE_URL` | Optional image endpoint override; omit for the shared production server |
120
131
  | `SAM3_API_BASE_URL` | No | `https://mcp.avc.ai/sam` | SAM3 service endpoint |
121
- | `SAM3_POLL_INTERVAL` | No | `2000` | SAM3 polling interval (milliseconds) |
122
- | `SAM3_POLL_MAX_ATTEMPTS` | No | `25` | SAM3 maximum polling attempts |
132
+ | `SAM3_POLL_INTERVAL_MS` | No | `2000` | SAM3 polling interval in milliseconds (`SAM3_POLL_INTERVAL` is a deprecated alias) |
133
+ | `SAM3_POLL_MAX_ATTEMPTS` | No | `25` | SAM3 maximum status queries; the time budget is interval × attempts, and whichever limit is hit first truncates the wait |
134
+
135
+ `IMAGE_API_BASE_URL` is an optional override for pointing image calls at a custom image endpoint. When omitted, image and video calls share the `HTTP_API_BASE_URL` service — the recommended setup for the production server.
123
136
 
124
137
  ### Custom Endpoint
125
138
 
126
139
  ```json
127
140
  {
128
141
  "env": {
129
- "HTTP_API_BASE_URL": "https://your-endpoint.com",
142
+ "HTTP_API_BASE_URL": "https://your-media-endpoint.com",
130
143
  "API_KEY": "your-api-key",
131
144
  "SAM3_API_BASE_URL": "https://your-sam3-endpoint.com"
132
145
  }
@@ -135,9 +148,11 @@ After restarting your client, check if the tools are available:
135
148
 
136
149
  Or via CLI args:
137
150
  ```bash
138
- npx -y @avclabs.ai/media-mcp@latest --base-url https://your-endpoint.com --api-key your-api-key --sam3-base-url https://your-sam3-endpoint.com
151
+ npx -y @avclabs.ai/media-mcp@latest --base-url https://your-media-endpoint.com --api-key your-api-key --sam3-base-url https://your-sam3-endpoint.com
139
152
  ```
140
153
 
154
+ The optional `--image-base-url` flag is available for deployments that intentionally split the public image endpoint; the current npm `latest` release does not use it (image calls share the main endpoint).
155
+
141
156
  ## Recommended Workflow
142
157
 
143
158
  This project provides both **synchronous** and **asynchronous** modes.
@@ -157,15 +172,15 @@ This project provides both **synchronous** and **asynchronous** modes.
157
172
 
158
173
  **Video Enhancement:**
159
174
  - Call `enhance_video_sync` → the server polls internally
160
- - Defaults to a maximum wait of 50 seconds
161
- - If completed within 50 seconds, returns the result directly
162
- - If not completed within 50 seconds, returns `task_id` and instructions for the Agent to switch to `get_task_status`
175
+ - Defaults to a maximum wait of 45 seconds
176
+ - If completed within 45 seconds, returns the result directly
177
+ - If not completed within 45 seconds, returns `task_id` and instructions for the Agent to switch to `get_task_status`
163
178
 
164
179
  **Image Segmentation (SAM3):**
165
180
  - Call `sam3_predict` → the server polls internally
166
- - Defaults to a maximum wait of 50 seconds (25 attempts × 2-second polling interval)
167
- - If completed within 50 seconds, returns the segmentation result directly
168
- - If not completed within 50 seconds, returns a truncation notice indicating the task is still processing
181
+ - Defaults to at most 25 status queries within a ~50-second budget (25 × 2-second interval; whichever limit is reached first ends the wait)
182
+ - If the task completes within the budget, returns the segmentation result directly
183
+ - If not completed within the budget, returns a truncation notice (with `task_id`) indicating the task is still processing
169
184
 
170
185
  ## Usage Examples
171
186
 
@@ -175,6 +190,12 @@ Once configured, ask your AI agent naturally:
175
190
 
176
191
  > "Improve the quality of /Users/me/Desktop/video.mp4 to 2k"
177
192
 
193
+ > "Enhance this image: https://example.com/photo.jpg"
194
+
195
+ > "Colorize this black-and-white photo: /Users/me/Desktop/old_photo.png"
196
+
197
+ > "Remove noise from this image: C:\\Users\\xxx\\noisy.jpg"
198
+
178
199
  > "Analyze this image and find all objects: C:\\Users\\xxx\\photo.png"
179
200
 
180
201
  > "Use SAM3 to segment this image, prompt: 'find all cars'"
@@ -234,27 +255,141 @@ The `message` field only appears when `status` is `processing`, prompting the Ag
234
255
 
235
256
  Synchronously enhance video (blocks until completion).
236
257
 
237
- > **Best for short videos (estimated processing time < 1 minute).** If the task is not completed within 50 seconds, the tool returns early with a `task_id`, and you need to use `get_task_status` to continue querying.
258
+ > **Best for short videos (estimated processing time < 1 minute).** If the task is not completed within the default 45-second wait budget, the tool returns early with a `task_id`, and you need to use `get_task_status` to continue querying.
238
259
 
239
260
  | Parameter | Type | Required | Default | Description |
240
261
  |---|---|---|---|---|
241
262
  | `video_source` | string | Yes | - | Video URL or local file path |
242
263
  | `type` | string | No | `url` | `url` or `local` |
243
264
  | `resolution` | string | No | `720p` | Target resolution |
244
- | `poll_interval` | number | No | `5` | Poll interval (seconds) |
245
- | `timeout` | number | No | `50` | Sync wait timeout (seconds), returns early when exceeded |
265
+ | `poll_interval` | number | No | `5` | Poll interval (seconds, 0.5-30) |
266
+ | `timeout` | number | No | `45` | Sync wait timeout in seconds (1-45), returns early when exceeded |
246
267
 
247
- **Truncated return example (not completed within 50s):**
268
+ **Truncated return example (not completed within the default 45-second budget):**
248
269
  ```json
249
270
  {
250
271
  "success": true,
251
272
  "status": "processing",
252
273
  "task_id": "xxx",
253
- "message": "Task is still processing (waited 50 seconds). Please use get_task_status to continue polling.",
274
+ "message": "Task is still processing (waited 45 seconds, 9 status queries). Please use get_task_status to continue polling.",
254
275
  "note": "The synchronous wait for this long-running task has been truncated. Switch to get_task_status polling."
255
276
  }
256
277
  ```
257
278
 
279
+ ### Image Enhancement
280
+
281
+ Three image processing tools are provided, each targeting a specific use case:
282
+
283
+ | Tool | Function | Use Case |
284
+ |---|---|---|
285
+ | `enhance_image_sync` | Image quality enhancement & face optimization | Blurry, low-resolution, or degraded photos |
286
+ | `colorize_image_sync` | Black-and-white photo colorization | Restoring old B&W photos with realistic colors |
287
+ | `denoise_image_sync` | Image noise removal | Noisy/grainy photos taken in low light |
288
+
289
+ All three tools share the same parameters and behavior pattern. They are **synchronous** — the tool blocks until the image is processed or the timeout is reached.
290
+
291
+ **Supported image formats**: PNG, JPG, JPEG, BMP, WebP, etc.
292
+
293
+ **Two upload methods**:
294
+ 1. **URL upload**: provide a publicly accessible image URL (`type: "url"`)
295
+ 2. **Local upload**: provide a local file path, the MCP Server auto-uploads to TOS object storage (`type: "local"`, max file size: 100MB)
296
+
297
+ #### enhance_image_sync
298
+
299
+ Synchronously enhance an image to improve quality and optimize faces.
300
+
301
+ > The tool internally creates a task and polls for the result. If processing completes within the timeout (default 45s), the result is returned directly. If not, the tool returns early with a `task_id` — use `get_image_task_status` to continue polling.
302
+
303
+ | Parameter | Type | Required | Default | Description |
304
+ |---|---|---|---|---|
305
+ | `image_source` | string | Yes | - | Image URL or local file path (URL must be publicly accessible, links requiring login or signatures are not supported) |
306
+ | `type` | string | No | `url` | `url` or `local` |
307
+ | `scale` | number | No | `2` | Enhancement scale multiplier (e.g. `2` for 2x, `4` for 4x upscaling) |
308
+ | `poll_interval` | number | No | `5` | Poll interval in seconds (0.5-30) |
309
+ | `timeout` | number | No | `45` | Sync wait timeout in seconds (1-45), returns early when exceeded |
310
+
311
+ **Normal completion return:**
312
+ ```json
313
+ {
314
+ "success": true,
315
+ "task_id": "xxx",
316
+ "status": "completed",
317
+ "progress": 100,
318
+ "image_url": "https://..."
319
+ }
320
+ ```
321
+
322
+ **Truncated return (not completed within the default 45-second budget):**
323
+ ```json
324
+ {
325
+ "success": true,
326
+ "status": "processing",
327
+ "task_id": "xxx",
328
+ "message": "Task is still processing (waited 45 seconds, 9 status queries). Please use get_image_task_status to continue polling.",
329
+ "note": "The synchronous wait for this long-running task has been truncated. Switch to get_image_task_status polling."
330
+ }
331
+ ```
332
+
333
+ #### colorize_image_sync
334
+
335
+ Synchronously colorize a black-and-white photo with AI.
336
+
337
+ > Best for old black-and-white photos. The AI will add realistic colors to the image. Supports the same parameters and return format as `enhance_image_sync`.
338
+
339
+ | Parameter | Type | Required | Default | Description |
340
+ |---|---|---|---|---|
341
+ | `image_source` | string | Yes | - | Image URL or local file path (URL must be publicly accessible, links requiring login or signatures are not supported) |
342
+ | `type` | string | No | `url` | `url` or `local` |
343
+ | `poll_interval` | number | No | `5` | Poll interval in seconds (0.5-30) |
344
+ | `timeout` | number | No | `45` | Sync wait timeout in seconds (1-45), returns early when exceeded |
345
+
346
+ **Returns:** Same format as `enhance_image_sync`.
347
+
348
+ #### denoise_image_sync
349
+
350
+ Synchronously remove noise from an image.
351
+
352
+ > Best for grainy/noisy photos taken in low-light conditions or with high ISO settings. Supports the same parameters and return format as `enhance_image_sync`.
353
+
354
+ | Parameter | Type | Required | Default | Description |
355
+ |---|---|---|---|---|
356
+ | `image_source` | string | Yes | - | Image URL or local file path (URL must be publicly accessible, links requiring login or signatures are not supported) |
357
+ | `type` | string | No | `url` | `url` or `local` |
358
+ | `poll_interval` | number | No | `5` | Poll interval in seconds (0.5-30) |
359
+ | `timeout` | number | No | `45` | Sync wait timeout in seconds (1-45), returns early when exceeded |
360
+
361
+ **Returns:** Same format as `enhance_image_sync`.
362
+
363
+ #### get_image_task_status
364
+
365
+ Query image processing task status. Used to poll for results when a sync tool times out.
366
+
367
+ > The returned `status` field can be: `processing`, `completed`, or `failed`. If `status` is `processing`, wait a few seconds and call this tool again.
368
+
369
+ | Parameter | Type | Required |
370
+ |---|---|---|
371
+ | `task_id` | string | Yes |
372
+
373
+ **Returns:**
374
+ ```json
375
+ {
376
+ "success": true,
377
+ "task_id": "xxx",
378
+ "status": "completed",
379
+ "progress": 100,
380
+ "image_url": "https://...",
381
+ "message": "Task is still processing, please check again later"
382
+ }
383
+ ```
384
+
385
+ The `message` field only appears when `status` is `processing`, prompting the Agent to continue waiting.
386
+
387
+ #### Recommended Workflow for Image Tools
388
+
389
+ 1. **For most images**: Call `enhance_image_sync` / `colorize_image_sync` / `denoise_image_sync` directly — the tool handles everything and returns the result
390
+ 2. **If truncated**: The tool returns a `task_id`, then use `get_image_task_status` to poll until `status` becomes `completed` or `failed`
391
+ 3. **If failed**: Check the `error_message` field for details
392
+
258
393
  ### Image Segmentation (SAM3)
259
394
 
260
395
  #### sam3_predict
@@ -315,13 +450,85 @@ Example result JSON:
315
450
  "success": true,
316
451
  "status": "processing",
317
452
  "task_id": "xxx",
318
- "message": "Task is still processing (waited about 50 seconds). Please retry later or record this task_id for manual follow-up.",
319
- "note": "The synchronous wait for this long-running task has been truncated."
453
+ "message": "Task is still processing (waited 50 seconds, 25 status queries). Please use get_sam3_task_status to continue polling.",
454
+ "note": "The synchronous wait for this long-running task has been truncated. Switch to task status polling."
455
+ }
456
+ ```
457
+
458
+ **Result download failure (completed task, missing result):**
459
+ If the task completed but the result file could not be downloaded, the tool returns `success: false` with the `task_id` and `status: "completed"`. Use `get_sam3_task_status` with that `task_id` to recover the result. Do not resubmit the task.
460
+ ```json
461
+ {
462
+ "success": false,
463
+ "task_id": "xxx",
464
+ "status": "completed",
465
+ "error": "Failed to download the completed result for task xxx: ...",
466
+ "note": "The task has completed; only the result download failed. Do not resubmit. Use get_sam3_task_status with this task_id to recover the result."
467
+ }
468
+ ```
469
+
470
+ #### get_sam3_task_status
471
+
472
+ Query SAM3 segmentation task status. Used to poll for results when `sam3_predict` times out.
473
+
474
+ > The returned `status` field can be: `processing`, `completed`, or `failed`. If `status` is `processing`, wait a few seconds and call this tool again.
475
+
476
+ | Parameter | Type | Required |
477
+ |---|---|---|
478
+ | `task_id` | string | Yes |
479
+
480
+ **Completed return:**
481
+ ```json
482
+ {
483
+ "success": true,
484
+ "task_id": "xxx",
485
+ "status": "completed",
486
+ "result_url": "https://..."
487
+ }
488
+ ```
489
+
490
+ **Processing return:**
491
+ ```json
492
+ {
493
+ "success": true,
494
+ "task_id": "xxx",
495
+ "status": "processing",
496
+ "message": "Task is still processing, please check again later."
497
+ }
498
+ ```
499
+
500
+ **Failed return:**
501
+ ```json
502
+ {
503
+ "success": false,
504
+ "task_id": "xxx",
505
+ "status": "failed",
506
+ "error": "Task failed"
320
507
  }
321
508
  ```
322
509
 
323
510
  ## FAQ
324
511
 
512
+ ### Is AVCLabs Media MCP free to use?
513
+
514
+ You get a free quota when you register — no credit card required. Beyond the free quota, pricing is pay-as-you-go credit packs (from $19.95) and monthly subscriptions (from $9.95/month). See https://mcp.avc.ai/pricing/ for the current plans.
515
+
516
+ ### Which AI clients work with it?
517
+
518
+ Any MCP-compatible client. One-command setup guides are available for Claude Code, Cursor, and Windsurf at https://mcp.avc.ai/docs/ (the package speaks standard MCP stdio, so other agents work by adding the same `npx` config).
519
+
520
+ ### Does it need a GPU or powerful hardware?
521
+
522
+ No. Video enhancement and SAM3 inference run on AVCLabs' cloud infrastructure. Your machine only runs the lightweight MCP stdio server process (Node.js 18+), so a plain laptop is enough.
523
+
524
+ ### Where do I get an API key?
525
+
526
+ Register at https://mcp.avc.ai/ and create a key in the dashboard. The key authenticates video enhancement, image tools, and SAM3 segmentation.
527
+
528
+ ### What does `sam3_predict` return?
529
+
530
+ Pixel-level segmentation masks, bounding boxes, and per-instance confidence scores for the objects described by your text prompt — ready to plug into compositing, annotation, or further analysis.
531
+
325
532
  ### Agent reports timeout when calling tools?
326
533
 
327
534
  This is the primary issue this project addresses. MCP Agents (such as Claude, Cursor) typically enforce a ~60-second timeout per tool call. If task processing exceeds this limit, the Agent will error and disconnect.
@@ -330,15 +537,11 @@ This is the primary issue this project addresses. MCP Agents (such as Claude, Cu
330
537
 
331
538
  1. **Prefer asynchronous tools**: For video enhancement and other time-consuming tasks, always use `create_task` + `get_task_status`. These tools return instantly on each call and will not trigger timeouts.
332
539
 
333
- 2. **Sync tool truncation mechanism**: `enhance_video_sync` has an internal 50-second truncation limit. If the task is not completed within 50 seconds, the tool proactively returns a `task_id` and instructs the Agent to use `get_task_status` to follow up.
540
+ 2. **Sync tool truncation mechanism**: `enhance_video_sync` has an internal 45-second truncation limit (default `timeout`). If the task is not completed within the budget, the tool proactively returns a `task_id` and instructs the Agent to use `get_task_status` to follow up.
334
541
 
335
- 3. **SAM3 truncation mechanism**: `sam3_predict` defaults to 25 polling attempts (~50 seconds). If the task is not completed, it returns a truncation notice indicating the task is still processing.
542
+ 3. **SAM3 truncation mechanism**: `sam3_predict` is bounded by two independent limits derived from its config: at most `SAM3_POLL_MAX_ATTEMPTS` status queries (default 25) and a time budget of `SAM3_POLL_INTERVAL_MS × attempts` (default 25 × 2 s ≈ 50 s). Whichever runs out first truncates the wait; the returned notice carries the `task_id` and the actual elapsed time and query count, and the task keeps running remotely.
336
543
 
337
- 4. **Adjust SAM3 polling parameters** (advanced): If you are confident that SAM3 tasks are usually fast (e.g., under 10 seconds), you can increase polling attempts via environment variable:
338
- ```bash
339
- SAM3_POLL_MAX_ATTEMPTS=60
340
- ```
341
- But ensure the total wait time does not exceed your Agent's timeout limit.
544
+ 4. **Adjust SAM3 polling parameters** (advanced): The two SAM3 limits are independent, so you can trade interval for attempt count freely (e.g. `SAM3_POLL_INTERVAL_MS=1000` with `SAM3_POLL_MAX_ATTEMPTS=50` still gives a ~50-second budget with twice as many queries). Lower the interval if the task usually finishes in a few seconds and you want quicker completion detection. Invalid explicit values (non-integer or outside the allowed range) abort startup before any task can be submitted. The wait budget covers only status polling after the task is created — source preparation, upload, task submission, and the final result download are not part of it, so the total tool call can take longer than the budget.
342
545
 
343
546
  ### Drag-and-drop attachment says file not found?
344
547
 
@@ -389,7 +592,7 @@ When `type` is `"local"`:
389
592
 
390
593
  Install Node.js >= 18: https://nodejs.org/
391
594
 
392
- ### "Error: --api-key argument or API_KEY environment variable is required"
595
+ ### "API key is required: pass --api-key or set the API_KEY environment variable"
393
596
 
394
597
  Your API Key is missing. Double-check the `env.API_KEY` in your config.
395
598
 
@@ -402,7 +605,7 @@ Check logs:
402
605
 
403
606
  ### "TOS upload failed"
404
607
 
405
- Usually a signature mismatch. Ensure your `HTTP_API_BASE_URL` and `API_KEY` are correct and active.
608
+ Usually a signature mismatch. Ensure your `IMAGE_API_BASE_URL` (or its `HTTP_API_BASE_URL` fallback) and `API_KEY` are correct and active.
406
609
 
407
610
  ## Global Install (Alternative)
408
611
 
@@ -414,6 +617,17 @@ npm install -g @avclabs.ai/media-mcp
414
617
 
415
618
  Then use `"command": "media-mcp"` with `"args": ["--api-key", "your-api-key"]` in your config.
416
619
 
620
+ ## Development and Release
621
+
622
+ This package runs locally in the MCP client and is released through npm; it is not a remote Node daemon. To verify a working tree before publishing:
623
+
624
+ ```bash
625
+ npm ci
626
+ npm run release:verify
627
+ ```
628
+
629
+ Maintainers: see the [release guide](https://github.com/avclabs/media-mcp/blob/main/docs/RELEASE.md) for the current release status, version synchronization, publish order, smoke tests, and the relationship with the portal/backend deployment.
630
+
417
631
  ## License
418
632
 
419
633
  MIT License - See [LICENSE](LICENSE) file for details