@felores/kie-ai-mcp-server 3.0.0 → 3.0.1
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/dist/index.js +131 -2
- package/dist/kie-ai-client.d.ts +2 -1
- package/dist/kie-ai-client.js +13 -1
- package/dist/types.d.ts +15 -1
- package/dist/types.js +6 -0
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, ListResources
|
|
|
5
5
|
import { KieAiClient } from "./kie-ai-client.js";
|
|
6
6
|
import { TaskDatabase } from "./database.js";
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
import { NanoBananaImageSchema, Veo3GenerateSchema, SunoGenerateSchema, ElevenLabsTTSSchema, ElevenLabsSoundEffectsSchema, ByteDanceSeedanceVideoSchema, ByteDanceSeedreamImageSchema, QwenImageSchema, RunwayAlephVideoSchema, WanVideoSchema, MidjourneyGenerateSchema, OpenAI4oImageSchema, FluxKontextImageSchema, RecraftRemoveBackgroundSchema, IdeogramReframeSchema, KlingVideoSchema, HailuoVideoSchema, SoraVideoSchema, Flux2ImageSchema, WanAnimateSchema, ZImageSchema, GrokImagineSchema, InfiniTalkSchema, KlingAvatarSchema, } from "./types.js";
|
|
8
|
+
import { NanoBananaImageSchema, Veo3GenerateSchema, SunoGenerateSchema, ElevenLabsTTSSchema, ElevenLabsSoundEffectsSchema, ByteDanceSeedanceVideoSchema, ByteDanceSeedreamImageSchema, QwenImageSchema, RunwayAlephVideoSchema, WanVideoSchema, MidjourneyGenerateSchema, OpenAI4oImageSchema, FluxKontextImageSchema, RecraftRemoveBackgroundSchema, IdeogramReframeSchema, KlingVideoSchema, HailuoVideoSchema, SoraVideoSchema, Flux2ImageSchema, WanAnimateSchema, ZImageSchema, GrokImagineSchema, InfiniTalkSchema, KlingAvatarSchema, TopazUpscaleImageSchema, } from "./types.js";
|
|
9
9
|
class KieAiMcpServer {
|
|
10
10
|
server;
|
|
11
11
|
client;
|
|
@@ -21,6 +21,7 @@ class KieAiMcpServer {
|
|
|
21
21
|
"flux_kontext_image",
|
|
22
22
|
"flux2_image",
|
|
23
23
|
"z_image",
|
|
24
|
+
"topaz_upscale_image",
|
|
24
25
|
"recraft_remove_background",
|
|
25
26
|
"ideogram_reframe",
|
|
26
27
|
"midjourney_generate", // Also generates images (6 modes: txt2img, img2img, style ref, omni ref, video SD/HD)
|
|
@@ -52,7 +53,7 @@ class KieAiMcpServer {
|
|
|
52
53
|
constructor() {
|
|
53
54
|
this.server = new Server({
|
|
54
55
|
name: "kie-ai-mcp-server",
|
|
55
|
-
version: "3.0.
|
|
56
|
+
version: "3.0.1",
|
|
56
57
|
});
|
|
57
58
|
// Initialize client with config from environment
|
|
58
59
|
this.config = {
|
|
@@ -1405,6 +1406,32 @@ class KieAiMcpServer {
|
|
|
1405
1406
|
required: ["prompt"],
|
|
1406
1407
|
},
|
|
1407
1408
|
},
|
|
1409
|
+
{
|
|
1410
|
+
name: "topaz_upscale_image",
|
|
1411
|
+
description: "Upscale and enhance images using Topaz Labs AI upscaler. Increases resolution with high-fidelity detail restoration, natural texture reconstruction, and improved clarity. Supports 1x-8x upscaling (max output 20,000px per side). Pricing: 10 credits (≤2K), 20 credits (4K), 40 credits (8K).",
|
|
1412
|
+
inputSchema: {
|
|
1413
|
+
type: "object",
|
|
1414
|
+
properties: {
|
|
1415
|
+
image_url: {
|
|
1416
|
+
type: "string",
|
|
1417
|
+
description: "URL of image to upscale (JPEG, PNG, WEBP, max 10MB)",
|
|
1418
|
+
format: "uri",
|
|
1419
|
+
},
|
|
1420
|
+
upscale_factor: {
|
|
1421
|
+
type: "string",
|
|
1422
|
+
description: "Upscale factor: 1x (enhance only), 2x (default), 4x, or 8x. Max output dimension is 20,000px.",
|
|
1423
|
+
enum: ["1", "2", "4", "8"],
|
|
1424
|
+
default: "2",
|
|
1425
|
+
},
|
|
1426
|
+
callBackUrl: {
|
|
1427
|
+
type: "string",
|
|
1428
|
+
description: "Optional: URL for task completion notifications (uses KIE_AI_CALLBACK_URL env var if not provided)",
|
|
1429
|
+
format: "uri",
|
|
1430
|
+
},
|
|
1431
|
+
},
|
|
1432
|
+
required: ["image_url"],
|
|
1433
|
+
},
|
|
1434
|
+
},
|
|
1408
1435
|
{
|
|
1409
1436
|
name: "recraft_remove_background",
|
|
1410
1437
|
description: "Remove backgrounds from images using Recraft AI background removal model",
|
|
@@ -1837,6 +1864,8 @@ class KieAiMcpServer {
|
|
|
1837
1864
|
return await this.handleRunwayAlephVideo(args);
|
|
1838
1865
|
case "wan_video":
|
|
1839
1866
|
return await this.handleWanVideo(args);
|
|
1867
|
+
case "topaz_upscale_image":
|
|
1868
|
+
return await this.handleTopazUpscaleImage(args);
|
|
1840
1869
|
case "recraft_remove_background":
|
|
1841
1870
|
return await this.handleRecraftRemoveBackground(args);
|
|
1842
1871
|
case "ideogram_reframe":
|
|
@@ -2020,6 +2049,16 @@ class KieAiMcpServer {
|
|
|
2020
2049
|
},
|
|
2021
2050
|
},
|
|
2022
2051
|
// Specialized Tools
|
|
2052
|
+
{
|
|
2053
|
+
uri: "kie://models/topaz-upscale",
|
|
2054
|
+
name: "Topaz Image Upscale",
|
|
2055
|
+
description: "AI-powered image upscaling with detail restoration (1x-8x)",
|
|
2056
|
+
mimeType: "text/markdown",
|
|
2057
|
+
annotations: {
|
|
2058
|
+
audience: ["assistant"],
|
|
2059
|
+
priority: 0.5,
|
|
2060
|
+
},
|
|
2061
|
+
},
|
|
2023
2062
|
{
|
|
2024
2063
|
uri: "kie://models/recraft-bg-removal",
|
|
2025
2064
|
name: "Recraft Background Removal",
|
|
@@ -2429,6 +2468,33 @@ class KieAiMcpServer {
|
|
|
2429
2468
|
errorMessage = apiData.errorMessage;
|
|
2430
2469
|
}
|
|
2431
2470
|
}
|
|
2471
|
+
else if (localTask?.api_type === "topaz-upscale") {
|
|
2472
|
+
// Topaz Image Upscale-specific status mapping
|
|
2473
|
+
const state = apiData.state;
|
|
2474
|
+
if (state === "success")
|
|
2475
|
+
status = "completed";
|
|
2476
|
+
else if (state === "fail")
|
|
2477
|
+
status = "failed";
|
|
2478
|
+
else if (state === "waiting")
|
|
2479
|
+
status = "processing";
|
|
2480
|
+
// Parse resultJson for Topaz Image Upscale
|
|
2481
|
+
if (apiData.resultJson) {
|
|
2482
|
+
try {
|
|
2483
|
+
parsedResult = JSON.parse(apiData.resultJson);
|
|
2484
|
+
if (parsedResult.resultUrls &&
|
|
2485
|
+
parsedResult.resultUrls.length > 0) {
|
|
2486
|
+
resultUrl = parsedResult.resultUrls[0];
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
catch (e) {
|
|
2490
|
+
// Invalid JSON in resultJson
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
// Extract error message for Topaz Image Upscale
|
|
2494
|
+
if (apiData.failMsg) {
|
|
2495
|
+
errorMessage = apiData.failMsg;
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2432
2498
|
else if (localTask?.api_type === "recraft-remove-background") {
|
|
2433
2499
|
// Recraft Remove Background-specific status mapping
|
|
2434
2500
|
const state = apiData.state;
|
|
@@ -2530,6 +2596,7 @@ class KieAiMcpServer {
|
|
|
2530
2596
|
"qwen-image",
|
|
2531
2597
|
"openai-4o-image",
|
|
2532
2598
|
"flux-kontext-image",
|
|
2599
|
+
"topaz-upscale",
|
|
2533
2600
|
"recraft-remove-background",
|
|
2534
2601
|
"ideogram-reframe",
|
|
2535
2602
|
"midjourney",
|
|
@@ -3924,6 +3991,61 @@ class KieAiMcpServer {
|
|
|
3924
3991
|
});
|
|
3925
3992
|
}
|
|
3926
3993
|
}
|
|
3994
|
+
async handleTopazUpscaleImage(args) {
|
|
3995
|
+
try {
|
|
3996
|
+
const request = TopazUpscaleImageSchema.parse(args);
|
|
3997
|
+
// Use intelligent callback URL fallback
|
|
3998
|
+
request.callBackUrl = this.getCallbackUrl(request.callBackUrl);
|
|
3999
|
+
const response = await this.client.generateTopazUpscaleImage(request);
|
|
4000
|
+
if (response.code === 200 && response.data?.taskId) {
|
|
4001
|
+
// Store task in database
|
|
4002
|
+
await this.db.createTask({
|
|
4003
|
+
task_id: response.data.taskId,
|
|
4004
|
+
api_type: "topaz-upscale",
|
|
4005
|
+
status: "pending",
|
|
4006
|
+
});
|
|
4007
|
+
return {
|
|
4008
|
+
content: [
|
|
4009
|
+
{
|
|
4010
|
+
type: "text",
|
|
4011
|
+
text: JSON.stringify({
|
|
4012
|
+
success: true,
|
|
4013
|
+
task_id: response.data.taskId,
|
|
4014
|
+
message: "Topaz Image Upscale task created successfully",
|
|
4015
|
+
parameters: {
|
|
4016
|
+
image_url: request.image_url,
|
|
4017
|
+
upscale_factor: request.upscale_factor,
|
|
4018
|
+
callBackUrl: request.callBackUrl,
|
|
4019
|
+
},
|
|
4020
|
+
next_steps: [
|
|
4021
|
+
"Use get_task_status to check generation progress",
|
|
4022
|
+
"Task completion will be sent to the provided callback URL",
|
|
4023
|
+
"Upscaling typically takes 30-90 seconds depending on image size and upscale factor",
|
|
4024
|
+
],
|
|
4025
|
+
}, null, 2),
|
|
4026
|
+
},
|
|
4027
|
+
],
|
|
4028
|
+
};
|
|
4029
|
+
}
|
|
4030
|
+
else {
|
|
4031
|
+
throw new Error(response.msg || "Failed to create Topaz Image Upscale task");
|
|
4032
|
+
}
|
|
4033
|
+
}
|
|
4034
|
+
catch (error) {
|
|
4035
|
+
if (error instanceof z.ZodError) {
|
|
4036
|
+
return this.formatError("topaz_upscale_image", error, {
|
|
4037
|
+
image_url: "Required: URL of image to upscale (JPEG, PNG, WEBP, max 10MB)",
|
|
4038
|
+
upscale_factor: 'Optional: Upscale factor "1", "2" (default), "4", or "8". Max output dimension is 20,000px.',
|
|
4039
|
+
callBackUrl: "Optional: URL for task completion notifications (uses KIE_AI_CALLBACK_URL env var if not provided)",
|
|
4040
|
+
});
|
|
4041
|
+
}
|
|
4042
|
+
return this.formatError("topaz_upscale_image", error, {
|
|
4043
|
+
image_url: "Required: URL of image to upscale",
|
|
4044
|
+
upscale_factor: 'Optional: Upscale factor "1", "2", "4", or "8"',
|
|
4045
|
+
callBackUrl: "Optional: URL for task completion notifications",
|
|
4046
|
+
});
|
|
4047
|
+
}
|
|
4048
|
+
}
|
|
3927
4049
|
async handleRecraftRemoveBackground(args) {
|
|
3928
4050
|
try {
|
|
3929
4051
|
const request = RecraftRemoveBackgroundSchema.parse(args);
|
|
@@ -4537,6 +4659,12 @@ class KieAiMcpServer {
|
|
|
4537
4659
|
category: "image",
|
|
4538
4660
|
quality: "premium",
|
|
4539
4661
|
},
|
|
4662
|
+
{
|
|
4663
|
+
name: "topaz_upscale_image",
|
|
4664
|
+
status: "available",
|
|
4665
|
+
category: "image",
|
|
4666
|
+
quality: "professional",
|
|
4667
|
+
},
|
|
4540
4668
|
{
|
|
4541
4669
|
name: "recraft_remove_background",
|
|
4542
4670
|
status: "available",
|
|
@@ -5025,6 +5153,7 @@ These guidelines ensure optimal balance between quality requirements and cost ma
|
|
|
5025
5153
|
"flux-kontext": "flux_kontext_image.md",
|
|
5026
5154
|
"openai-4o-image": "openai_4o-image.md",
|
|
5027
5155
|
"nano-banana": "google_nano-banana.md",
|
|
5156
|
+
"topaz-upscale": "topaz_image-upscale.md",
|
|
5028
5157
|
"recraft-bg-removal": "recraft_remove_background.md",
|
|
5029
5158
|
"ideogram-reframe": "ideogram_reframe_image.md",
|
|
5030
5159
|
// Video models
|
package/dist/kie-ai-client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KieAiConfig, KieAiResponse, NanoBananaImageRequest, Veo3GenerateRequest, SunoGenerateRequest, ElevenLabsTTSRequest, ElevenLabsSoundEffectsRequest, ByteDanceSeedanceVideoRequest, RunwayAlephVideoRequest, WanVideoRequest, ByteDanceSeedreamImageRequest, QwenImageRequest, MidjourneyGenerateRequest, OpenAI4oImageRequest, FluxKontextImageRequest, RecraftRemoveBackgroundRequest, IdeogramReframeRequest, KlingVideoRequest, HailuoVideoRequest, SoraVideoRequest, Flux2ImageRequest, WanAnimateRequest, ZImageRequest, GrokImagineRequest, InfiniTalkRequest, KlingAvatarRequest, ImageResponse, TaskResponse } from "./types.js";
|
|
1
|
+
import { KieAiConfig, KieAiResponse, NanoBananaImageRequest, Veo3GenerateRequest, SunoGenerateRequest, ElevenLabsTTSRequest, ElevenLabsSoundEffectsRequest, ByteDanceSeedanceVideoRequest, RunwayAlephVideoRequest, WanVideoRequest, ByteDanceSeedreamImageRequest, QwenImageRequest, MidjourneyGenerateRequest, OpenAI4oImageRequest, FluxKontextImageRequest, RecraftRemoveBackgroundRequest, IdeogramReframeRequest, KlingVideoRequest, HailuoVideoRequest, SoraVideoRequest, Flux2ImageRequest, WanAnimateRequest, ZImageRequest, GrokImagineRequest, InfiniTalkRequest, KlingAvatarRequest, TopazUpscaleImageRequest, ImageResponse, TaskResponse } from "./types.js";
|
|
2
2
|
export declare class KieAiClient {
|
|
3
3
|
private config;
|
|
4
4
|
constructor(config: KieAiConfig);
|
|
@@ -28,5 +28,6 @@ export declare class KieAiClient {
|
|
|
28
28
|
generateZImage(request: ZImageRequest): Promise<KieAiResponse<TaskResponse>>;
|
|
29
29
|
generateGrokImagine(request: GrokImagineRequest): Promise<KieAiResponse<TaskResponse>>;
|
|
30
30
|
generateInfiniTalk(request: InfiniTalkRequest): Promise<KieAiResponse<TaskResponse>>;
|
|
31
|
+
generateTopazUpscaleImage(request: TopazUpscaleImageRequest): Promise<KieAiResponse<TaskResponse>>;
|
|
31
32
|
generateKlingAvatar(request: KlingAvatarRequest): Promise<KieAiResponse<TaskResponse>>;
|
|
32
33
|
}
|
package/dist/kie-ai-client.js
CHANGED
|
@@ -84,7 +84,8 @@ export class KieAiClient {
|
|
|
84
84
|
apiType === "hailuo" ||
|
|
85
85
|
apiType === "sora-video" ||
|
|
86
86
|
apiType === "flux2-image" ||
|
|
87
|
-
apiType === "wan-animate"
|
|
87
|
+
apiType === "wan-animate" ||
|
|
88
|
+
apiType === "topaz-upscale") {
|
|
88
89
|
return this.makeRequest(`/jobs/recordInfo?taskId=${taskId}`, "GET");
|
|
89
90
|
}
|
|
90
91
|
else if (apiType === "runway-aleph-video") {
|
|
@@ -773,6 +774,17 @@ export class KieAiClient {
|
|
|
773
774
|
};
|
|
774
775
|
return this.makeRequest("/jobs/createTask", "POST", jobRequest);
|
|
775
776
|
}
|
|
777
|
+
async generateTopazUpscaleImage(request) {
|
|
778
|
+
const jobRequest = {
|
|
779
|
+
model: "topaz/image-upscale",
|
|
780
|
+
input: {
|
|
781
|
+
image_url: request.image_url,
|
|
782
|
+
upscale_factor: request.upscale_factor || "2",
|
|
783
|
+
},
|
|
784
|
+
callBackUrl: request.callBackUrl || process.env.KIE_AI_CALLBACK_URL,
|
|
785
|
+
};
|
|
786
|
+
return this.makeRequest("/jobs/createTask", "POST", jobRequest);
|
|
787
|
+
}
|
|
776
788
|
async generateKlingAvatar(request) {
|
|
777
789
|
const quality = request.quality || "standard";
|
|
778
790
|
const model = quality === "pro" ? "kling/ai-avatar-v1-pro" : "kling/v1-avatar-standard";
|
package/dist/types.d.ts
CHANGED
|
@@ -814,6 +814,20 @@ export declare const FluxKontextImageSchema: z.ZodEffects<z.ZodObject<{
|
|
|
814
814
|
safetyTolerance?: number | undefined;
|
|
815
815
|
}>;
|
|
816
816
|
export type FluxKontextImageRequest = z.infer<typeof FluxKontextImageSchema>;
|
|
817
|
+
export declare const TopazUpscaleImageSchema: z.ZodObject<{
|
|
818
|
+
image_url: z.ZodString;
|
|
819
|
+
upscale_factor: z.ZodDefault<z.ZodEnum<["1", "2", "4", "8"]>>;
|
|
820
|
+
callBackUrl: z.ZodOptional<z.ZodString>;
|
|
821
|
+
}, "strip", z.ZodTypeAny, {
|
|
822
|
+
image_url: string;
|
|
823
|
+
upscale_factor: "1" | "2" | "4" | "8";
|
|
824
|
+
callBackUrl?: string | undefined;
|
|
825
|
+
}, {
|
|
826
|
+
image_url: string;
|
|
827
|
+
callBackUrl?: string | undefined;
|
|
828
|
+
upscale_factor?: "1" | "2" | "4" | "8" | undefined;
|
|
829
|
+
}>;
|
|
830
|
+
export type TopazUpscaleImageRequest = z.infer<typeof TopazUpscaleImageSchema>;
|
|
817
831
|
export declare const RecraftRemoveBackgroundSchema: z.ZodEffects<z.ZodObject<{
|
|
818
832
|
image: z.ZodString;
|
|
819
833
|
callBackUrl: z.ZodOptional<z.ZodString>;
|
|
@@ -1152,7 +1166,7 @@ export interface TaskResponse {
|
|
|
1152
1166
|
export interface TaskRecord {
|
|
1153
1167
|
id?: number;
|
|
1154
1168
|
task_id: string;
|
|
1155
|
-
api_type: "nano-banana" | "nano-banana-edit" | "nano-banana-image" | "veo3" | "suno" | "elevenlabs-tts" | "elevenlabs-sound-effects" | "bytedance-seedance-video" | "runway-aleph-video" | "wan-video" | "bytedance-seedream-image" | "qwen-image" | "midjourney" | "openai-4o-image" | "flux-kontext-image" | "recraft-remove-background" | "ideogram-reframe" | "kling-3.0-video" | "hailuo" | "sora-video" | "flux2-image" | "wan-animate" | "z-image" | "grok-imagine" | "infinitalk" | "kling-avatar";
|
|
1169
|
+
api_type: "nano-banana" | "nano-banana-edit" | "nano-banana-image" | "veo3" | "suno" | "elevenlabs-tts" | "elevenlabs-sound-effects" | "bytedance-seedance-video" | "runway-aleph-video" | "wan-video" | "bytedance-seedream-image" | "qwen-image" | "midjourney" | "openai-4o-image" | "flux-kontext-image" | "recraft-remove-background" | "ideogram-reframe" | "kling-3.0-video" | "hailuo" | "sora-video" | "flux2-image" | "wan-animate" | "z-image" | "grok-imagine" | "infinitalk" | "kling-avatar" | "topaz-upscale";
|
|
1156
1170
|
status: "pending" | "processing" | "completed" | "failed";
|
|
1157
1171
|
created_at: string;
|
|
1158
1172
|
updated_at: string;
|
package/dist/types.js
CHANGED
|
@@ -557,6 +557,12 @@ export const FluxKontextImageSchema = z
|
|
|
557
557
|
message: "For image editing mode, safetyTolerance must be between 0 and 2",
|
|
558
558
|
path: ["safetyTolerance"],
|
|
559
559
|
});
|
|
560
|
+
// Topaz Image Upscale - AI-powered image enhancement and upscaling
|
|
561
|
+
export const TopazUpscaleImageSchema = z.object({
|
|
562
|
+
image_url: z.string().url(),
|
|
563
|
+
upscale_factor: z.enum(["1", "2", "4", "8"]).default("2"),
|
|
564
|
+
callBackUrl: z.string().url().optional(),
|
|
565
|
+
});
|
|
560
566
|
// Recraft Remove Background
|
|
561
567
|
export const RecraftRemoveBackgroundSchema = z
|
|
562
568
|
.object({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@felores/kie-ai-mcp-server",
|
|
3
|
-
"version": "3.0.
|
|
4
|
-
"description": "MCP server for Kie.ai APIs (
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"description": "MCP server for Kie.ai APIs (24 AI tools: Nano Banana image generation/editing/upscaling, Veo3 video generation, Suno music generation, ElevenLabs TTS/sound effects, ByteDance Seedance/Seedream video/image, Qwen image generation/editing, Runway Aleph video transformation, Midjourney AI generation, Wan video generation, Hailuo video generation, Kling video generation, OpenAI 4o image generation/editing/variants, Flux Kontext image generation/editing, Recraft background removal, Ideogram image reframing, Sora 2 video generation, Topaz image upscaling)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"kie-ai-mcp-server": "dist/index.js"
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"flux-2",
|
|
38
38
|
"recraft",
|
|
39
39
|
"ideogram",
|
|
40
|
+
"topaz",
|
|
40
41
|
"model-context-protocol",
|
|
41
42
|
"ai-api",
|
|
42
43
|
"unified-ai"
|