Pi Api Mcp Server

Pi Api Mcp Server

🚀 PI API 连接器服务器

本项目是一个用于连接 PI API 的 MCP 服务器实现,文档涵盖了完整的安装、配置和使用说明,能帮助用户快速搭建并使用该服务器。

🚀 快速开始

本项目是用于连接 PI API 的 MCP 服务器实现,下面将为你介绍其安装、配置和使用方法。

✨ 主要特性

  • 提供多种部署方式,包括 Docker 部署、直接执行等。
  • 支持不同客户端配置,如 Node.js 和 Docker 实现。
  • 提供常见使用场景的示例查询。

📦 安装指南

使用 Docker 部署

# 克隆仓库(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"

MCP 客户端配置

Node.js 实现

  • 按照 "本地执行" 部分的说明运行开发服务器。
  • 确保已执行 ./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 实现

# 拉取镜像(示例版本)
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"
]
}
}
}

💻 使用示例

基础用法

设置 PI API 连接器

# 安装依赖项
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       # 项目依赖和脚本配置

常见问题

  1. 如何安装依赖项? 使用以下命令安装所有依赖项:
npm install
  1. 如何启动服务器? 构建项目后运行:
npm start
  1. 如何配置服务器? 修改 config.json 文件并重新启动服务器。

贡献指南

  1. ** Fork 仓库**
  2. ** 提交代码**
  3. ** 创建 Pull Request**

📄 许可证

本项目遵循 MIT 协议。请查看 LICENSE 文件以获取详细信息。

如有任何问题,请联系 mingzilla@example.com。

  • 0 关注
  • 0 收藏,20 浏览
  • system 提出于 2025-09-21 13:33

相似服务问题

相关AI产品