MCP HubMCP Hub
apinetwork

piapi-mcp-server

by: apinetwork

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/Chrip/Trellis directly from Claude or any other MCP-compatible apps.

36created 26/12/2024
Visit
TypeScript
API

πŸ“ŒOverview

Purpose: The piapi-mcp-server is designed to facilitate the integration of Model Context Protocol (MCP) support with PiAPI's API for generating media content.

Overview: This TypeScript-based implementation acts as a server allowing users to generate various forms of media content using different platforms directly from compatible applications like Claude. It streamlines the creative process by connecting multiple media generation tools seamlessly.

Key Features:

  • Base Media Toolkits: Offers fundamental toolkits for image and video generation, making it a versatile solution for content creators.

  • Multi-Platform Media Generation: Supports generation from multiple sources, including text and image prompts for various media types such as images, videos, and music.


piapi-mcp-server

A TypeScript implementation of a Model Context Protocol (MCP) server that integrates with PiAPI's API, enabling users to generate media content with various tools directly from Claude or any other MCP-compatible applications.

Features

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
  • Kling Video and Effects generation
  • Luma Dream Machine video generation
  • Suno Music generation
  • Udio Music and Lyrics generation
  • Trellis 3D model generation from image
  • Workflow planning inside LLMs

Prerequisites

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

Installation

  1. Clone the repository:

    git clone https://github.com/apinetwork/piapi-mcp-server
    cd piapi-mcp-server
    
  2. Install dependencies:

    npm install
    
  3. Build the project:

    npm run build
    

    A dist/index.js file will be generated, which can be configured with Claude Desktop and other applications.

  4. (Optional) Test server with MCP Inspector:

    • Create a .env file in the project root with your API key:
      PIAPI_API_KEY=your_api_key_here
      
    • Start the MCP Inspector:
      npm run inspect
      

    The MCP Inspector will be available at http://localhost:5173.

Usage

Connecting to Claude Desktop

Add the following 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"
      }
    }
  }
}

Restart Claude after updating this configuration.

Connecting to Cursor

  1. Navigate to: File > Preferences > Cursor Settings
  2. Select "MCP" tab
  3. Click "Add new global MCP server" button
  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"
      }
    }
  }
}
  1. Refresh the entry or restart Cursor to connect to the piapi server.

Testing Image Generation

  1. Open "Agent mode" in Cursor Chat.
  2. Enter a test prompt, for example: "generate image of a dog".

Disabling the piapi Server

  1. Navigate to the MCP Servers page.
  2. Find the "piapi" entry and toggle it to "Disabled".

Development

Project Structure

piapi-mcp-server/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ index.ts        # Main server entry point
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└── .env.example

License

MIT