{
  "openapi": "3.1.0",
  "info": {
    "title": "MCPGuard & LoopBreaker API",
    "version": "1.3.0",
    "description": "Stateless zero-dependency security auditing for MCP configs, AI agent rules/SKILL.md files, unified repo bundles, and agent run-log circuit breaking."
  },
  "servers": [
    {
      "url": "https://mcpguard-x402-api.vercel.app"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "summary": "Health check and runtime metadata",
        "responses": {
          "200": {
            "description": "Healthy service metadata"
          }
        }
      }
    },
    "/.well-known/x402": {
      "get": {
        "summary": "Machine-readable x402 v2 payment discovery manifest",
        "responses": {
          "200": {
            "description": "x402 v2 discovery document"
          }
        }
      }
    },
    "/api/v1/audit-mcp": {
      "post": {
        "summary": "Audit an MCP JSON/JSONC config for secrets, Docker/FS risks & unpinned npx/uvx packages",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "config": {
                  "mcpServers": {
                    "demo": {
                      "command": "npx",
                      "args": [
                        "-y",
                        "@scope/pkg@1.0.0"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic JSON audit or circuit-breaker report"
          },
          "400": {
            "description": "Invalid JSON or missing required fields"
          },
          "402": {
            "description": "Payment Required (x402 v2 PAYMENT-REQUIRED header)"
          },
          "413": {
            "description": "Payload exceeds 1 MiB limit"
          }
        }
      }
    },
    "/api/v1/sanitize-mcp": {
      "post": {
        "summary": "Replace hardcoded MCP credentials with safe ${ENV_VAR} placeholders",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "config": {
                  "mcpServers": {
                    "demo": {
                      "env": {
                        "API_KEY": "sk-test-placeholder"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic JSON audit or circuit-breaker report"
          },
          "400": {
            "description": "Invalid JSON or missing required fields"
          },
          "402": {
            "description": "Payment Required (x402 v2 PAYMENT-REQUIRED header)"
          },
          "413": {
            "description": "Payload exceeds 1 MiB limit"
          }
        }
      }
    },
    "/api/v1/audit-rules": {
      "post": {
        "summary": "Audit AGENTS.md / CLAUDE.md / .cursorrules / SKILL.md for hidden backdoors & Context Bloat",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "fileName": "AGENTS.md",
                "content": "# Project Rules\nAlways run npm test.\n"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic JSON audit or circuit-breaker report"
          },
          "400": {
            "description": "Invalid JSON or missing required fields"
          },
          "402": {
            "description": "Payment Required (x402 v2 PAYMENT-REQUIRED header)"
          },
          "413": {
            "description": "Payload exceeds 1 MiB limit"
          }
        }
      }
    },
    "/api/v1/audit-repo-bundle": {
      "post": {
        "summary": "Audit a full bundle of MCP configs + Agent Rules/SKILL.md files into one Security Score, Grade, SARIF & Markdown report",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "targetName": "my-repo",
                "mcpConfigs": [
                  {
                    "path": ".vscode/mcp.json",
                    "content": "{}"
                  }
                ],
                "rulesFiles": [
                  {
                    "path": "AGENTS.md",
                    "content": "# Clean Rules\n"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic JSON audit or circuit-breaker report"
          },
          "400": {
            "description": "Invalid JSON or missing required fields"
          },
          "402": {
            "description": "Payment Required (x402 v2 PAYMENT-REQUIRED header)"
          },
          "413": {
            "description": "Payload exceeds 1 MiB limit"
          }
        }
      }
    },
    "/api/v1/circuit-break": {
      "post": {
        "summary": "Evaluate agent JSON/JSONL run logs against hard USD/token caps & ping-pong loop thresholds",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "records": [
                  {
                    "agent": "worker",
                    "tokens": 1200,
                    "costUsd": 0.01,
                    "ts": 1764100000
                  }
                ],
                "maxUsd": 5
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic JSON audit or circuit-breaker report"
          },
          "400": {
            "description": "Invalid JSON or missing required fields"
          },
          "402": {
            "description": "Payment Required (x402 v2 PAYMENT-REQUIRED header)"
          },
          "413": {
            "description": "Payload exceeds 1 MiB limit"
          }
        }
      }
    }
  }
}