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
Server配置
{
"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"
}
}
}
}