本项目是一个用于连接 PI API 的 MCP 服务器实现,文档涵盖了完整的安装、配置和使用说明,能帮助用户快速搭建并使用该服务器。
本项目是用于连接 PI API 的 MCP 服务器实现,下面将为你介绍其安装、配置和使用方法。
# 克隆仓库(SSH 或 HTTPS)
git clone git@github.com:mingzilla/pi-api-mcp-server.git
cd pi-api-mcp-server
# 安装依赖项
npm install
./dependencies.sh # 安装全局依赖以支持 MCP 客户端通过 "@mingzilla/pi-api-mcp-server" 连接
# 构建项目
npm run build
# 启动服务器
npm start
# 全局安装
npm install -g @mingzilla/pi-api-mcp-server
# 通过 npx 执行
npx @mingzilla/pi-api-mcp-server --api-url "http://localhost:8224/pi/api/v2" --auth-token "XXXXXXXX"
./dependencies.sh 以安装所需的全局依赖项。@mingzilla/pi-api-mcp-server 引用通过 "本地执行" 安装的包){
"mcpServers": {
"pi-api": {
"command": "npx",
"args": [
"-y",
"@mingzilla/pi-api-mcp-server",
"--api-url",
"http://localhost:8224/pi/api/v2",
"--auth-token",
"XXXXXXXX"
],
"autoApprove": [
"keep-session-alive",
"check-connection",
"authenticate",
"list-categories",
"get-category",
"list-charts",
"get-chart",
"export-chart",
"get-filterable-attributes",
"export-chart"
]
}
}
}
# 拉取镜像(示例版本)
docker pull mingzilla/pi-api-mcp-server:
# 运行容器
docker run -it --name pi-api-mcp-server mingzilla/pi-api-mcp-server: --api-url "http://localhost:8224/pi/api/v2" --auth-token "XXXXXXXX"
# 启动本地服务器
./start.sh
配置文件示例:
{
"mcpServers": {
"pi-api": {
"command": "node",
"args": [
"/home/mingzilla/dev/tool-mcp-pi-api-server/build/index.js",
"--api-url",
"http://localhost:8224/pi/api/v2",
"--auth-token",
"XXXXXXXX"
],
"autoApprove": [
"keep-session-alive",
"check-connection",
"authenticate",
"list-categories",
"get-category",
"list-charts",
"get-chart",
"export-chart",
"get-filterable-attributes",
"export-chart"
]
}
}
}
# 安装依赖项
npm install @mingzilla/pi-api-mcp-server
# 创建配置文件
vi config.json
以下是一些常见的使用场景:
curl -X GET "http://localhost:8224/categories"
curl -X GET "http://localhost:8224/categories/123"
curl -X POST "http://localhost:8224/categories" -H "Content-Type: application/json" -d '{"name":"New Category"}'
pi-api-mcp-server/
├── src/ # 源代码目录
│ ├── index.js # 入口文件
│ └── routes/ # 路由定义
├── build/ # 构建输出目录
├── config/ # 配置文件
└── package.json # 项目依赖和脚本配置
npm install
npm start
config.json 文件并重新启动服务器。本项目遵循 MIT 协议。请查看 LICENSE 文件以获取详细信息。
如有任何问题,请联系 mingzilla@example.com。