PiAPI
HomeWorkspace
HomeWorkspace
Join Discord
  1. Resources
  • Get Started
    • Overview
    • Quickstart
    • Make Instruction: How to Use PiAPI to Build a Workflow on Make?
  • Endpoints
    • Song(Udio)
      • Song API Task Creation Examples
      • [Udio] Song Extend
      • Get Task
      • Create Task
      • [Udio] Generate Lyrics
    • Kling
      • Lipsync With PiAPI Kling API Examples
      • Motion Brush With PiAPI Kling API Example
      • Kling Elements Video Generation API
      • Kling Effects Video Generation
      • Cancel Task
        • Cancel Tasks
        • Cancel Task
      • Get Task
      • Create Task
      • Kling Virtual Try-On
    • Hailuo
      • Hailuo Director Mode Example
      • Generate Video
      • Get Task
    • Flux
      • Flux with LoRA and Controlnet
      • Available LoRA and Controlnet
      • Flux API with Redux Variation, Fill, Inpaint and Outpaint
      • Create Task
        • Text to Image
        • Image to Image
      • Get task
    • AI Hug
      • Get Task
      • Create Task
    • LLM
      • Use Cases for GPT-4o Image API
      • How To Avoid Timeouts in Completion API
      • GPT-4o Image Generation API
      • LLM API | Basic Completions
      • Get Task
    • Midjourney
      • PiAPI Penalties on Midjourney Usage
      • Detailed Explaination on Midjourney Task Result
      • Midjourney V7 API Instructions
      • Create Task
        • Imagine
        • Upscale
        • Variation
        • Reroll
        • Describe
        • Seed
        • Blend
        • Inpaint
        • Outpaint
        • Pan
      • Cancel Task
        • Cancel Task
        • Cancel Tasks
      • Get Task
    • Faceswap
      • Multi Faceswap
      • Image Faceswap
      • Video Faceswap
      • Get Task
    • TTS
      • Zeroshot Text-to-Speech F5-TTS
      • Get Task
    • Trellis
      • Create Task
      • Get Task
    • Luma Dream Machine
      • Cancel Task
        • Cancel Tasks
        • Cancel Task
      • Create Task
      • Get Task
    • WanX
      • Generate WanX Task with LoRA Using PiAPI
      • Available LoRA Types for Wanx
      • Use Cases for Wanx LoRA
      • Use Cases for Wanx Control Camera
      • Create Task
      • Get Task
    • Skyreels
      • Create Task
      • Get Task
    • Framepack
      • Create Task
      • Get Task
    • Hunyuan Video
      • How to Make a Hunyuan API Call
      • Get Task
      • Generate Video
    • Mmaudio
      • Get Task
      • Generate Audio
    • DiffRhythm
      • Generate Audio
      • Get Task
    • Tools
      • File Upload API
      • Video Upscale
      • Video Upscale-Get Task
      • Remove Background API
      • Remove Background-Get Task
      • Segment With Prompt API
      • Segment With Prompt API-Get Task
      • Image Upscale(Super Resolution) API
      • Image Upscale-Get Task
    • PiAPI Account Management
      • PiAPI Account Info
      • Task List Info
      • User Task History
  • Resources
    • Change Log
    • Output Storage
    • Unified API Schema
    • Webhook
    • Bulk Generation Service
    • Billings
    • PiAPI MCP Server
    • Workspace Manual
      • Host-your-account (HYA) | Back-up Account
      • Host-your-account (HYA) | Debug Checklist
      • Host-your-account (HYA) | Connected Account Status
    • Announcements
      • PiAPI 2025 January 1st Pricing Update
  • Legacy Documentation
    • Midjourney
      • Midjourney Webhook
      • Imagine
      • Reroll
      • Upscale
      • Variation
      • Inpaint
      • Outpaint
      • Pan
      • Describe
      • Blend
      • Seed
      • Fetch
      • Multi Fetch
      • Cancel
    • Face Swap
      • Video Faceswap
      • Multi-face-swap
      • Fetch
    • Dream Machine
      • Video Generation
      • Video Extend
      • Get Video Generation
    • Kling
      • Video Generation
      • Video Extend
      • Get Video Generation
  1. Resources

PiAPI MCP Server

piapi-mcp-server#

A TypeScript implementation of a Model Context Protocol (MCP) server that integrates with PiAPI's API. PiAPI makes user able to generate media content with Midjourney/Flux/Kling/LumaLabs/Udio/Wanx/Trellis directly from Claude or any other MCP-compatible apps.

Features (more coming soon)#

Note: Time-consuming tools like video generation may not complete due to Claude's timeout limitations
Base Image toolkit
Base Video toolkit
Flux Image generation from text/image prompt
Hunyuan Video generation from text/image prompt
Skyreels Video generation from image prompt
Wan Video generation from text/image prompt
MMAudio Music generation from video
TTS Zero-Shot voice generation
Midjourney Image generation
imagine
other
Kling Video and Effects generation
Luma Dream Machine video generation
Udio Music and Lyrics generation
Trellis 3D model generation from image
Workflow planning inside LLMs

Working with Claude Desktop Example#

Prerequisites#

Node.js 16.x or higher
npm or yarn
A PiAPI API key (get one at piapi.ai)

Installation#

1.
Clone the repository:
2.
Install dependencies:
3.
Build the project:
After building, a dist/index.js file will be generated. You can then configure this file with Claude Desktop and other applications. For detailed configuration instructions, please refer to the Usage section.
4.
(Optional) Test server with MCP Inspector:
First, create a .env file in the project root directory with your API key:
Then run the following command to start the MCP Inspector:
After running the command, MCP Inspector will be available at http://localhost:5173 (default port: 5173). Open this URL in your browser to start testing. The default timeout for inspector operations is 10000ms (10 seconds), which may not be sufficient for image generation tasks. It's recommended to increase the timeout when testing image generation or other time-consuming operations. You can adjust the timeout by adding a timeout parameter to the URL, for example: http://localhost:5173?timeout=60000 (sets timeout to 60 seconds)
The MCP Inspector is a powerful development tool that helps you test and debug your MCP server implementation. Key features include:
Interactive Testing: Test your server's functions directly through a web interface
Real-time Feedback: See immediate results of your function calls and any errors that occur
Request/Response Inspection: View detailed information about requests and responses
Function Documentation: Browse available functions and their parameters
Custom Parameters: Set custom timeout values and other configuration options
History Tracking: Keep track of your previous function calls and their results
For detailed information about using the MCP Inspector and its features, visit the official MCP documentation.

Usage#

Connecting to Claude Desktop#

Add this to your Claude Desktop configuration file (~/Library/Application Support/Claude/claude_desktop_config.json on macOS or %APPDATA%\Claude\claude_desktop_config.json on Windows):
{
  "mcpServers": {
    "piapi": {
      "command": "node",
      "args": ["/absolute/path/to/piapi-mcp-server/dist/index.js"],
      "env": {
        "PIAPI_API_KEY": "your_api_key_here"
      }
    }
  }
}
After updating your configuration file, you need to restart Claude for Desktop. Upon restarting, you should see a hammer icon in the bottom right corner of the input box.
For more detailed information, visit the official MCP documentation

Connecting to Cursor#

Note: Following guide is based on Cursor 0.47.5. Features and behaviors may vary in different versions.
To configure the MCP server:
1.
Navigate to: File > Preferences > Cursor Settings, or use the shortcut key Ctrl+Shift+J
2.
Select "MCP" tab on the left panel
3.
Click "Add new global MCP server" button in the top right
4.
Add your configuration in the opened mcp.json file
{
  "mcpServers": {
    "piapi": {
      "command": "node",
      "args": ["/absolute/path/to/piapi-mcp-server/dist/index.js"],
      "env": {
        "PIAPI_API_KEY": "your_api_key_here"
      }
    }
  }
}
5.
After configuration, you'll see a "piapi" entry in MCP Servers page
6.
Click the Refresh button on the entry or restart Cursor to connect to the piapi server
To test the piapi image generation:
1.
Open and select "Agent mode" in Cursor Chat, or use the shortcut key Ctrl+I
2.
Enter a test prompt, for example: "generate image of a dog"
3.
The image will be generated based on your prompt using piapi server
To disable the piapi server:
1.
Navigate to the MCP Servers page in Cursor Settings
2.
Find the "piapi" entry in the server list
3.
Click the "Enabled" toggle button to switch it to "Disabled"

Development#

Project Structure#

piapi-mcp-server/
├── assets/
├── src/
│   ├── index.ts        # Main server entry point
├── package.json
├── tsconfig.json
└── .env.example
Previous
Billings
Next
Host-your-account (HYA) | Back-up Account