Piapi Mcp 伺服器
一個 TypeScript 實現的模型上下文協議 (MCP) 伺服器,與 PiAPI 的 API 整合。PiAPI 使得用戶能夠直接從 Claude 或任何其他兼容 MCP 的應用程序生成 Midjourney/Flux/Kling/LumaLabs/Udio/Chrip/Trellis 的媒體內容。
概覽
什麼是 PiAPI MCP 伺服器?
PiAPI MCP 伺服器是一個 TypeScript 實現的模型上下文協議(MCP)伺服器,無縫整合了 PiAPI 的 API。這個創新的伺服器允許用戶直接從 Claude 或任何其他兼容 MCP 的應用程序生成媒體內容,使用各種平台,如 Midjourney、Flux、Kling、LumaLabs、Udio、Chirp 和 Trellis。它作為用戶命令與這些平台的媒體生成能力之間的橋樑,增強了用戶體驗並簡化了內容創作。
PiAPI MCP 伺服器的特點
- TypeScript 實現:使用 TypeScript 構建,確保類型安全和更好的開發實踐。
- MCP 兼容性:完全符合模型上下文協議,便於與其他兼容 MCP 的應用程序進行集成。
- 多平台支持:支持多種媒體生成平台,使用戶能夠在不同服務之間創建內容。
- 用戶友好的界面:以可用性為設計理念,使得用戶能夠輕鬆生成媒體內容,而無需廣泛的技術知識。
- 開源:作為公共存儲庫提供,允許開發者貢獻、修改和增強伺服器的功能。
如何使用 PiAPI MCP 伺服器
-
安裝:從 GitHub 克隆存儲庫並使用 npm 或 yarn 安裝必要的依賴項。
git clone https://github.com/apinetwork/piapi-mcp-server.git cd piapi-mcp-server npm install
-
配置:在提供的配置文件中設置您的 API 密鑰和配置設置,以連接到所需的媒體生成平台。
-
運行伺服器:使用以下命令啟動伺服器:
npm start
-
發送請求:使用伺服器提供的 API 端點發送媒體生成請求。確保您的請求符合 MCP 規範。
-
集成:將伺服器與您的兼容 MCP 應用程序集成,以開始生成媒體內容。
常見問題
問題 1:PiAPI MCP 伺服器的目的是什么?
回答 1:PiAPI MCP 伺服器充當用戶與各種媒體生成平台之間的中介,通過統一的 API 允許高效的內容創作。
問題 2:PiAPI MCP 伺服器是免費使用的嗎?
回答 2:是的,PiAPI MCP 伺服器是開源的,並且在 GitHub 上免費提供。
問題 3:我可以為 PiAPI MCP 伺服器做貢獻嗎?
回答 3:當然可以!歡迎貢獻。您可以分叉存儲庫,進行更改,並提交拉取請求。
問題 4:我可以使用哪些平台生成媒體內容?
回答 4:該伺服器支持多個平台,包括 Midjourney、Flux、Kling、LumaLabs、Udio、Chirp 和 Trellis。
問題 5:我如何報告問題或請求功能?
回答 5:您可以通過在 GitHub 存儲庫上打開問題來報告問題或請求功能。
通過利用 PiAPI MCP 伺服器,用戶可以簡化其媒體生成過程,並增強其在各種平台上的創意工作流程。
詳細
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/Chrip/Trellis directly from Claude or any other MCP-compatible apps.
<a href="https://glama.ai/mcp/servers/ywvke8xruo"><img width="380" height="200" src="https://glama.ai/mcp/servers/ywvke8xruo/badge" alt="PiAPI-Server MCP server" /></a>
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
Prerequisites
- Node.js 16.x or higher
- npm or yarn
- A PiAPI API key (get one at piapi.ai)
Installation
- Clone the repository:
git clone https://github.com/apinetwork/piapi-mcp-server
cd piapi-mcp-server
- Install dependencies:
npm install
- Build the project:
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.
- (Optional) Test server with MCP Inspector:
First, create a .env
file in the project root directory with your API key:
PIAPI_API_KEY=your_api_key_here
Then run the following command to start the MCP Inspector:
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):
{
"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:
- Navigate to: File > Preferences > Cursor Settings, or use the shortcut key
Ctrl+Shift+J
- Select "MCP" tab on the left panel
- Click "Add new global MCP server" button in the top right
- 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"
}
}
}
}
- After configuration, you'll see a "piapi" entry in MCP Servers page
- Click the Refresh button on the entry or restart Cursor to connect to the piapi server
To test the piapi image generation:
- Open and select "Agent mode" in Cursor Chat, or use the shortcut key
Ctrl+I
- Enter a test prompt, for example: "generate image of a dog"
- The image will be generated based on your prompt using piapi server
To disable the piapi server:
- Navigate to the MCP Servers page in Cursor Settings
- Find the "piapi" entry in the server list
- 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
License
MIT
伺服器配置
{
"mcpServers": {
"piapi-mcp-server": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/metorial/mcp-container--apinetwork--piapi-mcp-server--piapi-mcp-server",
"node dist/index.js"
],
"env": {
"PIAPI_API_KEY": "piapi-api-key"
}
}
}
}