How to Use the Kling AI (Generative Video & Image) MCP in Mastra AI
Build resilient video generation workflows with Mastra AI. Automate retries for `text_to_video` and branch on task status.
Works with every AI agent you already use
…and any MCP-compatible client
Connect Kling AI (Generative Video & Image) MCP to Mastra AI
Create your Vinkius account to connect Kling AI (Generative Video & Image) to Mastra AI and route execution through our secure gateway. The platform manages server hosting, runtime updates, and security layers. Configuration requires no manual server provisioning.
Unattended Video Generation
This isn't about firing off a single API call; it's about building a workflow that survives errors. Your Mastra AI agent calls `text_to_video` to start a job, then enters a polling loop on `get_video_task`. Mastra's engine handles the logic. If `get_video_task` fails or times out, you can configure automatic retries with exponential backoff. If it succeeds, the workflow can pass the video URL to the next step, like a notification service or a database.
Conditional E-commerce Asset Pipelines
Automate your entire product visualization pipeline. An agent can use `virtual_try_on` to generate a new product shot. The workflow then polls `get_tryon_task` to check the result. Here's where Mastra AI shines. You build conditional logic in your workflow. If the `get_tryon_task` succeeds, the agent adds the image URL to a database. If it fails, it can log the error and try again with a different model image.
A Resilient Mastra AI MCP Server
This MCP server provides all the tools for a complete generative pipeline. Your agent can start with `text_to_image` to create a character, then use `image_to_video` to animate it, all within one workflow. Each step is a separate, monitored task. Your workflow can even use `list_video_tasks` to get a history of recent jobs for auditing or cleanup. Mastra AI ensures the sequence runs reliably from start to finish.
Set up Kling AI (Generative Video & Image) MCP in Mastra AI
Prerequisites
- Node.js 18+ and a TypeScript project
-
@mastra/mcp+@mastra/corepackages - Active Vinkius subscription with a valid endpoint token
- 1
Install dependencies
Run
npm install @mastra/mcp @mastra/coreplus your preferred model provider (e.g.@ai-sdk/openai). - 2
Configure the MCPClient
Create an
MCPClientwith your Vinkius endpoint as aURLobject. Replace[YOUR_TOKEN_HERE]with your token from cloud.vinkius.com. - 3
Discover and inject tools
Call
mcpClient.listTools()and spread the result into your agent'stoolsobject. All Kling AI (Generative Video & Image) tools become native Mastra tools. - 4
Run with any model
Swap
openai("gpt-4o")for any AI SDK-compatible provider. Callagent.generate()and the agent routes tool calls through MCP automatically.
import { MCPClient } from "@mastra/mcp";
import { Agent } from "@mastra/core/agent";
import { openai } from "@ai-sdk/openai";
const mcpClient = new MCPClient({
id: "kling-ai-generative-video-image-mcp-client",
servers: {
"kling-ai-generative-video-image-mcp": {
url: new URL(
"https://edge.vinkius.com/[YOUR_TOKEN_HERE]/mcp"
),
},
},
});
const agent = new Agent({
name: "Kling AI (Generative Video & Image) Agent",
model: openai("gpt-4o"),
instructions: "You have access to Kling AI (Generative Video & Image) tools.",
tools: {
...(await mcpClient.listTools()),
},
});
const result = await agent.generate(
"List recent Kling AI (Generative Video & Image) transactions"
);
console.log(result.text); Independent Platform Disclaimer: Vinkius is an independent platform and is not affiliated with, endorsed by, sponsored by, verified by, or otherwise authorized by Kling AI. All third-party trademarks, logos, and brand names are the property of their respective owners. Their use on this website is strictly for informational purposes to identify service compatibility and interoperability.
Why Choose Vinkius
Vinkius connects your tools to AI with real-time monitoring and automatic cost savings — all from one dashboard.
Real-time monitoring
Live
visibility into every interaction
Connect your favorite tools to your AI and see exactly what's happening — every request, every response, in real time.
Built-in savings
60%
lower AI costs
Vinkius compresses data between your apps and your AI automatically. Lower bills every month — no configuration required.
Single dashboard
One
place for every integration
Every tool your AI connects to, managed from a single screen. One account, complete control.
Common questions about Kling AI (Generative Video & Image) MCP in Mastra AI
Use it with your favorite AI tools
Connect this server to Cursor, Claude, VS Code, and more.
Start using the Kling AI (Generative Video & Image) MCP today
We host it, we monitor it, we maintain it. You just paste one token.