CLI and SDK
Use typed SDK and shell-friendly HTTP workflows in CI.
CLI and SDK
PreFlight exposes a maintained npm SDK for runtime signals and typed automation, alongside a REST API, MCP server, and shell-friendly CI patterns. This page covers each interface and when to use it.
curl, fetch, GitHub Actions, and AI hosts like Cursor and Claude Desktop.
Interface comparison
npm SDK
npm install @getpreflight/sdk
Use @getpreflight/sdk/next for the Next.js component, /browser for framework-neutral setup, /server for privacy-safe Threat Signals, and /api for typed automation. See Install the SDK for supported examples and the fixed coding-agent prompt.
REST API quick reference
Base URL: https://getpreflight.dev/api/v1
curl example: trigger a check
curl -X POST \
-H "Authorization: Bearer pf_live_your_key_here" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: deploy-$(date +%Y%m%d-%H%M%S)" \
https://getpreflight.dev/api/v1/projects/YOUR_PROJECT_UUID/checks
curl example: query the release rule
response=$(curl -sS -o /dev/null -w "%{http_code}" \
-H "Authorization: Bearer $PREFLIGHT_API_KEY" \
"https://getpreflight.dev/api/v1/projects/$PROJECT_ID/deploy-gate?mode=strict")
if [ "$response" != "200" ]; then
echo "Deploy blocked"
exit 1
fi
MCP Server
The MCP server wraps the REST API into tool calls that AI agents understand natively. It runs locally via stdio transport.
Install and run
# From the PreFlight repository root
npm install
npm run mcp -- --api-key pf_live_... --project-id YOUR_UUID
Or configure environment variables:
PREFLIGHT_API_KEY=pf_live_...
PREFLIGHT_PROJECT_ID=550e8400-e29b-41d4-a716-446655440000
PREFLIGHT_API_URL=https://getpreflight.dev
Available MCP tools
See the dedicated MCP server guide for host configuration examples.
CI integration patterns
GitHub Actions
jobs:
preflight-gate:
runs-on: ubuntu-latest
steps:
- name: Run PreFlight checks
run: |
curl -X POST \
-H "Authorization: Bearer ${{ secrets.PREFLIGHT_API_KEY }}" \
-H "Idempotency-Key: ${{ github.run_id }}" \
https://getpreflight.dev/api/v1/projects/${{ vars.PROJECT_ID }}/checks
- name: Query release rule
run: |
code=$(curl -sS -o gate.json -w "%{http_code}" \
-H "Authorization: Bearer ${{ secrets.PREFLIGHT_API_KEY }}" \
"https://getpreflight.dev/api/v1/projects/${{ vars.PROJECT_ID }}/deploy-gate?mode=strict")
cat gate.json
if [ "$code" != "200" ]; then
echo "::error::release rule blocked the release"
exit 1
fi
GitLab CI
preflight-gate:
stage: deploy
script:
- |
code=$(curl -sS -o gate.json -w "%{http_code}" \
-H "Authorization: Bearer $PREFLIGHT_API_KEY" \
"$PREFLIGHT_URL/api/v1/projects/$PROJECT_ID/deploy-gate?mode=strict")
cat gate.json
if [ "$code" != "200" ]; then exit 1; fi
rules:
- if: $CI_COMMIT_BRANCH == "main"
Vercel deploy hook
Run the gate check before vercel deploy --prod:
#!/bin/bash
set -e
# Trigger fresh check
curl -sS -X POST \
-H "Authorization: Bearer $PREFLIGHT_API_KEY" \
-H "Idempotency-Key: vercel-$(date +%s)" \
"$PREFLIGHT_URL/api/v1/projects/$PROJECT_ID/checks"
# Wait for check to complete (simple polling)
sleep 10
# Evaluate gate
code=$(curl -sS -o /dev/null -w "%{http_code}" \
-H "Authorization: Bearer $PREFLIGHT_API_KEY" \
"$PREFLIGHT_URL/api/v1/projects/$PROJECT_ID/deploy-gate?mode=strict")
if [ "$code" = "200" ]; then
vercel deploy --prod
else
echo "PreFlight gate blocked deployment"
exit 1
fi
SDK design principles
Environment variables reference
npm run mcp, and the REST API works with any HTTP client. This keeps your CI environment clean and avoids version drift.
<RelatedLinks links={[ { href: "/docs/api/overview", title: "API overview", description: "Full resource catalog and response shapes." }, { href: "/docs/api/authentication", title: "API authentication", description: "Key creation, scopes, and rate limits." }, { href: "/docs/api/mcp-server", title: "MCP server", description: "Detailed setup for Cursor, Claude Desktop, and other hosts." }, { href: "/docs/guides/deploy-gates", title: "Release Rules", description: "Turn API calls into CI release blockers." }, ]} />
