CI/CD Integration

Add TrustTrace security scanning to your deployment pipeline. Catch vulnerabilities before they reach production.

API access starts on the Developer plan, within your monthly scan limit. Webhook notifications require the Team plan or above.

Every request authenticates with your API key in the X-API-Key header. Create the key on your account page and store it in your CI platform's secrets.


GitHub Actions

Add this workflow to scan your MCP server on every push or pull request:

name: TrustTrace Security Scan
on: [push, pull_request]

jobs:
  ai-security-scan:
    runs-on: ubuntu-latest
    steps:
      - name: Scan MCP Server
        env:
          API_KEY: ${{ secrets.TRUSTTRACE_API_KEY }}
          MCP_URL: ${{ vars.MCP_SERVER_URL }}
        run: |
          # Submit the scan
          RESULT=$(curl -sS -X POST https://api.trusttrace.io/v1/scan/mcp \
            -H "X-API-Key: $API_KEY" \
            -H "Content-Type: application/json" \
            -d "{\"url\": \"$MCP_URL\"}")
          SCAN_ID=$(echo "$RESULT" | jq -r '.scan_id // empty')
          if [ -z "$SCAN_ID" ]; then
            echo "::error::Scan was not accepted: $(echo "$RESULT" | jq -c '.detail // .error // .')"
            exit 1
          fi

          # Poll for up to 5 minutes
          for i in $(seq 1 30); do
            RESPONSE=$(curl -sS https://api.trusttrace.io/v1/scan/$SCAN_ID -H "X-API-Key: $API_KEY")
            STATUS=$(echo "$RESPONSE" | jq -r '.status')
            case "$STATUS" in
              completed) break ;;
              failed|failed_permanent)
                echo "::error::Scan failed: $(echo "$RESPONSE" | jq -r '.error_message')"
                exit 1 ;;
            esac
            sleep 10
          done
          if [ "$STATUS" != "completed" ]; then
            echo "::error::Scan did not finish in time"
            exit 1
          fi
          echo "$RESPONSE" > scan_results.json

      - name: Check for Critical Findings
        run: |
          CRITICALS=$(jq '[.findings[] | select((.severity | ascii_downcase) == "critical")] | length' scan_results.json)
          HIGHS=$(jq '[.findings[] | select((.severity | ascii_downcase) == "high")] | length' scan_results.json)
          SCORE=$(jq '.overall_score' scan_results.json)

          echo "## TrustTrace Scan Results" >> $GITHUB_STEP_SUMMARY
          echo "Score: $SCORE/100" >> $GITHUB_STEP_SUMMARY
          echo "Critical: $CRITICALS | High: $HIGHS" >> $GITHUB_STEP_SUMMARY

          if [ "$CRITICALS" -gt 0 ]; then
            echo "::error::TrustTrace found $CRITICALS critical findings"
            exit 1
          fi

Finding details (needed to count severities) are returned on every plan. Descriptions and remediation require the Developer plan or above.

Configuration

Add these to your repository settings:

Secrets (Settings → Secrets and variables → Actions):

  • TRUSTTRACE_API_KEY: your TrustTrace API key

Variables (Settings → Secrets and variables → Actions → Variables):

  • MCP_SERVER_URL: your MCP server's streamable HTTP endpoint, usually ending in /mcp, with no query string

Scanning a File

To scan a tools document or package-lock.json instead of a live MCP server (one file per scan, up to 1 MB):

      - name: Scan Tool Definitions
        env:
          API_KEY: ${{ secrets.TRUSTTRACE_API_KEY }}
        run: |
          RESULT=$(curl -sS -X POST https://api.trusttrace.io/v1/scan/upload \
            -H "X-API-Key: $API_KEY" \
            -F "file=@tool_schemas/agent_tools.json")
          SCAN_ID=$(echo "$RESULT" | jq -r '.scan_id // empty')
          # ... poll for results as above

Running a Config Assessment

      - name: Assess Agent Config
        env:
          API_KEY: ${{ secrets.TRUSTTRACE_API_KEY }}
        run: |
          git archive --format=zip -o src.zip HEAD
          RESULT=$(curl -sS -X POST https://api.trusttrace.io/v1/scan/assessment \
            -H "X-API-Key: $API_KEY" \
            -F "config=@trusttrace.yaml" \
            -F "archive=@src.zip")
          SCAN_ID=$(echo "$RESULT" | jq -r '.scan_id // empty')
          # ... poll for results as above

The archive is optional and can be up to 10 MB. A checkout step (actions/checkout@v4) is needed before this one.


GitLab CI

trusttrace-scan:
  stage: test
  image: alpine:3.20
  before_script:
    - apk add --no-cache curl jq
  script:
    - |
      RESULT=$(curl -sS -X POST https://api.trusttrace.io/v1/scan/mcp \
        -H "X-API-Key: $TRUSTTRACE_API_KEY" \
        -H "Content-Type: application/json" \
        -d "{\"url\": \"$MCP_SERVER_URL\"}")
      SCAN_ID=$(echo "$RESULT" | jq -r '.scan_id // empty')
      [ -n "$SCAN_ID" ] || { echo "Scan was not accepted: $RESULT"; exit 1; }

      for i in $(seq 1 30); do
        RESPONSE=$(curl -sS https://api.trusttrace.io/v1/scan/$SCAN_ID -H "X-API-Key: $TRUSTTRACE_API_KEY")
        STATUS=$(echo "$RESPONSE" | jq -r '.status')
        case "$STATUS" in
          completed) break ;;
          failed|failed_permanent) echo "Scan failed: $(echo "$RESPONSE" | jq -r '.error_message')"; exit 1 ;;
        esac
        sleep 10
      done
      [ "$STATUS" = "completed" ] || { echo "Scan did not finish in time"; exit 1; }

      CRITICALS=$(echo "$RESPONSE" | jq '[.findings[] | select((.severity | ascii_downcase) == "critical")] | length')
      if [ "$CRITICALS" -gt 0 ]; then
        echo "Critical findings: $CRITICALS"
        exit 1
      fi
  variables:
    MCP_SERVER_URL: "https://your-server.example.com/mcp"

Add TRUSTTRACE_API_KEY to your GitLab CI/CD variables (Settings → CI/CD → Variables, masked).


Webhooks (Team+)

Instead of polling for results, configure a webhook to receive scan results. This is useful for async pipelines or notification workflows.

Setup

curl -X PUT https://api.trusttrace.io/v1/account/webhook \
  -H "X-API-Key: sk_scan_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"webhook_url": "https://your-app.example.com/webhooks/trusttrace"}'

The first time you set a URL, the response includes a webhook_secret. It is shown once, so store it securely. You can also set the URL from your account page.

Webhook Payload

When a scan completes or fails, TrustTrace sends one signed POST, with no retries. A completed scan sends:

{
  "scan_id": "a1b2c3d4...",
  "status": "completed",
  "scan_type": "mcp",
  "score": 43,
  "grade": "D",
  "findings_count": 11,
  "severity_counts": {
    "Critical": 3,
    "High": 5,
    "Medium": 2,
    "Low": 1
  }
}

A failed scan sends only scan_id, status and scan_type.

Verifying Webhook Authenticity

Every request carries two headers:

  • X-TrustTrace-Timestamp: Unix time in seconds when the request was signed.
  • X-TrustTrace-Signature: hex HMAC-SHA256 of {timestamp}.{raw request body}, keyed with your webhook secret.

Verify the signature over the raw body, before parsing it, and reject any timestamp more than 5 minutes (300 seconds) from your own clock so a captured request cannot be replayed:

import hashlib
import hmac
import time

TOLERANCE_SECONDS = 300  # 5 minutes


def verify_webhook(payload: bytes, timestamp: str, signature: str, secret: str) -> bool:
    """payload is the raw request body, exactly as received."""
    if not secret:
        return False
    try:
        sent_at = int(timestamp)
    except ValueError:
        return False
    if abs(time.time() - sent_at) > TOLERANCE_SECONDS:
        return False
    expected = hmac.new(
        secret.encode("utf-8"),
        timestamp.encode("utf-8") + b"." + payload,
        hashlib.sha256,
    ).hexdigest()
    return hmac.compare_digest(expected, signature)

Pass the X-TrustTrace-Timestamp and X-TrustTrace-Signature header values as timestamp and signature. See the API reference for the full field list.


Best Practices

Scan on every PR. Catch issues before they're merged. Use the GitHub Actions workflow above to block PRs with Critical findings.

Scan after dependency updates. Run an upload scan with your updated package-lock.json, or a config assessment with a code archive, to catch unpinned and typosquatted packages.

Set up baseline tracking. On Pro+ plans, regular MCP scans build a baseline. You'll catch tool definition changes (rug pulls) that appear between scans.

Don't store your API key in code. Use your CI/CD platform's secrets management (GitHub Secrets, GitLab Variables, etc.).

Fail builds on Critical only. Blocking on High findings during early adoption creates too much friction. Start with Critical-only gating, then tighten over time as your team resolves existing issues.