技术参考文档
PETP — 流水线 · 执行 · 任务 · 处理器
基于 Python 的可配置任务运行器、执行引擎和 MCP 工具服务器。PET = Pipeline-Execution-Task,层级模型。末尾的 P = Processor,与每个任务一一对应。
Pipeline 1:n Execution
Execution 1:n Task
Task 1:1 Processor
运行模式
🖥️
桌面 GUI
基于 wxPython 的完整可视化运行时。支持交互式 RPA、本地开发和手动触发执行。
python PETP.py
⚙️
后台 / JOB模式
无 GUI,自动检测后台 Chrome,适用于定时任务、CLI 流水线和服务器自动化。
python PETP_backgroud.py
🐳
Docker
多架构镜像(arm64 构建 → amd64 运行),无头模式,支持 CI/CD 和 NAS 部署。
docker run -p 8866:8866 petp
🔌
MCP 工具服务器
将执行任务暴露为带类型的 MCP 工具,同时支持 stdio 和 Streamable-HTTP 传输方式。
GET /mcp · port 8866
处理器库
| 分类 | 能力 |
|---|---|
| Browser Automation Selenium |
Navigate, go back, fullscreen, close Chrome. Find element(s) then click / key-in / collect. Batch find with skip. iFrame, cookies, screenshot. Convert Selenium IDE recordings to PETP tasks. |
| SSH / SFTP Paramiko |
Create SSH / SFTP sessions. Run remote commands. Upload / download files. |
| File & Folder | Open, write, delete, read text. Find files / latest file. Watch & auto-move. ZIP / UNZIP. File-chooser dialog. |
| Data & Spreadsheet | Read CSV / Excel. Write to Excel. CSV to XLSX. Collect, filter, group-by, mapping, masking, conversion. Merge collections. |
| Database CRUD | MySQL, PostgreSQL, SAP HANA, SQLite — unified DB_ACCESS
processor.
|
| AI / LLM | DeepSeek, Google Gemini, Ollama (local), Zhipu Z.AI — each with Setup + Q&A + MCP-tool calling processors. |
| MCP | Expose PETP as standard MCP Tool Server (Streamable-HTTP). MCP client processors for all LLM providers. |
| HTTP / Network | Configurable HTTP requests. Extract response keys. Built-in HTTP service (port 8866). OAuth2 / PKCE. |
| String Utilities | Encode / decode (Base64, URL…). Hash (MD5, SHA256…). |
| Mouse & GUI PyAutoGUI |
Click, scroll, query position at absolute or relative coordinates. |
| Send email via SMTP with attachments. | |
| Data Visualization | Charts and plots via Matplotlib. |
| Execution Control | Init / check params. Nested execution. Conditional stop. Wait / sleep. Reload log config. Read JSON. Run shell commands. Run JavaScript. |
HTTP 服务与 MCP 端点
内置 HTTP 服务器 — 端口 8866
| 方法 | 端点 | 说明 |
|---|---|---|
| GET | / | PETP HTTP service home |
| GET | /mcp | MCP Tool Server — Streamable-HTTP transport |
| GET | /health | Health check (Docker / container) |
| GET | /petp/tools | List all exposed MCP tools |
| POST | /petp/exec | Trigger execution or pipeline (async) |
| GET | /petp/result | Poll async result by ?request_id=<id> |
| POST | /mcp | MCP Tool Server — direct POST endpoint |
MCP Inspector 配置
将任何 MCP Inspector 或兼容 MCP 的客户端直接连接到 PETP 的 HTTP 服务器。
- 传输类型:Streamable HTTP
- URL:http://localhost:8866/mcp
- 本地开发无需身份验证
- Claude Code、Cursor、VS Code Copilot——在设置中添加为 MCP 服务器
# Claude Code — add PETP as MCP server # .claude/settings.json or mcpServers config "mcpServers": { "petp": { "type": "http", "url": "http://localhost:8866/mcp" } } # Or trigger via HTTP POST (no MCP client needed) POST http://localhost:8866/petp/exec { "wait_for_result": "true", "action": "execution", "params": { "execution": "YOUR_EXECUTION_NAME", "fromHTTPService": "true" } }
依赖分组
Modular requirements/
structure — install only what you need. Uses uv (10-100× faster than pip) or standard pip.
core.txt
pyyaml, croniter, cryptocode
web-automation.txt
selenium, urllib3, Pillow
http-client.txt
requests, httpx, httpx-sse
ssh-sftp.txt
paramiko
excel-data.txt
openpyxl, pandas
database.txt
psycopg, mysql-connector, hdbcli
ai-deepseek.txt
openai (DeepSeek compat.)
ai-gemini.txt
google-genai
ai-ollama.txt
ollama (local LLM)
ai-zhipu.txt
zai (Zhipu Z.AI)
mcp.txt
mcp protocol
http-service.txt
fastapi, uvicorn
javascript.txt
pythonmonkey
gui-wxpython.txt
wxpython 4.3.x
gui-automation.txt
pyautogui, pyperclip
chart.txt
matplotlib
安装选项
- Full (GUI desktop):
requirements.txt - Background service:
requirements-nogui.txt - Docker / headless:
requirements-docker.txt - Custom: combine any group files with
-r
# Recommended: uv (fast) pip install -U uv uv pip install -r requirements.txt # Custom combination uv pip install \ -r requirements/core.txt \ -r requirements/mcp.txt \ -r requirements/http-service.txt # Pin versions for reproducible builds uv pip compile requirements.txt \ -o requirements.lock
项目结构
| 目录 / 文件 | 说明 |
|---|---|
| PETP.py | GUI desktop entry point |
| PETP_backgroud.py | Headless / background entry point |
| config/petpconfig.yaml | Main runtime configuration |
| core/executions/ | YAML execution definitions |
| core/processors/ | Processor implementations — one .py per task type |
| core/pipelines/ | YAML pipeline definitions |
| core/runtime/ | Background / no-GUI runtime logic |
| core/definition/ | YAML reader, Selenium IDE converter |
| httpservice/ | HTTP server, MCP handler, request routing |
| mvp/ | GUI layer (Model-View-Presenter with wxPython) |
| utils/ | Utilities — Selenium, Excel, Date, OS, Logger, Paramiko |
| webapp/ | Flask web application (this site) |
| webdriver/ | Platform ChromeDriver binaries |