
Petra Security
io.github.WYRE-AI由 GitHub 账号 WYRE-AI 发布v1.0.1更新于 Nov 7, 2026
Read-only Petra Security MCP: M365 compromise incidents, failed attacks, posture, tenants, usage.
概览
只读访问 Petra Security 数据:M365 账号入侵事件、被拦截攻击、安全态势报告、租户与计费用量。
- 可以做什么
- 列出各租户及其 Petra 与 Microsoft 租户 ID、接入日期和暂停状态
- 查看组织级计费用量与各租户的可计费用户
- 列出并查询 M365 账号入侵事件,可选包含钓鱼邮件信息
- 按国家、日期和被攻击用户汇总单个租户的被拦截攻击
- 读取 M365 安全态势报告,含评分、等级、主要风险与修复建议
- 适用场景
- 适合已在使用 Petra Security 的托管服务商或安全团队,让助手在不打开 Petra 控制台的情况下排查 M365 账号入侵事件、查看被拦截攻击趋势、检查安全态势问题,或获取租户与计费摘要。
- 运行要求
- 以本地进程运行(Docker 镜像或从源码构建的 npm 包)。需要 Petra API 密钥,放在 PETRA_API_KEY 中,由 Petra 管理员在 Settings > API Keys 创建。需能访问固定的 Petra API 主机。HTTP 模式还需 CONDUIT_S2S_SECRET,网关模式下每个请求还需 X-Petra-Api-Key 请求头。
安装
在 SourceWeft 中
- 打开 控制台中的 Petra Security,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Petra Security MCP Server
Read-only MCP server for Petra Security's public REST API, for AI assistants and the WYRE Conduit gateway. Petra detects and investigates Microsoft 365 account compromises (BEC, session hijacks). This server exposes its incidents, failed attacks, posture reports, tenants, usage and billable users.
Authentication
A Petra Admin creates an API key at app.petrasecurity.com under Settings > API Keys. The full key is shown only once, so store it in a secrets manager immediately. Full Members can see the key list but cannot create keys.
Every request goes to https://api.petrasecurity.com with Authorization: Bearer <key> and a User-Agent header (Petra returns 403 without one). The host is fixed and cannot be changed by request headers or tool arguments.
Petra rate-limits each route to 10 requests per minute. A 429 comes back as a tool error that names the Retry-After-public-api wait. To spare that budget, successful responses are cached in memory per API key (keyed by a SHA-256 of the key) for 60 seconds, and /v1/failed-attacks for 5 minutes. Identical concurrent requests share one upstream call.
Configuration
Copy .env.example and set the variables below. The stdio transport reads PETRA_API_KEY and does not use CONDUIT_S2S_SECRET.
/health and /healthz stay unauthenticated and do not read credentials.
HTTP authentication
With MCP_TRANSPORT=http and CONDUIT_S2S_SECRET set, every /mcp request must include X-Gateway-S2S. The check is verifyS2sHeader in src/s2s-verify.ts: the header value is t=<unix seconds>,v1=<hex>, where the hex is HMAC-SHA256 of the literal string t=<unix seconds> keyed with CONDUIT_S2S_SECRET (64 lowercase hex characters). The timestamp must be within 300 seconds of the server clock. A missing or invalid header is HTTP 401, before vendor credentials are read. An empty secret refuses to start unless MCP_ALLOW_INSECURE_DEV=1. A known placeholder (replace-with-a-real-secret, your-s2s-secret, changeme, change-me, placeholder, secret, example, replace-me, s2s-secret, any case) refuses to start even with that flag, so a copied example cannot forge the header.
In AUTH_MODE=gateway, /mcp also requires X-Petra-Api-Key. That header is the only credential source for the request. A request without it returns 401 and does not fall back to PETRA_API_KEY in the process environment.
AUTH_MODE=env still requires a valid X-Gateway-S2S header, then uses PETRA_API_KEY from the environment.
Request limits
- HTTP request bodies are capped at 256 KiB (262144 bytes). After the
X-Gateway-S2Scheck (and, withAUTH_MODE=gateway, theX-Petra-Api-Keypresence check) passes, aContent-Lengthabove the cap returns 413 with a JSON-RPC error; bodies withoutContent-Lengthare capped by the MCP SDK transport. Unauthenticated requests still get 401 first. tools/callarguments are capped at 10,000 elements (every array item and object key at any depth). Larger inputs return anisErrortool result and are never dispatched.
These limits address CVE-2026-111768 / GHSA-46jr-4wx8-v453 (memory exhaustion during validation) and GHSA-f897-62hf-6gxq (no request body / batch cap).
Tools
Every tool is a GET, annotated readOnlyHint: true and destructiveHint: false. Where a tool takes tenantId, either the Petra tenant ID (e.g. ZZk90t, from petra_list_tenants or the app.petrasecurity.com/tenant/<id> URL) or the Microsoft tenant ID works.
Tenants and billing
petra_list_tenants- every client tenant with Petra and Microsoft tenant IDs, onboarding date and paused flag (GET /v1/tenants). OptionalnameContainsandincludePausedfilters.petra_get_usage- organization-wide billing snapshot per tenant: service, billable status, licensed and billable users, prorating, first billable date, plus totals (GET /v1/usage). OptionalasOf,includePaused(setfalseso paused tenants don't inflate counts) andbillableStatus.petra_list_billable_users- billable users for one tenant with UPN, mail, enabled flag and license SKUs (GET /v1/billable-users). Petra documents only the Petra tenant ID here, so a Microsoft tenant ID is resolved through/v1/tenantsfirst. OptionalenabledOnly.
Security events
petra_list_incidents- M365 compromise incidents, newest first, with user, remediation status, live flag, dwell time and phishing email (GET /v1/incidents). OmittenantIdfor all tenants.startDateandlimit(1-500) go to Petra;remediationStatus,liveOnly,userPrincipalNameandincludePhishingEmailare applied locally after the limit.petra_get_incident- one incident by ID. Petra has no single-incident route, so this searches the newest 500 (passtenantIdto reach older ones in a tenant).petra_get_failed_attacks- blocked-attack summary for one tenant: total, by country, daily by attack type, and most-targeted users (GET /v1/failed-attacks). Defaults to the last 30 days.petra_list_posture_reports- M365 posture reports: score and grade, control rollup, Global Admin review, top risks and every check with its suggested fix (GET /v1/posture-reports). Latest per tenant by default. OptionalincludeChecks: falsefor a compact view.
Scope
This server covers the first five tools StackJack ships for Petra (petra_list_tenants, petra_get_usage, petra_list_billable_users, petra_list_incidents, petra_get_failed_attacks), with the same names, and adds petra_get_incident and petra_list_posture_reports.
Petra's public API has no write, remediation, pause or scan-trigger routes, so there is nothing to gate. GET /v1/usage-xlsx is left out on purpose: it returns a binary spreadsheet and needs a separate Multi-MSP API key.
The request and response shapes come from Petra's published OpenAPI spec (/docs/api-reference/openapi.json). Tests mock the API, and nothing has been tested against a live Petra key yet.
Development
Docker
The image listens on 0.0.0.0 inside the container (MCP_HTTP_HOST) and defaults to AUTH_MODE=gateway. Startup still refuses to run without a real CONDUIT_S2S_SECRET. Publish the port on loopback. In gateway mode, the Petra key arrives on each request as a header and is not read from the environment.
Compose refuses to start when CONDUIT_S2S_SECRET is unset, defaults AUTH_MODE to gateway, publishes 127.0.0.1:8080:8080, and does not set PETRA_API_KEY or env_file:
Single-tenant HTTP (AUTH_MODE=env) still requires the S2S secret, then uses PETRA_API_KEY:
Local HTTP without a secret is development-only. It binds 127.0.0.1 (including when MCP_HTTP_HOST is localhost or ::1) and logs a warning. A non-loopback MCP_HTTP_HOST makes startup exit. The container image sets MCP_HTTP_HOST=0.0.0.0, so the bypass inside Docker also needs -e MCP_HTTP_HOST=127.0.0.1. Do not publish that port off loopback.
来源:README.md,提交 e681853
工具
0版本历史
2- v1.0.1最新Nov 7, 2026
- v1.0.0Nov 3, 2026
评分
已满足适用检查项的 40%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
请在仓库或注册中心条目中声明许可证。
