piapi-mcp-server logo

piapi-mcp-server

Community
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.

Publisherapinetwork
Repositorypiapi-mcp-server
LanguageTypeScript
Forks
22
Stars
75
Available tools
0
Transport typestdio
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    piapi-mcp-server exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    75 stars and 22 forks from the linked repository.

piapi-mcp-server

Website Documentation Discord

smithery badge

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.

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
  • Suno Music generation
  • Suno Lyrics generation
  • Udio Music and Lyrics generation
  • Trellis 3D model generation from image
  • Workflow planning inside LLMs

Working with Claude Desktop Example

image

Prerequisites

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

Installation

Installing via Smithery

To install PiAPI MCP Server for Claude Desktop automatically via Smithery:

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

Manual Installation

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

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.

  1. (Optional) Test server with MCP Inspector:

First, create a .env file in the project root directory with your API key:

bash
PIAPI_API_KEY=your_api_key_here

Then run the following command to start the MCP Inspector:

bash
npm run inspect

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):

json
{
  "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
json
{
  "mcpServers": {
    "piapi": {
      "command": "node",
      "args": ["/absolute/path/to/piapi-mcp-server/dist/index.js"],
      "env": {
        "PIAPI_API_KEY": "your_api_key_here"
      }
    }
  }
}
  1. After configuration, you'll see a "piapi" entry in MCP Servers page
  2. 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"

Keeping tools in sync with PiAPI (sync task)

src/index.ts registers a contract-backed MCP tool for every committed PiAPI (model, task_type) capability. Tool names are deterministic: piapi_<model>_<task_type> (for example, piapi_qubico_flux1_schnell_txt2img), and their input schemas are generated from the committed catalog. The existing hand-written convenience tools remain available; the contract-backed tools ensure the exposed surface stays complete as the Manager catalog changes.

The legacy convenience tools in src/index.ts remain hand-written, but the complete contract-backed surface is generated from the committed catalog. This repository includes a repeatable drift detector that compares that catalog baseline with PiAPI Manager's versioned API contract. It detects new APIs, deprecated APIs, parameter changes, and description changes.

Source of truth: the Go API.postman_collection.json contract in the PiAPI Manager GitHub repository (Gocyber-world/midjourney-http-v2). The task fetches that versioned contract directly from GitHub and extracts the POST /api/v1/task examples into (model, task_type) capabilities. If the Manager repository is private, set the CI secret MCP_SYNC_GITHUB_TOKEN with least-privilege contents: read on that source repository (and only the separate approved write permissions needed for MCP update automation). It has no Apidog dependency and deliberately does not inspect or report pricing.

Commands

bash
npm run build          # compile the MCP server and sync task
npm run test:sync      # offline sync-engine tests (no network or credentials)
npm run sync           # fetch contract and diff baseline; exit 0 = in sync, 2 = drift
npm run sync:snapshot  # print the normalized current contract catalog
npm run sync:report    # write the Markdown drift report to sync-report.md
npm run sync:accept    # after updating src/index.ts, refresh the baseline

By default, npm run sync uses the Manager GitHub contract. For recovery or local development, an exported OpenAPI JSON file can be supplied instead:

bash
node dist/sync/cli.js diff --file ./piapi-openapi.json

When a drift report is produced, a new capability is already represented by its contract-backed MCP tool after the baseline is accepted. Validate the MCP server, run npm run sync:accept, and commit the refreshed baseline. Update a hand-written convenience tool only when a curated model-specific UX is useful.

Automation

.github/workflows/sync-piapi.yml is retained for manual dispatch only. Periodic synchronization is run from the approved local automation environment, which holds the separately owner-approved MCP credential and can validate, accept, and push catalog updates after its sensitive-information gate passes.

Development

Project Structure

piapi-mcp-server/
├── assets/
├── src/
│   ├── index.ts        # Main server entry point
│   └── sync/           # PiAPI -> MCP sync task
│       ├── cli.ts          # CLI: snapshot / diff / accept / report-file
│       ├── fetchers.ts     # GitHub Postman contract + local-file sources
│       ├── normalize.ts    # OpenAPI -> (model, task_type) catalog
│       ├── diff.ts         # catalog diff + Markdown report
│       ├── catalog.ts      # baseline load/save
│       ├── mcp_tools.ts    # catalog -> contract-backed FastMCP tool schemas
│       ├── selftest.ts     # offline engine test (npm run test:sync)
│       ├── types.ts
│       └── baseline.piapi-catalog.json  # committed baseline
├── .github/workflows/sync-piapi.yml     # weekly drift check
├── package.json
├── tsconfig.json
└── .env.example

License

MIT

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "apinetwork-piapi-mcp-server": {
      "command": "",
      "args": []
    }
  }
}

Use piapi-mcp-server MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once piapi-mcp-server is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add piapi-mcp-server as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the piapi-mcp-server MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "apinetwork-piapi-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "piapi-mcp-server"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the piapi-mcp-server MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the piapi-mcp-server MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use piapi-mcp-server to help me with this task?
piapi-mcp-server
Sure. I read it.
Here is what I found using piapi-mcp-server.

Frequently asked questions

What is the piapi-mcp-server MCP server used for?

piapi-mcp-server is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use piapi-mcp-server MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use piapi-mcp-server with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use piapi-mcp-server MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With piapi-mcp-server connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect piapi-mcp-server MCP to TypingMind?

piapi-mcp-server runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does piapi-mcp-server MCP provide in TypingMind?

piapi-mcp-server exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use piapi-mcp-server MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If piapi-mcp-server requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇