PiAPI Image Generation MCP server

Integrates with PiAPI to enable AI-driven image generation from text prompts for content creation and visual design tasks.
Back to servers
Setup instructions
Provider
API Network
Release date
Dec 26, 2024
Language
TypeScript
Stats
60 stars

This TypeScript MCP server integrates with PiAPI's API, allowing you to generate media content from Midjourney, Flux, Kling, LumaLabs, Udio, Chrip, and Trellis directly through Claude or other MCP-compatible applications.

Installation Options

Installing via Smithery

For the easiest installation with Claude Desktop:

npx -y @smithery/cli install piapi-mcp-server --client claude

Manual Installation

To install the server manually, follow these steps:

  1. Clone the repository:
git clone https://github.com/apinetwork/piapi-mcp-server
cd piapi-mcp-server
  1. Install dependencies:
npm install
  1. Build the project:
npm run build

Testing with MCP Inspector

To test your server with the MCP Inspector:

  1. Create a .env file with your API key:
PIAPI_API_KEY=your_api_key_here
  1. Start the MCP Inspector:
npm run inspect
  1. Open http://localhost:5173 in your browser

For time-consuming operations like image generation, you may need to increase the timeout: http://localhost:5173?timeout=60000 (sets timeout to 60 seconds)

Connecting to Applications

Claude Desktop Integration

  1. Add this to your Claude Desktop configuration file:
{
  "mcpServers": {
    "piapi": {
      "command": "node",
      "args": ["/absolute/path/to/piapi-mcp-server/dist/index.js"],
      "env": {
        "PIAPI_API_KEY": "your_api_key_here"
      }
    }
  }
}

The configuration file is located at:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  1. Restart Claude Desktop
  2. Look for a hammer icon in the bottom right corner of the input box

Cursor Integration

  1. Navigate to: File > Preferences > Cursor Settings (or use Ctrl+Shift+J)
  2. Select "MCP" tab on the left panel
  3. Click "Add new global MCP server" button
  4. Add your configuration:
{
  "mcpServers": {
    "piapi": {
      "command": "node",
      "args": ["/absolute/path/to/piapi-mcp-server/dist/index.js"],
      "env": {
        "PIAPI_API_KEY": "your_api_key_here"
      }
    }
  }
}
  1. Click the Refresh button or restart Cursor
  2. Test by opening Agent mode (Ctrl+I) and entering "generate image of a dog"

Available Features

This MCP server currently supports:

  • Base Image and Video toolkits
  • Flux Image generation
  • Hunyuan Video generation
  • Skyreels Video generation
  • Wan Video generation
  • MMAudio Music generation
  • TTS Zero-Shot voice generation
  • Midjourney Image generation (imagine command)
  • Kling Video and Effects
  • Luma Dream Machine video generation
  • Suno Music generation
  • Trellis 3D model generation

Note: Time-consuming operations like video generation may not complete due to Claude's timeout limitations.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "piapi" '{"command":"node","args":["/absolute/path/to/piapi-mcp-server/dist/index.js"],"env":{"PIAPI_API_KEY":"your_api_key_here"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "piapi": {
            "command": "node",
            "args": [
                "/absolute/path/to/piapi-mcp-server/dist/index.js"
            ],
            "env": {
                "PIAPI_API_KEY": "your_api_key_here"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "piapi": {
            "command": "node",
            "args": [
                "/absolute/path/to/piapi-mcp-server/dist/index.js"
            ],
            "env": {
                "PIAPI_API_KEY": "your_api_key_here"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later